feat(audio): practice hype calls and leader calls in qualifying and finals (1.61.0)
This commit is contained in:
1 parent
f602778895
commit
94ec278f53
13 files changed
+334
-9
No files matched your search
+19
-2
@@ -1,3 +1,5 @@
|
||||
import { PRACTICE_HYPE_EVENTS } from "./practice_hype_logic.js";
|
||||
|
||||
export const RACE_AUDIO_PRIORITIES = Object.freeze({ pass: 0, low: 10, normal: 20, high: 30, critical: 40 });
|
||||
export const START_LIGHT_STATES = Object.freeze(["IDLE", "GRID", "READY", "LIGHT_1", "LIGHT_2", "LIGHT_3", "LIGHT_4", "LIGHT_5", "WAIT_RANDOM", "GO"]);
|
||||
|
||||
@@ -21,6 +23,8 @@ export const RACE_AUDIO_EVENT_DEFINITIONS = Object.freeze([
|
||||
event("track_record", "race", "normal", true, "effects/track_record_fanfare.wav", 2000),
|
||||
event("training_stable_pace", "training", "low", true, "", 120000),
|
||||
event("new_leader", "race", "normal", true, "", 1000),
|
||||
event("leader_update", "race", "normal"),
|
||||
...PRACTICE_HYPE_EVENTS.map((key) => event(key, "training", "low")),
|
||||
event("position_gain", "race", "low", false, "effects/position_gain.wav", 750),
|
||||
event("position_loss", "race", "low", false, "effects/position_loss.wav", 750),
|
||||
event("final_lap", "race", "high", true, "effects/final_lap.wav"),
|
||||
@@ -93,6 +97,11 @@ export function normalizeRaceAudioSettings(value = {}) {
|
||||
startSound: Object.hasOwn(START_SOUNDS, source.startSound) ? source.startSound : "tone",
|
||||
finishSound: Object.hasOwn(FINISH_SOUNDS, source.finishSound) ? source.finishSound : "stop",
|
||||
raceCallouts: source.raceCallouts === "full" ? "full" : "passing",
|
||||
// Practice hype calls (practice_hype_logic.js); never in qualifying or finals.
|
||||
practiceHype: source.practiceHype !== false,
|
||||
// Qualifying and finals: "both" = when the leader changes and every 2 minutes,
|
||||
// "change" = only when the leader changes, "off" = never (unless raceCallouts is "full").
|
||||
raceLeaderCalls: ["off", "change", "both"].includes(source.raceLeaderCalls) ? source.raceLeaderCalls : "both",
|
||||
// Open Practice personal best calls (practice_callouts_logic.js); 0 turns a rule off.
|
||||
practicePbWarmupLaps: Math.round(clamp(source.practicePbWarmupLaps, 10, 0, 30)),
|
||||
practicePbCooldownSec: Math.round(clamp(source.practicePbCooldownSec, 60, 0, 600)),
|
||||
@@ -109,9 +118,17 @@ export function normalizeRaceAudioSettings(value = {}) {
|
||||
export const RACE_PASSING_CALLOUT_EVENTS = Object.freeze(["personal_best", "fastest_lap", "track_record", "new_leader", "position_gain", "position_loss", "provisional_pole"]);
|
||||
const PRACTICE_TYPES = new Set(["open_practice", "free_practice", "practice"]);
|
||||
|
||||
const PRACTICE_HYPE_SET = new Set(PRACTICE_HYPE_EVENTS);
|
||||
export const LEADER_UPDATE_INTERVAL_MS = 120000;
|
||||
|
||||
export function isSilencedDuringRace(eventKey, settings, session) {
|
||||
if (!session || PRACTICE_TYPES.has(String(session.type || ""))) return false;
|
||||
if (normalizeRaceAudioSettings(settings).raceCallouts === "full") return false;
|
||||
const audio = normalizeRaceAudioSettings(settings);
|
||||
const practice = Boolean(session) && PRACTICE_TYPES.has(String(session.type || ""));
|
||||
if (PRACTICE_HYPE_SET.has(eventKey)) return !practice || !audio.practiceHype;
|
||||
if (!session || practice) return false;
|
||||
if (eventKey === "leader_update") return audio.raceLeaderCalls !== "both";
|
||||
if (eventKey === "new_leader" && audio.raceLeaderCalls !== "off") return false;
|
||||
if (audio.raceCallouts === "full") return false;
|
||||
return RACE_PASSING_CALLOUT_EVENTS.includes(eventKey);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user