diff --git a/CHANGELOG.md b/CHANGELOG.md index f51daa9..de268ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.89.34 + +- **Whole race days as presets, federation style:** new race format presets **EFRA 1/10 Off-road**, **EFRA 1/10 Touring / On-road**, **EFRA/SBF 1/8 Nitro** (bump-up, long final), **ROAR** (timed qualifying, bump-up, single A main), **Quick club day**, **Rookie / Junior** and **Points race without finals**; **IFMAR** now also brings 2 practices. A preset sets the practice rounds (seeding on the best 3 laps in a row), qualifying, finals, bump-up and lap limits in one pick, and its description is shown under the choice in the new-race wizard and in Manage race. Values follow the handbooks in spirit and stay editable. + ## 1.89.33 - **Driver picker grouped by class:** picking the drivers of a race (new-race wizard, Manage race and series rounds) groups them by class with **All** / **None** per class, a search box (name or transponder), **Show only selected** and **Same drivers as…** to copy an earlier race's field (the series' rounds first). **Select all** now takes only the race's own class or what the search shows - before, it ticked the whole club, so a Rookie race meant unticking everyone one by one. diff --git a/README.md b/README.md index dcd006f..d1d7b25 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ After creation the race is managed in four tabs (Race Setup → Manage): - qualifying points table (placement, by field size, 10-9-8...) and tie-break; - finals: legs, counted legs, bump-ups and reserved bump slots; - count-down length, follow-up time and the min/max lap time; - - presets: short technical track, club race, IFMAR style, endurance, or your own saved club presets; + - 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; - reseed upcoming heats; locked manual grids are respected; diff --git a/README.sv.md b/README.sv.md index 296d281..5ea76a2 100644 --- a/README.sv.md +++ b/README.sv.md @@ -184,7 +184,7 @@ Efter det hanteras racet i fyra flikar (Race Setup → Hantera): - poängtabell för kval (placering, efter fältstorlek, 10-9-8...) och tie-break; - finaler: antal finalheat, räknade finalheat, bump-up och reserverade bump-platser; - nedräkningens längd, follow-up-tid och min/max-varvtid; - - förval: kort teknisk bana, klubbrace, IFMAR-stil, endurance, eller egna sparade klubbförval; + - 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; - omseeda kommande heat; låsta manuella grid respekteras; diff --git a/docs/javascript-architecture.md b/docs/javascript-architecture.md index 2d57b0d..961993a 100644 --- a/docs/javascript-architecture.md +++ b/docs/javascript-architecture.md @@ -2983,3 +2983,5 @@ Tests: decoder_diagnostics.test.js covers bounds, isolation, snapshots and outco `lap_chart_logic.js` (pure) turns a heat's passings into a lap chart: `buildLapChart(entries)` gives each driver's place after every lap (order of crossing for that lap, among those who did it), `renderLapChartSvg()` draws it as a self-styled inline SVG (`currentColor` for axes, so it works in every theme and in print). `buildRaceOverview()` adds `heat.lapChart` for qualifying and finals when given `getCompetitorPassings`; the race overview panel shows it in a `
`, `renderRaceOverviewHeatsHtml()` prints it (single heat, or finals in the full results), and `buildHeatPdfSection()` sends it as `section.chart`, which `server.js` `normalizePdfLapChart()` checks and `server/pdf_render.js` `drawLapChart()` draws as vector lines. `participant_picker.js` is the one driver picker for the new-race wizard (step 2), Manage race → Participants and a series round: `groupParticipantChoices()` groups drivers by class (the race's own class first, then classes with someone ticked), `renderParticipantPicker()` draws search, Only selected, Select all / Clear, per-class All / None and an optional "Same drivers as…" select (`participantCopySources()`: earlier races, the series' rounds first, no open practice); `bindParticipantPicker()` works in the DOM and calls the caller's `onChange(ids)` (search text, Only selected and folded classes are remembered per picker across re-renders). "Select all" never takes the folded classes, only the race's own class or the current search. + +Race format presets (`getRaceFormatPresets()` in `event_race_logic.js`) may carry a `hint` (shown under the select in the wizard and in Manage race) and `wizard.practiceSessions`, which `applyRaceWizardPresetDefaults()` uses for the wizard's practice count. The federation-style presets (`efra_offroad`, `efra_touring`, `efra_nitro`, `roar`, `club_quick`, `rookie_junior`, `points_only`) spread `FEDERATION_BASE` and override what differs; `tests/race_presets.test.js` checks every built-in preset against the values the race settings accept. diff --git a/package-lock.json b/package-lock.json index fff5031..e0eb65b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.89.33", + "version": "1.89.34", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.89.33", + "version": "1.89.34", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index 7dc0250..489920e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.89.33", + "version": "1.89.34", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/app.js b/src/app.js index 5851d42..96e23ad 100644 --- a/src/app.js +++ b/src/app.js @@ -2549,6 +2549,21 @@ const TRANSLATIONS = { "events.heat_order_fastest_last": "Snabbaste heatet sist", "events.heat_order_fastest_first": "Snabbaste heatet först", "events.preset_ifmar": "IFMAR-stil kval/final", + "events.preset_ifmar_hint": "IFMAR VM-stil: 2 kontrollerade träningar (seeding), 5 kval à 5 min där 3 räknas på IFMAR-poäng, 10 per final, 3 finaler där 2 räknas.", + "events.preset_efra_offroad": "EFRA 1/10 Off-road (5 kval, 3 finaler)", + "events.preset_efra_offroad_hint": "EFRA-stil: 2 kontrollerade träningar med seeding på bästa 3 varv i följd, 5 kval à 5 min med individuell start där 3 räknas, 10 per final, 3 finaler à 5 min där 2 räknas. Långsammaste heatet först.", + "events.preset_efra_touring": "EFRA 1/10 Touring / On-road (5 kval, 3 finaler)", + "events.preset_efra_touring_hint": "EFRA-stil för asfalt: 2 träningar med seeding, 5 kval à 5 min med flygande start där 3 räknas, 10 per final, 3 finaler där 2 räknas. Varvgränser för korta on-road-varv.", + "events.preset_efra_nitro": "EFRA/SBF 1/8 Nitro (bump-up, lång final)", + "events.preset_efra_nitro_hint": "EFRA-stil 1/8: 2 träningar, 5 kval där 3 räknas, 12 per final, de 4 bästa i varje final går upp till nästa (bump-up). Finalerna är 30 min - gör A-finalen längre (45/60 min) i Hantera om ni vill.", + "events.preset_roar": "ROAR-stil (tidskval, bump-up, en A-final)", + "events.preset_roar_hint": "ROAR-stil: 1 träning, 4 kval där bästa omgången (varv/tid) avgör, 10 per final, de 2 bästa går upp till nästa final, en final à 5 min.", + "events.preset_club_quick": "Klubbdag snabb (3 kval, 1 final)", + "events.preset_club_quick_hint": "För en kvällsträff: 1 träning, 3 kval där 2 räknas, 8 per heat, en final à 5 min per grupp.", + "events.preset_rookie_junior": "Rookie / Junior (6 per heat, 2 finaler)", + "events.preset_rookie_junior_hint": "Lugnare för nya förare: 2 träningar, 3 kval där 2 räknas, max 6 bilar per heat och final, 2 finaler där bästa räknas, mjuka varvgränser.", + "events.preset_points_only": "Poängrace utan finaler", + "events.preset_points_only_hint": "Bara kval: 1 träning, 4 kval där 3 räknas. Skapa inga finaler - kvalställningen är slutresultatet. Bra när tiden är knapp.", "events.preset_endurance": "Endurance / lagrace", "events.tie_break_note": "Tie-break", "events.counted_rounds_label": "Räknade rundor", @@ -4912,6 +4927,21 @@ const TRANSLATIONS = { "events.heat_order_fastest_last": "Fastest heat last", "events.heat_order_fastest_first": "Fastest heat first", "events.preset_ifmar": "IFMAR-style qual/finals", + "events.preset_ifmar_hint": "IFMAR worlds style: 2 controlled practices (seeding), 5 qualifiers of 5 min with 3 counting on IFMAR points, 10 per final, 3 finals with 2 counting.", + "events.preset_efra_offroad": "EFRA 1/10 Off-road (5 quals, 3 finals)", + "events.preset_efra_offroad_hint": "EFRA style: 2 controlled practices seeded on the best 3 laps in a row, 5 qualifiers of 5 min with individual start and 3 counting, 10 per final, 3 finals of 5 min with 2 counting. Slowest heat first.", + "events.preset_efra_touring": "EFRA 1/10 Touring / On-road (5 quals, 3 finals)", + "events.preset_efra_touring_hint": "EFRA style for tarmac: 2 practices with seeding, 5 qualifiers of 5 min with flying start and 3 counting, 10 per final, 3 finals with 2 counting. Lap limits for short on-road laps.", + "events.preset_efra_nitro": "EFRA/SBF 1/8 Nitro (bump-up, long final)", + "events.preset_efra_nitro_hint": "EFRA style 1/8: 2 practices, 5 qualifiers with 3 counting, 12 per final, the top 4 of each final move up to the next (bump-up). Finals are 30 min - make the A final longer (45/60 min) in Manage if you like.", + "events.preset_roar": "ROAR style (timed qualifying, bump-up, single A main)", + "events.preset_roar_hint": "ROAR style: 1 practice, 4 qualifiers where the best round (laps/time) decides, 10 per final, the top 2 move up to the next final, one 5 min final.", + "events.preset_club_quick": "Quick club day (3 quals, 1 final)", + "events.preset_club_quick_hint": "For an evening: 1 practice, 3 qualifiers with 2 counting, 8 per heat, one 5 min final per group.", + "events.preset_rookie_junior": "Rookie / Junior (6 per heat, 2 finals)", + "events.preset_rookie_junior_hint": "Calmer for new drivers: 2 practices, 3 qualifiers with 2 counting, max 6 cars per heat and final, 2 finals with the best counting, soft lap limits.", + "events.preset_points_only": "Points race without finals", + "events.preset_points_only_hint": "Qualifying only: 1 practice, 4 qualifiers with 3 counting. Don't make finals - the qualifying standings are the result. Good when time is short.", "events.preset_endurance": "Endurance / team race", "events.tie_break_note": "Tie-break", "events.counted_rounds_label": "Counted rounds", diff --git a/src/event_manager_view.js b/src/event_manager_view.js index f6d33a3..266cb8b 100644 --- a/src/event_manager_view.js +++ b/src/event_manager_view.js @@ -255,7 +255,7 @@ export function renderEventManagerMarkup(context) { (preset) => `` ) .join("")} - ` + ${selectedPreset?.hint ? `${escapeHtml(selectedPreset.hint)}` : ""}` )} ${raceFormatAdvanced ? ` diff --git a/src/event_race_logic.js b/src/event_race_logic.js index 36bf109..da35ce4 100644 --- a/src/event_race_logic.js +++ b/src/event_race_logic.js @@ -21,6 +21,22 @@ export function normalizeStoredRacePreset(preset, { uid }) { +// Shared by the federation-style presets: points per round (low wins), seeding from practice +// on the best 3 laps in a row, grid start in the finals, fastest heat last, no bump-up. +const FEDERATION_BASE = { + qualifyingScoring: "points", + qualDurationMin: 5, + qualSeedLapCount: 3, + qualSeedMethod: "consecutive", + qualifyingPointsTable: "rank_low", + qualifyingTieBreak: "rounds", + finalDurationMin: 5, + finalStartMode: "position", + bumpCount: 0, + reserveBumpSlots: false, + heatOrder: "fastest_last", +}; + export function getRaceFormatPresets({ state, t, uid, normalizeStoredRacePreset }) { const builtins = [ { @@ -81,6 +97,8 @@ export function getRaceFormatPresets({ state, t, uid, normalizeStoredRacePreset { id: "ifmar", label: t("events.preset_ifmar"), + hint: t("events.preset_ifmar_hint"), + wizard: { practiceSessions: 2 }, values: { qualifyingScoring: "points", qualifyingRounds: 5, @@ -131,6 +149,58 @@ export function getRaceFormatPresets({ state, t, uid, normalizeStoredRacePreset heatOrder: "fastest_last", }, }, + // Federation-style days (2026-11): the values follow the EFRA / ROAR handbooks in spirit - + // they change between editions, so everything stays editable after picking one. `wizard` + // sets the new-race wizard's practice count; `hint` is shown under the choice. + { + id: "efra_offroad", + label: t("events.preset_efra_offroad"), + hint: t("events.preset_efra_offroad_hint"), + wizard: { practiceSessions: 2 }, + values: { ...FEDERATION_BASE, qualifyingRounds: 5, carsPerHeat: 10, qualStartMode: "staggered", countedQualRounds: 3, carsPerFinal: 10, finalLegs: 3, countedFinalLegs: 2, followUpSec: 40, minLapMs: 15000, maxLapMs: 90000 }, + }, + { + id: "efra_touring", + label: t("events.preset_efra_touring"), + hint: t("events.preset_efra_touring_hint"), + wizard: { practiceSessions: 2 }, + values: { ...FEDERATION_BASE, qualifyingRounds: 5, carsPerHeat: 10, qualStartMode: "flying", countedQualRounds: 3, carsPerFinal: 10, finalLegs: 3, countedFinalLegs: 2, followUpSec: 30, minLapMs: 6000, maxLapMs: 40000 }, + }, + { + id: "efra_nitro", + label: t("events.preset_efra_nitro"), + hint: t("events.preset_efra_nitro_hint"), + wizard: { practiceSessions: 2 }, + values: { ...FEDERATION_BASE, qualifyingRounds: 5, carsPerHeat: 12, qualStartMode: "staggered", countedQualRounds: 3, carsPerFinal: 12, finalLegs: 1, countedFinalLegs: 1, finalDurationMin: 30, followUpSec: 60, minLapMs: 15000, maxLapMs: 120000, bumpCount: 4, reserveBumpSlots: true }, + }, + { + id: "roar", + label: t("events.preset_roar"), + hint: t("events.preset_roar_hint"), + wizard: { practiceSessions: 1 }, + values: { ...FEDERATION_BASE, qualifyingScoring: "best", qualifyingRounds: 4, carsPerHeat: 10, qualStartMode: "staggered", qualSeedMethod: "best_sum", countedQualRounds: 1, qualifyingTieBreak: "best_round", carsPerFinal: 10, finalLegs: 1, countedFinalLegs: 1, followUpSec: 15, minLapMs: 10000, maxLapMs: 90000, bumpCount: 2, reserveBumpSlots: true }, + }, + { + id: "club_quick", + label: t("events.preset_club_quick"), + hint: t("events.preset_club_quick_hint"), + wizard: { practiceSessions: 1 }, + values: { ...FEDERATION_BASE, qualifyingRounds: 3, carsPerHeat: 8, qualStartMode: "flying", qualSeedMethod: "best_sum", countedQualRounds: 2, carsPerFinal: 8, finalLegs: 1, countedFinalLegs: 1, followUpSec: 15, minLapMs: 10000, maxLapMs: 60000 }, + }, + { + id: "rookie_junior", + label: t("events.preset_rookie_junior"), + hint: t("events.preset_rookie_junior_hint"), + wizard: { practiceSessions: 2 }, + values: { ...FEDERATION_BASE, qualifyingRounds: 3, carsPerHeat: 6, qualStartMode: "flying", qualSeedMethod: "best_sum", countedQualRounds: 2, carsPerFinal: 6, finalLegs: 2, countedFinalLegs: 1, followUpSec: 20, minLapMs: 8000, maxLapMs: 120000 }, + }, + { + id: "points_only", + label: t("events.preset_points_only"), + hint: t("events.preset_points_only_hint"), + wizard: { practiceSessions: 1 }, + values: { ...FEDERATION_BASE, qualifyingRounds: 4, carsPerHeat: 8, qualStartMode: "flying", qualSeedMethod: "best_sum", countedQualRounds: 3, carsPerFinal: 8, finalLegs: 1, countedFinalLegs: 1, followUpSec: 15, minLapMs: 10000, maxLapMs: 60000 }, + }, { id: "endurance", label: t("events.preset_endurance"), @@ -422,8 +492,10 @@ export function applyRaceWizardPresetDefaults(draft, presetId, { getRaceWizardPr const preset = getRaceWizardPreset(presetId); const endurance = preset.id === "endurance"; draft.presetId = preset.id; - draft.createPractice = !endurance; - draft.practiceSessions = endurance ? 0 : Math.max(1, Number(draft.practiceSessions || 1)); + // A preset may say how many practice rounds its day has (federation style: 2 with seeding). + const presetPractice = Number.isFinite(Number(preset.wizard?.practiceSessions)) ? Math.max(0, Number(preset.wizard.practiceSessions)) : null; + draft.createPractice = !endurance && presetPractice !== 0; + draft.practiceSessions = endurance ? 0 : presetPractice ?? Math.max(1, Number(draft.practiceSessions || 1)); draft.createQualifying = !endurance; draft.qualifyingRounds = Math.max(1, Number(preset.values?.qualifyingRounds || draft.qualifyingRounds || 3)); draft.createTeamRace = endurance; diff --git a/src/event_workspace_controller.js b/src/event_workspace_controller.js index 9a39b24..89fb97d 100644 --- a/src/event_workspace_controller.js +++ b/src/event_workspace_controller.js @@ -238,6 +238,12 @@ export function renderEventWorkspaceView(context) { toggleWizardPlanField("createQualifying", "qualifyingRounds"); toggleWizardPlanField("createTeamRace", "teamRaceDurationMin"); + // The chosen preset's description (what the day looks like) follows the select. + document.querySelector('#raceWizardStepForm [name="presetId"]')?.addEventListener("change", (event) => { + const hint = document.getElementById("raceWizardPresetHint"); + if (hint) hint.textContent = event.target.selectedOptions[0]?.dataset.hint || ""; + }); + bindParticipantPicker(document.querySelector(".participant-picker")?.parentElement, { onChange: (ids) => { getRaceWizardDraft().driverIds = ids; }, getCopyIds: (sourceId) => { diff --git a/src/race_setup_ui.js b/src/race_setup_ui.js index 9873124..4ccc03a 100644 --- a/src/race_setup_ui.js +++ b/src/race_setup_ui.js @@ -112,9 +112,10 @@ export function renderRaceWizardContent(draft, classOptions, wizardDrivers, pres +

${escapeHtml(getRaceFormatPresets().find((item) => item.id === draft.presetId)?.hint || "")}

`; } if (raceWizardStep === 2) { diff --git a/tests/race_presets.test.js b/tests/race_presets.test.js new file mode 100644 index 0000000..441b002 --- /dev/null +++ b/tests/race_presets.test.js @@ -0,0 +1,38 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { getRaceFormatPresets, applyRaceWizardPresetDefaults, HEAT_ORDERS } from "../src/event_race_logic.js"; + +const presets = getRaceFormatPresets({ state: { settings: {} }, t: (key) => key, uid: () => "x", normalizeStoredRacePreset: (p) => p }); +const get = (id) => presets.find((preset) => preset.id === id); + +test("the federation-style presets are offered with a description", () => { + for (const id of ["efra_offroad", "efra_touring", "efra_nitro", "ifmar", "roar", "club_quick", "rookie_junior", "points_only"]) { + assert.ok(get(id), id); + assert.equal(get(id).hint, `events.preset_${id}_hint`); + } +}); + +test("every built-in preset has values the race settings accept", () => { + for (const preset of presets.filter((item) => item.id !== "custom")) { + const v = preset.values; + assert.ok(["points", "best"].includes(v.qualifyingScoring), preset.id); + assert.ok(["rank_low", "field_desc", "ifmar"].includes(v.qualifyingPointsTable), preset.id); + assert.ok(["rounds", "best_lap", "best_round"].includes(v.qualifyingTieBreak), preset.id); + assert.ok(["best_sum", "average", "consecutive"].includes(v.qualSeedMethod), preset.id); + assert.ok(!v.heatOrder || HEAT_ORDERS.includes(v.heatOrder), preset.id); + assert.ok(v.countedQualRounds <= v.qualifyingRounds, `${preset.id} counted rounds`); + assert.ok(v.countedFinalLegs <= v.finalLegs, `${preset.id} counted legs`); + assert.ok(v.bumpCount < v.carsPerFinal, `${preset.id} bump-up`); + assert.ok(v.minLapMs < v.maxLapMs, `${preset.id} lap limits`); + } +}); + +test("a preset sets the wizard's practice rounds; others keep the draft's", () => { + const getRaceWizardPreset = (id) => get(id); + assert.equal(applyRaceWizardPresetDefaults({ practiceSessions: 1 }, "efra_offroad", { getRaceWizardPreset }).practiceSessions, 2); + const draft = applyRaceWizardPresetDefaults({ practiceSessions: 3 }, "club_qualifying", { getRaceWizardPreset }); + assert.equal(draft.practiceSessions, 3); + assert.equal(draft.createPractice, true); + assert.equal(applyRaceWizardPresetDefaults({}, "efra_nitro", { getRaceWizardPreset }).qualifyingRounds, 5); + assert.equal(applyRaceWizardPresetDefaults({}, "endurance", { getRaceWizardPreset }).createPractice, false); +}); diff --git a/tests/run.js b/tests/run.js index df5fe00..1031c69 100644 --- a/tests/run.js +++ b/tests/run.js @@ -11,6 +11,7 @@ import "./team_race_logic.test.js"; import "./race_overview.test.js"; import "./lap_chart.test.js"; import "./participant_picker.test.js"; +import "./race_presets.test.js"; import "./leader_call_logic.test.js"; import "./decoder_sim.test.js"; import "./sponsor_event.test.js";