feat(race): practice split into heats by cars per heat; format change rebuilds heats not run yet (1.89.46)
This commit is contained in:
1 parent
ce86f771c3
commit
74a2e9ba47
11 files changed
+159
-17
No files matched your search
@@ -89,6 +89,7 @@ export function renderEventManagerView(context) {
|
||||
applyRaceFormatPreset,
|
||||
normalizeStoredRacePreset,
|
||||
generateQualifyingForRace,
|
||||
rebuildPracticeHeats,
|
||||
clearGeneratedQualifying,
|
||||
reseedUpcomingQualifying,
|
||||
generateFinalsForRace,
|
||||
@@ -673,8 +674,26 @@ export function renderEventManagerView(context) {
|
||||
},
|
||||
}));
|
||||
applyFormatToPendingSessions(state.sessions.filter((session) => session.eventId === event.id), before, config);
|
||||
// Cars per heat or the number of rounds changed: build the qualifying heats again, as
|
||||
// long as none of them has run (that would delete laps). updateEvent replaced the event,
|
||||
// so the new config is read from state.
|
||||
let notice = "";
|
||||
// Practice heats follow cars per heat too (the race's own practice only, never one that ran).
|
||||
if (Number(before.carsPerHeat) !== Number(config.carsPerHeat)) {
|
||||
const updated = state.events.find((item) => item.id === event.id);
|
||||
if (updated && rebuildPracticeHeats(updated) < 0) notice = t("events.format_practice_not_rebuilt");
|
||||
}
|
||||
const heatsChanged = ["carsPerHeat", "qualifyingRounds"].some((key) => Number(before[key]) !== Number(config[key]));
|
||||
if (heatsChanged && getSessionsForEvent(event.id).some((s) => s.type === "qualification" && s.generated)) {
|
||||
const run = runHeatNames("qualification");
|
||||
const updated = state.events.find((item) => item.id === event.id);
|
||||
// A rebuild shows in the heat list at once; only a refusal needs saying.
|
||||
if (run) notice = [notice, t("events.format_heats_not_rebuilt", { names: run })].filter(Boolean).join("\n");
|
||||
else if (updated) generateQualifyingForRace(updated);
|
||||
}
|
||||
saveState();
|
||||
refreshManager();
|
||||
if (notice) alert(notice);
|
||||
});
|
||||
|
||||
document.getElementById("scheduleForm")?.addEventListener("submit", (e) => {
|
||||
|
||||
Reference in new issue
Block a user