feat(race): practice seeding setting (EFRA 3 in a row), seeding time in lists and a new-seeding-time call (1.89.49)
This commit is contained in:
1 parent
f2adc67695
commit
576847279d
15 files changed
+146
-17
No files matched your search
@@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
No changes recorded yet.
|
||||
|
||||
## 1.89.49 - 2026-11-16
|
||||
|
||||
- Races: new **Practice seeding** setting at the top of Manage → Format (number of laps and method). The practice heats are ranked on it for Generate qualifying from practice, and lists and overlay show the seeding time ("3 in a row 0:54.312"). EFRA and the other federation presets use the 3 fastest laps in a row; changing it re-ranks practice already run. Before, practice in a race always ranked on the best single lap. Open Practice is not affected.
|
||||
- A driver who has not yet driven enough laps for a seeding time now ranks after everyone who has (their best single lap used to beat a sum of 3 laps).
|
||||
- New training call in race practice: "Roy, new seeding time, 54 31. 0.40 quicker." when a driver beats their own seeding time (on by default; Settings → Audio, seed improved).
|
||||
|
||||
## 1.89.48 - 2026-11-16
|
||||
|
||||
- Checkboxes everywhere sit in front of their text again. The general field style stretched them across the whole cell and stacked them above the text (e.g. Settings → OBS config, the race wizard), so a box often looked like it belonged to the next field.
|
||||
|
||||
@@ -175,7 +175,7 @@ After creation the race is managed in four tabs (Race Setup → Manage):
|
||||
- presets: short technical track, club race, ÖRC Winter, endurance, and whole race days in federation style - **EFRA 1/10 Off-road**, **EFRA 1/10 Touring / On-road**, **EFRA/SBF 1/8 Nitro** (bump-up, long final), **IFMAR worlds**, **ROAR** (timed qualifying, bump-up, single A main), **Quick club day**, **Rookie / Junior** and **Points race without finals** - or your own saved club presets. A federation preset also sets the practice rounds (with seeding on the best 3 laps in a row), and its description is shown under the choice. The values follow the handbooks in spirit; rules change between editions, so everything stays editable;
|
||||
- **Race actions** at the bottom of the tab:
|
||||
- create qualifying from practice (or the entry list); heats are split as evenly as possible, e.g. 9 drivers with max 8 per heat gives 5 + 4;
|
||||
- practice is split into heats the same way;
|
||||
- practice is split into heats the same way, and ranked by **Practice seeding** at the top of Format (0 = best single lap; EFRA presets: 3 fastest laps in a row). Lists and overlay show the seeding time, and a better seeding time is called out ("new seeding time, 0.40 quicker"). Open Practice is not affected;
|
||||
- changing cars per heat or the number of qualifying rounds under Format rebuilds the practice and qualifying heats that have not run yet;
|
||||
- Manage → Race actions shows the buttons in the order of the day: 1. after practice, **Generate qualifying from practice**; 2. between qualifying rounds (optional), **Regroup qualifying heats not run yet**; 3. after qualifying, **Generate finals from qualifying** and bump-ups. Until qualifying is built from practice, the heat list says the qualifying heats are preliminary; locked manual grids are respected;
|
||||
- create A/B/C finals and apply bump-ups;
|
||||
|
||||
+1
-1
@@ -188,7 +188,7 @@ Efter det hanteras racet i fyra flikar (Race Setup → Hantera):
|
||||
- förval: kort teknisk bana, klubbrace, ÖRC Winter, endurance, och hela racedagar i förbundsstil – **EFRA 1/10 Off-road**, **EFRA 1/10 Touring / On-road**, **EFRA/SBF 1/8 Nitro** (bump-up, lång final), **IFMAR VM**, **ROAR** (tidskval, bump-up, en A-final), **Klubbdag snabb**, **Rookie / Junior** och **Poängrace utan finaler** – eller egna sparade klubbförval. Ett förbundsförval sätter även antal träningar (med seeding på bästa 3 varv i följd), och beskrivningen visas under valet. Värdena följer handböckerna i stil; reglerna ändras mellan årgångar, så allt går att justera;
|
||||
- **Race actions** längst ner i fliken:
|
||||
- skapa kval från träningen (eller deltagarlistan); heaten delas så jämnt som möjligt, till exempel 9 förare och max 8 per heat → 5 + 4;
|
||||
- träningen (practice) delas i heat på samma sätt;
|
||||
- träningen (practice) delas i heat på samma sätt och rankas enligt **Practice-seedning** överst i Format (0 = bästa enskilda varv; EFRA-förvalen: 3 snabbaste varv i rad). Listor och overlay visar seedningstiden, och en bättre seedningstid ropas ut ("ny seedningstid, 0,40 snabbare"). Open Practice påverkas inte;
|
||||
- ändrar du bilar per heat eller antal kvalomgångar under Format byggs de practice- och kvalheat som inte har körts om;
|
||||
- Hantera → Race actions visar knapparna i dagens ordning: 1. efter practice, **Skapa kval från practice**; 2. mellan kvalomgångarna (valfritt), **Dela om kvalheat som inte körts**; 3. efter kvalet, **Skapa finaler från kval** och bump-up. Tills kvalet är skapat från practice står det i heatlistan att kvalheaten är preliminära; låsta manuella grid respekteras;
|
||||
- skapa A/B/C-finaler och bump-up;
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.48",
|
||||
"version": "1.89.49",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.48",
|
||||
"version": "1.89.49",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.48",
|
||||
"version": "1.89.49",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"transponder_pass": { "effect": "effects/transponder_pass.wav" },
|
||||
"transponder_detected": { "effect": "effects/transponder_pass.wav" },
|
||||
"training_stable_pace": { "voice": "training_stable_pace" },
|
||||
"seed_improved": { "voice": "seed_improved" },
|
||||
"entering_pits": { "effect": "effects/transponder_pass.wav" },
|
||||
"leaving_pits": { "effect": "effects/transponder_pass.wav" },
|
||||
"personal_best": { "effect": "effects/personal_best.wav" },
|
||||
@@ -60,6 +61,7 @@
|
||||
"clock_running": "Clock is running.",
|
||||
"personal_best": "Personal best. {driverName}. {lapTime}.", "fastest_lap": "Fastest lap. {driverName}. {lapTime}.",
|
||||
"training_stable_pace": "{driverName}, good pace and consistent driving. Average {avgLap}.",
|
||||
"seed_improved": "{driverName}, new seeding time, {seedTime}. {gain} quicker.",
|
||||
"track_record": "New track record. {driverName}. {lapTime}.", "new_leader": "New race leader. {driverName}.",
|
||||
"leader_update": "{driverName} leads, {laps} laps.",
|
||||
"lap_completed": "{driverPrefix}{lapShort}.",
|
||||
@@ -100,6 +102,7 @@
|
||||
"clock_running": "Klockan går.",
|
||||
"personal_best": "Personbästa. {driverName}. {lapTime}.", "fastest_lap": "Snabbaste varv. {driverName}. {lapTime}.",
|
||||
"training_stable_pace": "{driverName}, bra tempo och stabil körning. Snitt {avgLap}.",
|
||||
"seed_improved": "{driverName}, ny seedningstid, {seedTime}. {gain} snabbare.",
|
||||
"track_record": "Nytt banrekord. {driverName}. {lapTime}.", "new_leader": "Ny ledare. {driverName}.",
|
||||
"leader_update": "{driverName} leder, {laps} varv.",
|
||||
"lap_completed": "{driverPrefix}{lapShort}.",
|
||||
|
||||
+19
-5
@@ -2546,7 +2546,7 @@ const TRANSLATIONS = {
|
||||
"guide.race_wizard_1": "1. Börja i Race Setup och använd wizarden när du skapar ett nytt race, i stället för att bygga allt direkt i Hantera.",
|
||||
"guide.race_wizard_2": "2. Steg 1 sätter namn, datum, klass och preset. Det finns hela tävlingsdagar som preset (EFRA off-road, touring, 1/8 nitro, ROAR, snabb klubbdag, Rookie/Junior, poängrace utan finaler) - beskrivningen visas under valet. Presetet fyller rimliga standardvärden innan du finjusterar något.",
|
||||
"guide.race_wizard_3": "3. Steg 2 väljer exakt vilka förare som ska vara med. Listan är grupperad per klass med Alla/Ingen per klass, sök på namn eller transponder och Samma förare som... för att kopiera ett tidigare race. De blir race-specifika deltagare och filter för timing/seedning.",
|
||||
"guide.race_wizard_4": "4. Steg 3 väljer vilka sessioner som ska skapas direkt: practice, kval och/eller team race beroende på preset. Practice och kval delas i heat med högst Bilar per heat (12 förare och max 5 → 4 + 4 + 4). Ändrar du Bilar per heat eller antal kvalomgångar under Hantera → Format innan heaten har körts byggs de om av sig själva; heat som redan har körts rörs inte.",
|
||||
"guide.race_wizard_4": "4. Steg 3 väljer vilka sessioner som ska skapas direkt: practice, kval och/eller team race beroende på preset. Practice och kval delas i heat med högst Bilar per heat (12 förare och max 5 → 4 + 4 + 4). Ändrar du Bilar per heat eller antal kvalomgångar under Hantera → Format innan heaten har körts byggs de om av sig själva; heat som redan har körts rörs inte. Practice rankas enligt Practice-seedning överst i Format (EFRA: 3 snabbaste varv i rad), och listor och overlay visar seedningstiden. Slår en förare sin seedningstid ropas det ut (\"ny seedningstid, 0,40 snabbare\").",
|
||||
"guide.race_wizard_5": "5. Wizarden skapar de första sessionerna automatiskt, kvalet som heat (Q1 H1, Q1 H2 …). Finaler skapas senare från Race actions när kval eller practice är klara.",
|
||||
"guide.race_wizard_6": "6. Efter skapandet går du vidare till Hantera för raceformat, generering, grid, standings och utskrift.",
|
||||
"guide.race_wizard_7": "7. I Hantera -> Race actions kan du exportera eller importera ett enskilt racepaket om du vill flytta just det racet till en annan installation.",
|
||||
@@ -2573,6 +2573,13 @@ const TRANSLATIONS = {
|
||||
"events.qual_seed_laps_hint": "0 = flest varv på tiden vinner (vanligast). Över 0 = heatet rankas på så många bästa varv i stället.",
|
||||
"events.qual_seed_method": "Kval seedmetod",
|
||||
"events.qual_seed_method_hint": "Hur kvalheat räknar varv när bästa-varvsläget används.",
|
||||
"events.practice_seed_laps": "Practice-seedning: antal varv",
|
||||
"events.practice_seed_laps_hint": "Hur practice-heaten rankas inför kvalet. 0 = bästa enskilda varv. 3 med Bästa N konsekutiva varv = EFRA-seedning (3 snabbaste varv i rad). Gäller även redan körd practice – rankingen räknas om från varven.",
|
||||
"events.practice_seed_method": "Practice-seedning: metod",
|
||||
"seed.in_a_row": "{n} i rad",
|
||||
"seed.average": "snitt {n}",
|
||||
"seed.best_sum": "{n} bästa",
|
||||
"events.practice_seed_method_hint": "Hur varven räknas när antal varv är över 0.",
|
||||
"events.counted_qual_rounds": "Räknade kvalrundor",
|
||||
"events.counted_qual_rounds_hint": "Hur många av kvalrundorna som räknas i slutrankingen.",
|
||||
"events.qual_points_table": "Poängtabell",
|
||||
@@ -4983,7 +4990,7 @@ const TRANSLATIONS = {
|
||||
"guide.race_wizard_1": "1. Start in Race Setup and use the wizard when creating a new race instead of building everything directly in Manage.",
|
||||
"guide.race_wizard_2": "2. Step 1 sets name, date, class and preset. Whole race days come as presets (EFRA off-road, touring, 1/8 nitro, ROAR, quick club day, Rookie/Junior, points race without finals) - the description shows under the choice. The preset fills sensible defaults before you fine-tune anything.",
|
||||
"guide.race_wizard_3": "3. Step 2 selects exactly which drivers take part. The list is grouped by class with All/None per class, a search on name or transponder and Same drivers as... to copy an earlier race. They become the race-specific participant scope for timing and seeding.",
|
||||
"guide.race_wizard_4": "4. Step 3 chooses which sessions should be created immediately: practice, qualifying and/or team race depending on the preset. Practice and qualifying are split into heats of at most Cars per heat (12 drivers and max 5 → 4 + 4 + 4). If you change Cars per heat or the number of qualifying rounds under Manage → Format before the heats have run, they are built again by themselves; heats that have already run are left alone.",
|
||||
"guide.race_wizard_4": "4. Step 3 chooses which sessions should be created immediately: practice, qualifying and/or team race depending on the preset. Practice and qualifying are split into heats of at most Cars per heat (12 drivers and max 5 → 4 + 4 + 4). If you change Cars per heat or the number of qualifying rounds under Manage → Format before the heats have run, they are built again by themselves; heats that have already run are left alone. Practice is ranked by Practice seeding at the top of Format (EFRA: 3 fastest laps in a row), and lists and overlay show the seeding time. When a driver beats their seeding time it is called out (\"new seeding time, 0.40 quicker\").",
|
||||
"guide.race_wizard_5": "5. The wizard creates the initial sessions automatically, qualifying as heats (Q1 H1, Q1 H2 …). Finals are generated later from Race Actions after qualifying or practice is complete.",
|
||||
"guide.race_wizard_6": "6. After creation, continue in Manage for race format, generation, grid, standings and print/export.",
|
||||
"guide.race_wizard_7": "7. In Manage -> Race Actions you can export or import a single race package when you want to move just that race to another installation.",
|
||||
@@ -5010,6 +5017,13 @@ const TRANSLATIONS = {
|
||||
"events.qual_seed_laps_hint": "0 = most laps in the time wins (most common). Above 0 = the heat is ranked on that many best laps instead.",
|
||||
"events.qual_seed_method": "Qualifying seed method",
|
||||
"events.qual_seed_method_hint": "How qualifying heats evaluate laps when best-lap mode is used.",
|
||||
"events.practice_seed_laps": "Practice seeding: number of laps",
|
||||
"events.practice_seed_laps_hint": "How the practice heats are ranked before qualifying. 0 = best single lap. 3 with Best N consecutive laps = EFRA seeding (3 fastest laps in a row). Also applies to practice already run – the ranking is worked out again from the laps.",
|
||||
"events.practice_seed_method": "Practice seeding: method",
|
||||
"seed.in_a_row": "{n} in a row",
|
||||
"seed.average": "avg {n}",
|
||||
"seed.best_sum": "best {n}",
|
||||
"events.practice_seed_method_hint": "How the laps are counted when the number of laps is above 0.",
|
||||
"events.counted_qual_rounds": "Counted qualifying rounds",
|
||||
"events.counted_qual_rounds_hint": "How many qualifying rounds count toward the final ranking.",
|
||||
"events.qual_points_table": "Points table",
|
||||
@@ -8490,12 +8504,12 @@ function formatSeedMetric(metric) {
|
||||
return "-";
|
||||
}
|
||||
if (metric.method === "average") {
|
||||
return `${metric.lapCount} avg ${formatLap(metric.averageMs)}`;
|
||||
return `${t("seed.average", { n: metric.lapCount })} ${formatLap(metric.averageMs)}`;
|
||||
}
|
||||
if (metric.method === "consecutive") {
|
||||
return `${metric.lapCount} con ${formatRaceClock(metric.totalMs)}`;
|
||||
return `${t("seed.in_a_row", { n: metric.lapCount })} ${formatRaceClock(metric.totalMs)}`;
|
||||
}
|
||||
return `${metric.lapCount}/${formatRaceClock(metric.totalMs)}`;
|
||||
return `${t("seed.best_sum", { n: metric.lapCount })} ${formatRaceClock(metric.totalMs)}`;
|
||||
}
|
||||
|
||||
function clearGeneratedQualifying(eventId) {
|
||||
|
||||
+20
-1
@@ -13,6 +13,9 @@ import { getCompetitorEndTs } from "./timing_logic.js";
|
||||
const PRACTICE_SESSION_TYPES = new Set(["open_practice", "free_practice", "practice"]);
|
||||
// Last personal best *called* per driver, per practice day and layout (practice_callouts_logic.js).
|
||||
const lastPracticePbCall = new Map();
|
||||
// Best seeding time (best N laps) per driver and practice heat in a race, for the
|
||||
// "new seeding time" call. Only practice in a race ranked on N laps, never Open Practice.
|
||||
const bestSeedTime = new Map();
|
||||
const practiceHypeMemory = new Map();
|
||||
const lastLeaderCallBySession = new Map();
|
||||
const leaderMemoryByHeat = new Map();
|
||||
@@ -691,6 +694,22 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
|
||||
if (callPersonalBest) triggerRaceAudio("personal_best", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
if (!suspect && previousSessionFastest && lapMs < previousSessionFastest) triggerRaceAudio("fastest_lap", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
if (!suspect && previousTrackRecord && lapMs < previousTrackRecord) triggerRaceAudio("track_record", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
let seedCall = false;
|
||||
if (session.type === "practice" && Number(session.seedBestLapCount || 0) > 0 && !suspect && !validationWarning) {
|
||||
const metric = leaderboard.find((row) => row.key === key)?.seedMetric;
|
||||
const before = bestSeedTime.get(pbCallKey);
|
||||
if (metric) {
|
||||
// At least a hundredth quicker than the driver's own best seeding time in this heat.
|
||||
if (before && metric.comparableMs <= before - 10) {
|
||||
const language = normalizeRaceAudioSettings(state.settings?.raceAudio).language;
|
||||
const timeMs = metric.method === "average" ? metric.averageMs : metric.totalMs;
|
||||
const gainMs = before - metric.comparableMs;
|
||||
triggerRaceAudio("seed_improved", { variables: { ...audioVariables, seedTime: formatSpokenLapTime(timeMs, language), gain: formatSpokenGap(gainMs, language) }, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, sessionId: session.id, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
seedCall = true;
|
||||
}
|
||||
if (!before || metric.comparableMs < before) bestSeedTime.set(pbCallKey, metric.comparableMs);
|
||||
}
|
||||
}
|
||||
let hype = null;
|
||||
if (isPracticeSession && entry.driverId && !suspect && !validationWarning) {
|
||||
hype = buildPracticeHype({ state, session, result, entry, key, lapMs, previousPersonalBest, memoryKey: pbCallKey, timestamp });
|
||||
@@ -698,7 +717,7 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
|
||||
}
|
||||
// The quick lap time, "Anders, 17 six": only when nothing else is called for this lap and the
|
||||
// voice is free (race_audio.js decides practice / always / off).
|
||||
const calledThisLap = callPersonalBest || hype
|
||||
const calledThisLap = callPersonalBest || hype || seedCall
|
||||
|| (!suspect && previousSessionFastest && lapMs < previousSessionFastest) || (!suspect && previousTrackRecord && lapMs < previousTrackRecord);
|
||||
if (!calledThisLap && !validationWarning && lapMs > 500) {
|
||||
const audio = normalizeRaceAudioSettings(state.settings?.raceAudio);
|
||||
|
||||
@@ -770,6 +770,8 @@ export function renderEventManagerView(context) {
|
||||
qualStartMode: config.qualStartMode,
|
||||
qualSeedLapCount: config.qualSeedLapCount,
|
||||
qualSeedMethod: config.qualSeedMethod,
|
||||
practiceSeedLapCount: config.practiceSeedLapCount,
|
||||
practiceSeedMethod: config.practiceSeedMethod,
|
||||
countedQualRounds: config.countedQualRounds,
|
||||
qualifyingPointsTable: config.qualifyingPointsTable,
|
||||
qualifyingTieBreak: config.qualifyingTieBreak,
|
||||
|
||||
@@ -280,6 +280,19 @@ export function renderEventManagerMarkup(context) {
|
||||
</div>
|
||||
</div>
|
||||
`}
|
||||
${/* Practice runs first in the day, so its seeding comes first in the format. */""}
|
||||
${showBasicQualifyingFields ? renderRaceFormatFieldView(
|
||||
"events.practice_seed_laps",
|
||||
"events.practice_seed_laps_hint",
|
||||
`<input type="number" min="0" name="practiceSeedLapCount" value="${event.raceConfig.practiceSeedLapCount || 0}" />`
|
||||
) : ""}
|
||||
${showBasicQualifyingFields ? renderRaceFormatFieldView(
|
||||
"events.practice_seed_method",
|
||||
"events.practice_seed_method_hint",
|
||||
`<select name="practiceSeedMethod">
|
||||
${["consecutive", "best_sum", "average"].map((value) => `<option value="${value}" ${(event.raceConfig.practiceSeedMethod || "consecutive") === value ? "selected" : ""}>${t(`events.seed_method_${value}`)}</option>`).join("")}
|
||||
</select>`
|
||||
) : ""}
|
||||
${showBasicQualifyingFields ? renderRaceFormatFieldView(
|
||||
"events.qualifying_scoring",
|
||||
"events.qualifying_scoring_hint",
|
||||
|
||||
+18
-3
@@ -28,6 +28,8 @@ const FEDERATION_BASE = {
|
||||
qualDurationMin: 5,
|
||||
qualSeedLapCount: 3,
|
||||
qualSeedMethod: "consecutive",
|
||||
practiceSeedLapCount: 3,
|
||||
practiceSeedMethod: "consecutive",
|
||||
qualifyingPointsTable: "rank_low",
|
||||
qualifyingTieBreak: "rounds",
|
||||
finalDurationMin: 5,
|
||||
@@ -267,6 +269,11 @@ export function buildRaceFormatConfigFromForm(form, event, { normalizeStartMode,
|
||||
qualSeedMethod: ["best_sum", "average", "consecutive"].includes(String(form.get("qualSeedMethod") || "").toLowerCase())
|
||||
? String(form.get("qualSeedMethod")).toLowerCase()
|
||||
: "best_sum",
|
||||
// How the race's practice heats are ranked for seeding: 0 = best single lap, else best N laps.
|
||||
practiceSeedLapCount: Math.max(0, Math.round(Number(form.get("practiceSeedLapCount") ?? event.raceConfig.practiceSeedLapCount) || 0)),
|
||||
practiceSeedMethod: ["best_sum", "average", "consecutive"].includes(String(form.get("practiceSeedMethod") ?? event.raceConfig.practiceSeedMethod ?? "").toLowerCase())
|
||||
? String(form.get("practiceSeedMethod") ?? event.raceConfig.practiceSeedMethod).toLowerCase()
|
||||
: "consecutive",
|
||||
countedQualRounds: Math.max(1, Number(form.get("countedQualRounds") || 1) || 1),
|
||||
qualifyingPointsTable: ["rank_low", "field_desc", "ifmar"].includes(String(form.get("qualifyingPointsTable") || "").toLowerCase())
|
||||
? String(form.get("qualifyingPointsTable")).toLowerCase()
|
||||
@@ -316,6 +323,10 @@ export function normalizeEvent(event, { normalizeBrandingConfig, normalizeStartM
|
||||
qualSeedMethod: ["best_sum", "average", "consecutive"].includes(String(event?.raceConfig?.qualSeedMethod || "").toLowerCase())
|
||||
? String(event.raceConfig.qualSeedMethod).toLowerCase()
|
||||
: "best_sum",
|
||||
practiceSeedLapCount: Math.max(0, Math.round(Number(event?.raceConfig?.practiceSeedLapCount) || 0)),
|
||||
practiceSeedMethod: ["best_sum", "average", "consecutive"].includes(String(event?.raceConfig?.practiceSeedMethod || "").toLowerCase())
|
||||
? String(event.raceConfig.practiceSeedMethod).toLowerCase()
|
||||
: "consecutive",
|
||||
countedQualRounds: Math.max(1, Number(event?.raceConfig?.countedQualRounds || 1) || 1),
|
||||
qualifyingPointsTable: ["rank_low", "field_desc", "ifmar"].includes(String(event?.raceConfig?.qualifyingPointsTable || "").toLowerCase())
|
||||
? String(event.raceConfig.qualifyingPointsTable).toLowerCase()
|
||||
@@ -645,7 +656,11 @@ export function buildPracticeHeats(event, rounds, { t, buildRaceSession }) {
|
||||
for (let round = 1; round <= Math.max(1, Number(rounds) || 1); round += 1) {
|
||||
groups.forEach((driverIds, index) => {
|
||||
const name = `${t("session.practice")} ${round}${groups.length > 1 ? ` H${index + 1}` : ""}`;
|
||||
const session = buildRaceSession(event.id, name, "practice", event.raceConfig?.qualDurationMin, { driverIds, startMode: "mass", followUpSec: 0 });
|
||||
const session = buildRaceSession(event.id, name, "practice", event.raceConfig?.qualDurationMin, {
|
||||
driverIds, startMode: "mass", followUpSec: 0,
|
||||
seedBestLapCount: Number(event.raceConfig?.practiceSeedLapCount) || 0,
|
||||
seedMethod: event.raceConfig?.practiceSeedMethod || "consecutive",
|
||||
});
|
||||
session.generated = true;
|
||||
sessions.push(session);
|
||||
});
|
||||
@@ -1306,10 +1321,10 @@ export function buildEventSchedule(event, sessions) {
|
||||
// value changed are applied, so a heat edited by hand keeps its own other values.
|
||||
// How a heat is ranked (best N laps, method) only decides its result, which is worked out from
|
||||
// the laps each time: a wrong choice fixed afterwards also re-ranks heats already run.
|
||||
const RANKING_ONLY_KEYS = new Set(["qualSeedLapCount", "qualSeedMethod"]);
|
||||
const RANKING_ONLY_KEYS = new Set(["qualSeedLapCount", "qualSeedMethod", "practiceSeedLapCount", "practiceSeedMethod"]);
|
||||
export function applyFormatToPendingSessions(sessions, before = {}, after = {}) {
|
||||
const fields = {
|
||||
practice: [["qualDurationMin", "durationMin"]],
|
||||
practice: [["qualDurationMin", "durationMin"], ["practiceSeedLapCount", "seedBestLapCount"], ["practiceSeedMethod", "seedMethod"]],
|
||||
qualification: [["qualDurationMin", "durationMin"], ["qualStartMode", "startMode"], ["followUpSec", "followUpSec"], ["qualSeedLapCount", "seedBestLapCount"], ["qualSeedMethod", "seedMethod"]],
|
||||
final: [["finalDurationMin", "durationMin"], ["finalStartMode", "startMode"], ["followUpSec", "followUpSec"]],
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@ export const RACE_AUDIO_EVENT_DEFINITIONS = Object.freeze([
|
||||
event("fastest_lap", "race", "normal", true, "effects/fastest_lap_trophy.wav", 1500),
|
||||
event("track_record", "race", "normal", true, "effects/track_record_fanfare.wav", 2000),
|
||||
event("training_stable_pace", "training", "low", true, "", 120000),
|
||||
event("seed_improved", "training", "low", true, "", 0),
|
||||
event("new_leader", "race", "normal", true, "", 1000),
|
||||
event("leader_update", "race", "normal"),
|
||||
...PRACTICE_HYPE_EVENTS.map((key) => event(key, "training", "low")),
|
||||
|
||||
+8
-2
@@ -618,17 +618,23 @@ export function buildPracticeStandings(event, { getSessionsForEvent, buildLeader
|
||||
const sessions = getSessionsForEvent(event.id).filter((session) => session.type === "practice");
|
||||
const competitorMap = new Map();
|
||||
|
||||
// A heat ranked on best N laps: a driver without N laps yet has no seeding time, so they go
|
||||
// after everyone who has one (their best single lap would otherwise beat a sum of N laps).
|
||||
const better = (a, b) => a.tier - b.tier || a.comparableMs - b.comparableMs;
|
||||
sessions.forEach((session) => {
|
||||
const needsSeedTime = Number(session.seedBestLapCount || 0) > 0;
|
||||
buildLeaderboard(session).forEach((row) => {
|
||||
const key = row.driverId || row.key;
|
||||
const seedMetric = getCompetitorSeedMetric(session, row);
|
||||
const comparableMs = seedMetric?.comparableMs ?? row.bestLapMs ?? row.totalElapsedMs;
|
||||
const tier = needsSeedTime && !seedMetric ? 1 : 0;
|
||||
const current = competitorMap.get(key);
|
||||
if (!current || comparableMs < current.comparableMs) {
|
||||
if (!current || better({ tier, comparableMs }, current) < 0) {
|
||||
competitorMap.set(key, {
|
||||
key,
|
||||
driverId: row.driverId,
|
||||
driverName: row.driverName,
|
||||
tier,
|
||||
comparableMs,
|
||||
resultDisplay: seedMetric ? formatSeedMetric(seedMetric) : `${row.laps}/${formatRaceClock(row.totalElapsedMs)}`,
|
||||
sourceSessionName: session.name,
|
||||
@@ -637,7 +643,7 @@ export function buildPracticeStandings(event, { getSessionsForEvent, buildLeader
|
||||
});
|
||||
});
|
||||
|
||||
return [...competitorMap.values()].sort((a, b) => a.comparableMs - b.comparableMs).map((row, index) => ({
|
||||
return [...competitorMap.values()].sort(better).map((row, index) => ({
|
||||
...row,
|
||||
rank: index + 1,
|
||||
score: row.resultDisplay,
|
||||
|
||||
@@ -14,6 +14,7 @@ function createHarness(options = {}) {
|
||||
status: "running",
|
||||
startMode: options.startMode || "mass",
|
||||
startedAt: 1_000,
|
||||
...(options.session || {}),
|
||||
};
|
||||
const state = {
|
||||
events: [{
|
||||
@@ -46,7 +47,7 @@ function createHarness(options = {}) {
|
||||
findEventTeamForPassing: (event, driverId) => event.teams.find((team) => team.driverIds.includes(driverId)) || null,
|
||||
persistPassingToBackend: () => {},
|
||||
pushOverlayEvent: (type, label) => overlayEvents.push({ type, label }),
|
||||
buildLeaderboard: () => [],
|
||||
buildLeaderboard: options.buildLeaderboard ? () => options.buildLeaderboard(state, session) : () => [],
|
||||
formatLap: (ms) => `${ms}ms`,
|
||||
announcePassing: () => {},
|
||||
triggerRaceAudio: (key, opts) => { audioEvents.push(key); audioCalls.push({ key, variables: opts?.variables || {} }); },
|
||||
@@ -71,6 +72,29 @@ test("five controlled practice laps trigger one stable-pace voice cue", () => {
|
||||
assert.equal(call.variables.avgLap, "20 jämnt");
|
||||
});
|
||||
|
||||
test("practice in a race ranked on N laps: a better seeding time is called, the first one is not", () => {
|
||||
// Seeding time = sum of the last 3 laps (enough for the test), from the stored laps.
|
||||
const buildLeaderboard = (state, session) => Object.entries(state.resultsBySession[session.id]?.competitors || {}).map(([key, entry]) => {
|
||||
const laps = (state.resultsBySession[session.id].passings || []).filter((p) => p.competitorKey === key || p.driverId === entry.driverId).map((p) => p.lapMs).filter((ms) => ms > 500);
|
||||
const window = laps.slice(-3);
|
||||
return { key, driverId: entry.driverId, seedMetric: window.length === 3 ? { method: "consecutive", lapCount: 3, totalMs: window.reduce((a, b) => a + b, 0), comparableMs: window.reduce((a, b) => a + b, 0) } : null };
|
||||
});
|
||||
const harness = createHarness({ sessionType: "practice", session: { seedBestLapCount: 3, seedMethod: "consecutive" }, buildLeaderboard });
|
||||
let ts = 1_000;
|
||||
harness.passing(ts, "main");
|
||||
for (const lapMs of [20_000, 20_000, 20_000, 19_000]) { ts += lapMs; harness.passing(ts, "main"); }
|
||||
const calls = harness.audioCalls.filter((item) => item.key === "seed_improved");
|
||||
assert.equal(calls.length, 1, "first full seeding time silent, the improvement called");
|
||||
assert.equal(calls[0].variables.gain, "1,00");
|
||||
});
|
||||
|
||||
test("open practice never gets the seeding call", () => {
|
||||
const harness = createHarness({ sessionType: "open_practice", session: { seedBestLapCount: 3 } });
|
||||
let ts = 1_000;
|
||||
for (let lap = 0; lap < 6; lap += 1) { harness.passing(ts, "main"); ts += 20_000 - lap * 500; }
|
||||
assert.equal(harness.audioEvents.includes("seed_improved"), false);
|
||||
});
|
||||
|
||||
test("stable-pace training cue is never emitted during a race", () => {
|
||||
const harness = createHarness({ sessionType: "team_race" });
|
||||
for (let lap = 1; lap <= 5; lap += 1) harness.passing(1_000 + lap * 20_000, "main");
|
||||
|
||||
@@ -56,3 +56,29 @@ test("qualifying seed notice: preliminary until practice is run, then a reminder
|
||||
assert.equal(getQualifyingSeedNotice(ev, [ran, { ...q, status: "finished", startedAt: 5 }]), null, "qualifying started");
|
||||
assert.equal(getQualifyingSeedNotice(ev, [q]), null, "no practice");
|
||||
});
|
||||
|
||||
test("practice seeding: format values go onto the practice heats, also ones already run", async () => {
|
||||
const { applyFormatToPendingSessions } = await import("../src/event_race_logic.js");
|
||||
const ev = event(4, 10, { practiceSeedLapCount: 3, practiceSeedMethod: "consecutive" });
|
||||
const [heat] = buildPracticeHeats(ev, 1, { t, buildRaceSession: (eventId, name, type, durationMin, o = {}) => ({ id: "x", eventId, name, type, status: "ready", driverIds: o.driverIds, seedBestLapCount: o.seedBestLapCount, seedMethod: o.seedMethod }) });
|
||||
assert.equal(heat.seedBestLapCount, 3);
|
||||
assert.equal(heat.seedMethod, "consecutive");
|
||||
const ran = { type: "practice", status: "finished", startedAt: 1, seedBestLapCount: 0, seedMethod: "best_sum" };
|
||||
applyFormatToPendingSessions([ran], { practiceSeedLapCount: 0, practiceSeedMethod: "best_sum" }, { practiceSeedLapCount: 3, practiceSeedMethod: "consecutive" });
|
||||
assert.equal(ran.seedBestLapCount, 3);
|
||||
assert.equal(ran.seedMethod, "consecutive");
|
||||
});
|
||||
|
||||
test("practice seeding: a driver without N laps ranks after everyone with a seeding time", async () => {
|
||||
const { buildPracticeStandings } = await import("../src/timing_logic.js");
|
||||
const session = { id: "p", type: "practice", seedBestLapCount: 3 };
|
||||
const rows = [{ driverId: "a", driverName: "A", bestLapMs: 17000, laps: 2 }, { driverId: "b", driverName: "B", bestLapMs: 18000, laps: 5 }];
|
||||
const standings = buildPracticeStandings({ id: "e1" }, {
|
||||
getSessionsForEvent: () => [session],
|
||||
buildLeaderboard: () => rows,
|
||||
getCompetitorSeedMetric: (_s, row) => (row.driverId === "b" ? { comparableMs: 54500, totalMs: 54500 } : null),
|
||||
formatSeedMetric: () => "3/54.500",
|
||||
formatRaceClock: () => "",
|
||||
});
|
||||
assert.deepEqual(standings.map((row) => row.driverId), ["b", "a"]);
|
||||
});
|
||||
Reference in new issue
Block a user