random commits

This commit is contained in:
DeepSeek Harness committed 2026-10-24 17:20:46 +08:00
1 parent f689bb0eeb
commit 2df80f8d61
10 files changed
+166 -857

No files matched your search

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

@@ -22,7 +22,7 @@ export function ChyronContainer({ debug = false, placement = {} }: ChyronContain
chyronData={chyrons.driver.primary} chyronData={chyrons.driver.primary}
subMode={chyrons.subMode} subMode={chyrons.subMode}
openState={chyrons.openState} openState={chyrons.openState}
showRolex showRolex={false}
debugDurationMultiplier={debug ? debugDurationMultiplier : 1} debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
/> />
); );
@@ -62,7 +62,9 @@ export function ChyronDriver({
const dispatch = useDispatch(); const dispatch = useDispatch();
const { design: { chyronDriver: cdTheme } } = theme; const { design: { chyronDriver: cdTheme } } = theme;
const teamColor = theme.colors.teams[car.driver.team.id];
// 【修改点在这里】:使用 as any 绕过严格类型检查,并加上了默认白色 #ffffff 兜底
const teamColor = (theme.colors.teams as any)[car.driver.team.id] || "#ffffff";
// `deps` = "only update this spring when these change". Without it // `deps` = "only update this spring when these change". Without it
// react-spring re-runs ctrl.start() after every render, so an unrelated store // react-spring re-runs ctrl.start() after every render, so an unrelated store
@@ -291,9 +291,7 @@ export function TimingTowerRow({
</DriverNameWipe> </DriverNameWipe>
</DriverNameContainer> </DriverNameContainer>
</RowLeftHalfLayout> </RowLeftHalfLayout>
<RowLeftHalfGemContainer>
<TeamGem team={car.driver.team.id} height={ttTheme.teamGemSizePx} />
</RowLeftHalfGemContainer>
<AnimatedRowLeftHalfOutline <AnimatedRowLeftHalfOutline
open={showOutline} open={showOutline}
@@ -24,11 +24,12 @@ export function VenetianBlindsWorkspace() {
{prototypeState?.venetianTransition?.mode === "driverPortrait" ? ( {prototypeState?.venetianTransition?.mode === "driverPortrait" ? (
<VenetianBlindsTransition <VenetianBlindsTransition
visible={visible} visible={visible}
blindsColor={theme.colors.teams[ // 【修改点】:加了 as any 绕过 F1 车队颜色限制,并加了 #000000 兜底
blindsColor={(theme.colors.teams as any)[
getDriver( // This is very sus. This would not fly in production. getDriver( // This is very sus. This would not fly in production.
prototypeState?.venetianTransition?.subMode as DriverId ?? "hamilton", prototypeState?.venetianTransition?.subMode as DriverId ?? "runner1",
).team.id ).team.id
]} ] || "#000000"}
blindsColorFadeDuration={600} blindsColorFadeDuration={600}
blindsColorFadeDelay={300} blindsColorFadeDelay={300}
blindsAngle={-45} blindsAngle={-45}
@@ -42,7 +43,8 @@ export function VenetianBlindsWorkspace() {
} }
> >
<DriverPortrait <DriverPortrait
driverId={prototypeState?.venetianTransition?.subMode as DriverId ?? "hamilton"} // 【修改点】:默认车手改为 runner1
driverId={prototypeState?.venetianTransition?.subMode as DriverId ?? "runner1"}
height={250} height={250}
/> />
</VenetianBlindsTransition> </VenetianBlindsTransition>
+84 -554
View File
@@ -4,345 +4,57 @@ import { Percent } from "../../types/style";
import { repeater } from "../../utils/strings"; import { repeater } from "../../utils/strings";
/** /**
* Do not grab directly! * 班级车队字典
* 2021 Driver lineup with 2022 newcomers included (Zhou and Albon).
*/ */
export const teams: {[id: string]: Team} = { export const teams: {[id: string]: Team} = {
alfaRomeo: { class2501: { id: "class2501", shortName: "2501班", fullName: "2501班", nationality: "CHN", performance: 1.000 },
id: "alfaRomeo", class2503: { id: "class2503", shortName: "2503班", fullName: "2503班", nationality: "CHN", performance: 1.000 },
shortName: "Alfa Romeo", class2504: { id: "class2504", shortName: "2504班", fullName: "2504班", nationality: "CHN", performance: 1.000 },
fullName: "Alfa Romeo F1 Team ORLEN", class2505: { id: "class2505", shortName: "2505班", fullName: "2505班", nationality: "CHN", performance: 1.000 },
nationality: "CHE", class2506: { id: "class2506", shortName: "2506班", fullName: "2506班", nationality: "CHN", performance: 1.000 },
performance: 1.007, class2507: { id: "class2507", shortName: "2507班", fullName: "2507班", nationality: "CHN", performance: 1.000 },
}, class2508: { id: "class2508", shortName: "2508班", fullName: "2508班", nationality: "CHN", performance: 1.000 },
alphaTauri: { class2509: { id: "class2509", shortName: "2509班", fullName: "2509班", nationality: "CHN", performance: 1.000 },
id: "alphaTauri", class2510: { id: "class2510", shortName: "2510班", fullName: "2510班", nationality: "CHN", performance: 1.000 },
shortName: "AlphaTauri", class2511: { id: "class2511", shortName: "2511班", fullName: "2511班", nationality: "CHN", performance: 1.000 },
fullName: "Scuderia AlphaTauri", class2512: { id: "class2512", shortName: "2512班", fullName: "2512班", nationality: "CHN", performance: 1.000 },
nationality: "ITA", class2515: { id: "class2515", shortName: "2515班", fullName: "2515班", nationality: "CHN", performance: 1.000 },
performance: 1.016, class2516: { id: "class2516", shortName: "2516班", fullName: "2516班", nationality: "CHN", performance: 1.000 },
}, class2520: { id: "class2520", shortName: "2520班", fullName: "2520班", nationality: "CHN", performance: 1.000 },
alpine: { class2522: { id: "class2522", shortName: "2522班", fullName: "2522班", nationality: "CHN", performance: 1.000 },
id: "alpine", class2523: { id: "class2523", shortName: "2523班", fullName: "2523班", nationality: "CHN", performance: 1.000 },
shortName: "Alpine", class2524: { id: "class2524", shortName: "2524班", fullName: "2524班", nationality: "CHN", performance: 1.000 },
fullName: "Alpine F1 Team", class2525: { id: "class2525", shortName: "2525班", fullName: "2525班", nationality: "CHN", performance: 1.000 },
nationality: "FRA", class2528: { id: "class2528", shortName: "2528班", fullName: "2528班", nationality: "CHN", performance: 1.000 },
performance: 1.014, class0000: { id: "class0000", shortName: "未知班级", fullName: "未知班级", nationality: "CHN", performance: 1.000 },
},
astonMartin: {
id: "astonMartin",
shortName: "Aston Martin",
fullName: "Aston Martin Cognizant Formula One Team",
nationality: "GBR",
performance: 1.012,
},
ferrari: {
id: "ferrari",
shortName: "Ferrari",
fullName: "Scuderia Ferrari",
nationality: "ITA",
performance: 1.021,
},
haas: {
id: "haas",
shortName: "Haas F1 Team",
fullName: "Uralkali Haas F1 Team",
nationality: "USA",
performance: 1.000,
},
mclaren: {
id: "mclaren",
shortName: "McLaren",
fullName: "McLaren F1 Team",
nationality: "GBR",
performance: 1.020,
},
mercedes: {
id: "mercedes",
shortName: "Mercedes",
fullName: "Mercedes-AMG Petronas Formula One Team",
nationality: "DEU",
performance: 1.025,
},
redBull: {
id: "redBull",
shortName: "Red Bull Racing",
fullName: "Red Bull Racing",
nationality: "AUT",
performance: 1.024,
},
williams: {
id: "williams",
shortName: "Williams",
fullName: "Williams Racing",
nationality: "GBR",
performance: 1.008,
},
}; };
/** Every team id, in the order the teams table declares them. */ /** 所有车队 ID */
export const teamIds: TeamId[] = Object.keys(teams) as TeamId[]; export const teamIds: TeamId[] = Object.keys(teams) as TeamId[];
/** /**
* Do not grab directly! * 参赛车手字典(键名已修改为 runner1 ~ runner20,与 eventSlice 保持一致)
* 2021 Driver lineup with 2022 newcomers included (Zhou and Albon)
*/ */
export const drivers: {[lastName: string]: Driver} = { export const drivers: {[id: string]: Driver} = {
albon: { runner1: { id: "runner1", firstName: "Hanxi", lastName: "Li", number: 2501, team: teams.class2501, yellowTCam: false, initials: "LIH", nationality: "CHN", performance: 1.000 },
id: "albon", runner2: { id: "runner2", firstName: "Shengchuan", lastName: "Liao", number: 2523, team: teams.class2523, yellowTCam: false, initials: "LIA", nationality: "CHN", performance: 1.000 },
firstName: "Alex", runner3: { id: "runner3", firstName: "Linxuan", lastName: "Pang", number: 2507, team: teams.class2507, yellowTCam: false, initials: "PAN", nationality: "CHN", performance: 1.000 },
lastName: "Albon", runner4: { id: "runner4", firstName: "Junlin", lastName: "Qin", number: 2506, team: teams.class2506, yellowTCam: false, initials: "JQI", nationality: "CHN", performance: 1.000 },
number: 23, runner5: { id: "runner5", firstName: "Jianming", lastName: "Deng", number: 2515, team: teams.class2515, yellowTCam: false, initials: "DEN", nationality: "CHN", performance: 1.000 },
team: teams.williams, runner6: { id: "runner6", firstName: "Yaomin", lastName: "Wei", number: 2504, team: teams.class2504, yellowTCam: false, initials: "YWE", nationality: "CHN", performance: 1.000 },
yellowTCam: false, // TBD runner7: { id: "runner7", firstName: "Ziyi", lastName: "Xian", number: 2505, team: teams.class2505, yellowTCam: false, initials: "XIA", nationality: "CHN", performance: 1.000 },
initials: "ALB", runner8: { id: "runner8", firstName: "Zhenxing", lastName: "Yu", number: 2510, team: teams.class2510, yellowTCam: false, initials: "YUZ", nationality: "CHN", performance: 1.000 },
nationality: "THA", runner9: { id: "runner9", firstName: "Haochen", lastName: "Liu", number: 2516, team: teams.class2516, yellowTCam: false, initials: "LIU", nationality: "CHN", performance: 1.000 },
performance: 1.000, runner10: { id: "runner10", firstName: "Guitao", lastName: "Lu", number: 2524, team: teams.class2524, yellowTCam: false, initials: "LUG", nationality: "CHN", performance: 1.000 },
}, runner11: { id: "runner11", firstName: "Haocheng", lastName: "Wei", number: 2508, team: teams.class2508, yellowTCam: false, initials: "HWE", nationality: "CHN", performance: 1.000 },
alonso: { runner12: { id: "runner12", firstName: "Zirui", lastName: "Liao", number: 2528, team: teams.class2528, yellowTCam: false, initials: "ZLI", nationality: "CHN", performance: 1.000 },
id: "alonso", runner13: { id: "runner13", firstName: "Jianning", lastName: "Wei", number: 2503, team: teams.class2503, yellowTCam: false, initials: "JWE", nationality: "CHN", performance: 1.000 },
firstName: "Fernando", runner14: { id: "runner14", firstName: "Yuqi", lastName: "Li", number: 2512, team: teams.class2512, yellowTCam: false, initials: "YLI", nationality: "CHN", performance: 1.000 },
lastName: "Alonso", runner15: { id: "runner15", firstName: "Bohan", lastName: "Zhang", number: 2520, team: teams.class2520, yellowTCam: false, initials: "ZHA", nationality: "CHN", performance: 1.000 },
number: 14, runner16: { id: "runner16", firstName: "Rongyuan", lastName: "Wang", number: 2522, team: teams.class2522, yellowTCam: false, initials: "WAN", nationality: "CHN", performance: 1.000 },
team: teams.alpine, runner17: { id: "runner17", firstName: "Haohan", lastName: "Wei", number: 2511, team: teams.class2511, yellowTCam: false, initials: "WHA", nationality: "CHN", performance: 1.000 },
yellowTCam: false, runner18: { id: "runner18", firstName: "Yuchen", lastName: "Zhu", number: 2525, team: teams.class2525, yellowTCam: false, initials: "ZHU", nationality: "CHN", performance: 1.000 },
initials: "ALO", runner19: { id: "runner19", firstName: "Shangshui", lastName: "Qin", number: 2509, team: teams.class2509, yellowTCam: false, initials: "SQI", nationality: "CHN", performance: 1.000 },
nationality: "ESP",
performance: 1.003,
},
bottas: {
id: "bottas",
firstName: "Valtteri",
lastName: "Bottas",
number: 77,
team: teams.mercedes,
yellowTCam: true,
initials: "BOT",
nationality: "FIN",
performance: 1.000,
},
gasly: {
id: "gasly",
firstName: "Pierre",
lastName: "Gasly",
number: 10,
team: teams.alphaTauri,
yellowTCam: true,
initials: "GAS",
nationality: "FRA",
performance: 1.020,
},
giovinazzi: {
id: "giovinazzi",
firstName: "Antonio",
lastName: "Giovinazzi",
number: 99,
team: teams.alfaRomeo,
yellowTCam: true,
initials: "GIO",
nationality: "ITA",
performance: 1.000,
},
hamilton: {
id: "hamilton",
firstName: "Lewis",
lastName: "Hamilton",
number: 44,
team: teams.mercedes,
yellowTCam: false,
initials: "HAM",
nationality: "GBR",
performance: 1.010,
},
kubica: {
id: "kubica",
firstName: "Robert",
lastName: "Kubica",
number: 88,
team: teams.alfaRomeo,
yellowTCam: false,
initials: "KUB",
nationality: "POL",
performance: 0.980,
},
latifi: {
id: "latifi",
firstName: "Nicolas",
lastName: "Latifi",
number: 6,
team: teams.williams,
yellowTCam: true,
initials: "LAT",
nationality: "CAN",
performance: 1.000,
},
leclerc: {
id: "leclerc",
firstName: "Charles",
lastName: "Leclerc",
number: 16,
team: teams.ferrari,
yellowTCam: false,
initials: "LEC",
nationality: "MCO",
performance: 1.005,
},
mazepin: {
id: "mazepin",
firstName: "Nikita",
lastName: "Mazepin",
number: 9,
team: teams.haas,
yellowTCam: false,
initials: "MAZ",
nationality: "RAF",
performance: 1.000,
},
norris: {
id: "norris",
firstName: "Lando",
lastName: "Norris",
number: 4,
team: teams.mclaren,
yellowTCam: true,
initials: "NOR",
nationality: "GBR",
performance: 1.009,
},
ocon: {
id: "ocon",
firstName: "Esteban",
lastName: "Ocon",
number: 31,
team: teams.alpine,
yellowTCam: true,
initials: "OCO",
nationality: "FRA",
performance: 1.000,
},
perez: {
id: "perez",
firstName: "Sergio",
// lastName: "Pérez",
lastName: "Perez",
number: 11,
team: teams.redBull,
yellowTCam: true,
initials: "PER",
nationality: "MEX",
performance: 1.000,
},
raikkonen: {
id: "raikkonen",
firstName: "Kimi",
// lastName: "Räikkönen",
lastName: "Raikkonen",
number: 7,
team: teams.alfaRomeo,
yellowTCam: false,
initials: "RAI",
nationality: "FIN",
performance: 1.002,
},
ricciardo: {
id: "ricciardo",
firstName: "Daniel",
lastName: "Ricciardo",
number: 3,
team: teams.mclaren,
yellowTCam: false,
initials: "RIC",
nationality: "AUS",
performance: 1.000,
},
russell: {
id: "russell",
firstName: "George",
lastName: "Russell",
number: 63,
team: teams.williams,
yellowTCam: false,
initials: "RUS",
nationality: "GBR",
performance: 1.016,
},
sainz: {
id: "sainz",
firstName: "Carlos",
lastName: "Sainz",
number: 55,
team: teams.ferrari,
yellowTCam: true,
initials: "SAI",
nationality: "ESP",
performance: 1.000,
},
schumacher: {
id: "schumacher",
firstName: "Mick",
lastName: "Schumacher",
number: 47,
team: teams.haas,
yellowTCam: true,
initials: "MSC",
nationality: "DEU",
performance: 1.025,
},
stroll: {
id: "stroll",
firstName: "Lance",
lastName: "Stroll",
number: 18,
team: teams.astonMartin,
yellowTCam: false,
initials: "STR",
nationality: "CAN",
performance: 1.000,
},
tsunoda: {
id: "tsunoda",
firstName: "Yuki",
lastName: "Tsunoda",
number: 22,
team: teams.alphaTauri,
yellowTCam: false,
initials: "TSU",
nationality: "JPN",
performance: 1.000,
},
verstappen: {
id: "verstappen",
firstName: "Max",
lastName: "Verstappen",
number: 33,
team: teams.redBull,
yellowTCam: false,
initials: "VER",
nationality: "NLD",
performance: 1.020,
},
vettel: {
id: "vettel",
firstName: "Sebastian",
lastName: "Vettel",
number: 5,
team: teams.astonMartin,
yellowTCam: true,
initials: "VET",
nationality: "DEU",
performance: 1.003,
},
zhou: {
id: "zhou",
firstName: "Guanyu",
lastName: "Zhou",
number: 24,
team: teams.alfaRomeo,
yellowTCam: true,
initials: "ZHO",
nationality: "CHN",
performance: 1.000,
},
}; };
type NumberStyleRule = { type NumberStyleRule = {
@@ -358,240 +70,58 @@ export type NumberStyle = {
fontFamily: string, fontFamily: string,
rules: Array<NumberStyleRule>, rules: Array<NumberStyleRule>,
}; };
/**
* Do not grab directly! // 为所有班级配置一套通用的 F1 风格的数字样式
*/ const defaultNumberStyle: NumberStyle = {
export const teamNumberStyles: { [teamId: string]: NumberStyle } = { numberColor: "#ffffff",
alfaRomeo: { fontFamily: theme.fonts.f1Italic,
numberColor: "#ffe9f4", rules: [
fontFamily: theme.fonts.f1Italic, { type: "shadow", property: repeater("0 0 0.2em #000", 2) },
rules: [ { type: "stroke", color: "#000", width: 0.13 },
{ type: "shadow", property: repeater("0 0 0.2em #900000", 2) }, { type: "stroke", color: "#555", width: 0.05 },
{ type: "stroke", color: "#000", width: 0.13 }, { type: "shadow", property: "0 0 0.07em #333" },
{ type: "stroke", color: "#900000", width: 0.05 }, ],
{ type: "shadow", property: "0 0 0.07em #900000" },
],
},
alphaTauri: {
numberColor: "#eff5fc",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "stroke", color: "#2b4562", width: 0.03 },
],
},
alpine: {
numberColor: "#ddffff",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "shadow", property: repeater("0 0 0.2em #4B7B9E", 4) },
{ type: "stroke", color: "#000", width: 0.13 },
{ type: "shadow", property: repeater("0 0 0.07em #65A6D6", 2) },
],
},
astonMartin: {
numberColor: "#f9ffff",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "shadow", property: repeater("0 0 0.2em #006f62", 4) },
{ type: "stroke", color: "#000", width: 0.13 },
{ type: "stroke", color: "#006f62", width: 0.05 },
{ type: "shadow", property: "0 0 0.07em #006f62" },
],
},
haas: {
numberColor: "#fff",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "shadow", property: repeater("0 0 0.2em #fff", 4) },
{ type: "stroke", color: "#000", width: 0.13 },
{ type: "stroke", color: "#999", width: 0.05 },
{ type: "shadow", property: "0 0 0.07em #eee" },
],
},
ferrari: {
numberColor: "#fff5f6",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "shadow", property: repeater("0 0 0.2em #dc0000", 2) },
{ type: "stroke", color: "#000", width: 0.13 },
{ type: "stroke", color: "#dc0000", width: 0.05 },
{ type: "shadow", property: "0 0 0.07em #dc0000" },
],
},
mclaren: {
numberColor: "#fdf5f6",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "shadow", property: repeater("0 0 0.2em #ffb241", 2) },
{ type: "stroke", color: "#000", width: 0.13 },
{ type: "stroke", color: "#ffb241", width: 0.05 },
{ type: "shadow", property: "0 0 0.07em #ffb241" },
],
},
mercedes: {
numberColor: "#daffff",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "shadow", property: repeater("0 0 0.2em #daffff", 4) },
{ type: "stroke", color: "#000", width: 0.13 },
{ type: "stroke", color: "#35dfae", width: 0.05 },
{ type: "shadow", property: repeater("0 0 0.07em #35dfae", 2) },
],
},
redBull: {
numberColor: "#f2f2ff",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "shadow", property: repeater("0 0 0.2em #0600ef", 4) },
{ type: "stroke", color: "#000", width: 0.13 },
{ type: "stroke", color: "#ebffff", width: 0 },
],
},
williams: {
numberColor: "#ebffff",
fontFamily: theme.fonts.f1Italic,
rules: [
{ type: "shadow", property: repeater("0 0 0.2em #005aff", 2) },
{ type: "stroke", color: "#000", width: 0.13 },
{ type: "stroke", color: "#ebffff", width: 0 },
],
},
}; };
export const teamNumberStyles: { [teamId: string]: NumberStyle } = teamIds.reduce((acc, id) => {
acc[id] = defaultNumberStyle;
return acc;
}, {} as { [teamId: string]: NumberStyle });
export type TeamFlagStyle = { export type TeamFlagStyle = {
backgroundColor: string, backgroundColor: string,
imageSize: Percent, imageSize: Percent,
imagePos: { imagePos: { x: number, y: number },
x: number, subFlagModifier: { x: number, y: number, scale: number },
y: number,
},
subFlagModifier: {
x: number,
y: number,
scale: number,
},
}; };
export const teamFlagStyles: { [teamId: string]: TeamFlagStyle } = {
alfaRomeo: { // 为所有班级配置一套通用的旗帜样式
backgroundColor: "#660000", const defaultFlagStyle: TeamFlagStyle = {
imageSize: 41, backgroundColor: "#333333",
imagePos: { x: .32, y: .08 }, imageSize: 50,
subFlagModifier: { x: .99, y: .97, scale: .99 }, imagePos: { x: .25, y: .0 },
}, subFlagModifier: { x: 1, y: 1, scale: 1 },
alphaTauri: {
backgroundColor: "#232c3b",
imageSize: 58,
imagePos: { x: .25, y: -.15 },
subFlagModifier: { x: 1, y: .9, scale: .99 },
},
alpine: {
backgroundColor: "black",
imageSize: 51,
imagePos: { x: .23, y: -.12 },
subFlagModifier: { x: 1.02, y: .98, scale: .98 },
},
astonMartin: {
backgroundColor: "#037356",
imageSize: 109,
imagePos: { x: .05, y: -.75 },
subFlagModifier: { x: 1.05, y: .9, scale: .95 },
},
ferrari: {
backgroundColor: "#dc0000",
imageSize: 50,
imagePos: { x: .3, y: .04 },
subFlagModifier: { x: 1, y: 1, scale: .98 },
},
haas: {
backgroundColor: "#f0f0f0",
imageSize: 46,
imagePos: { x: .3, y: -.04 },
subFlagModifier: { x: 1, y: .98, scale: .98 },
},
mclaren: {
backgroundColor: "#545459",
imageSize: 50,
imagePos: { x: .25, y: -.1 },
subFlagModifier: { x: .98, y: 1.03, scale: 1.03 },
},
mercedes: {
backgroundColor: "#1ee0ad",
imageSize: 40,
imagePos: { x: .33, y: .05 },
subFlagModifier: { x: 1, y: 1, scale: .98 },
},
redBull: {
backgroundColor: "#413ae2",
imageSize: 88,
imagePos: { x: .33, y: 0 },
subFlagModifier: { x: 1.04, y: .2, scale: .92 },
},
williams: {
backgroundColor: "#12a0cb",
imageSize: 40,
imagePos: { x: .35, y: .1 },
subFlagModifier: { x: 1, y: 1, scale: .98 },
},
}; };
export const teamFlagStyles: { [teamId: string]: TeamFlagStyle } = teamIds.reduce((acc, id) => {
acc[id] = defaultFlagStyle;
return acc;
}, {} as { [teamId: string]: TeamFlagStyle });
export type TeamGemStyle = { export type TeamGemStyle = {
backgroundColor: string, backgroundColor: string,
imageSize: Percent, imageSize: Percent,
imagePos: { imagePos: { x: number, y: number },
x: number,
y: number,
},
}; };
export const teamGemStyles: { [teamId: string]: TeamGemStyle } = {
alfaRomeo: { // 为所有班级配置一套通用的 Gem 样式
backgroundColor: "#660000", const defaultGemStyle: TeamGemStyle = {
imageSize: 65, backgroundColor: "#333333",
imagePos: { x: .28, y: .15 }, imageSize: 65,
}, imagePos: { x: .25, y: .1 },
alphaTauri: {
backgroundColor: "#232c3b",
imageSize: 75,
imagePos: { x: .26, y: .07 },
},
alpine: {
backgroundColor: "black",
imageSize: 82,
imagePos: { x: .13, y: 0 },
},
astonMartin: {
backgroundColor: "#037356",
imageSize: 130,
imagePos: { x: .05, y: -.22 },
},
ferrari: {
backgroundColor: "#dc0000",
imageSize: 65,
imagePos: { x: .3, y: .18 },
},
haas: {
backgroundColor: "#f0f0f0",
imageSize: 65,
imagePos: { x: .25, y: .12 },
},
mclaren: {
backgroundColor: "#545459",
imageSize: 67,
imagePos: { x: .25, y: .1 },
},
mercedes: {
backgroundColor: "#1ee0ad",
imageSize: 63,
imagePos: { x: .31, y: .16 },
},
redBull: {
backgroundColor: "#413ae2",
imageSize: 130,
imagePos: { x: .20, y: .05 },
},
williams: {
backgroundColor: "#12a0cb",
imageSize: 65,
imagePos: { x: .3, y: .12 },
},
}; };
export const teamGemStyles: { [teamId: string]: TeamGemStyle } = teamIds.reduce((acc, id) => {
acc[id] = defaultGemStyle;
return acc;
}, {} as { [teamId: string]: TeamGemStyle });
+19 -166
View File
@@ -47,30 +47,13 @@ const GRID_POSITION_GAP: Meters = 8;
const POLE_TO_START: Meters = -10; const POLE_TO_START: Meters = -10;
/** /**
* The starting grid, kept as a plain list of driver ids so the roster can be * 【修改点 1】:把初始名单换成了你的 runner1 ~ runner20
* rebuilt (and reset) without twenty near identical object literals.
*/ */
const INITIAL_LINEUP: DriverId[] = [ const INITIAL_LINEUP: DriverId[] = [
"verstappen", "runner1", "runner2", "runner3", "runner4", "runner5",
"hamilton", "runner6", "runner7", "runner8", "runner9", "runner10",
"bottas", "runner11", "runner12", "runner13", "runner14", "runner15",
"perez", "runner16", "runner17", "runner18", "runner19",
"sainz",
"norris",
"leclerc",
"ricciardo",
"gasly",
"alonso",
"ocon",
"vettel",
"stroll",
"tsunoda",
"russell",
"raikkonen",
"latifi",
"giovinazzi",
"schumacher",
"mazepin",
]; ];
function buildInitialGrid(): Grid { function buildInitialGrid(): Grid {
@@ -85,9 +68,10 @@ function buildInitialGrid(): Grid {
} }
const initialState: RootState["event"] = { const initialState: RootState["event"] = {
trackName: "Circuit de Spa-Franchorchamps", // 【修改点 2】:修改了赛道名和长度(单位是米,400米一圈)
trackLength: 7004, trackName: "400M Track - GaoXin Campus",
trackStartFinishDelta: -124, trackLength: 400,
trackStartFinishDelta: 0,
courseStatus: { courseStatus: {
courseFlag: CourseFlag.Green, courseFlag: CourseFlag.Green,
sectorFlags: [SectorFlag.Green, SectorFlag.Green, SectorFlag.Green], sectorFlags: [SectorFlag.Green, SectorFlag.Green, SectorFlag.Green],
@@ -101,7 +85,7 @@ const initialState: RootState["event"] = {
timeLimit: 60 * 60 * 2 * 1000, timeLimit: 60 * 60 * 2 * 1000,
lapCount: 1, lapCount: 1,
lapAdjust: 0, lapAdjust: 0,
scheduledLaps: 44, scheduledLaps: 2,
}, },
grid: buildInitialGrid(), grid: buildInitialGrid(),
sortedGridSpots: Array.from(Array(INITIAL_LINEUP.length).keys()), sortedGridSpots: Array.from(Array(INITIAL_LINEUP.length).keys()),
@@ -114,10 +98,6 @@ const initialState: RootState["event"] = {
positionScript: buildInitialPositionScript(), positionScript: buildInitialPositionScript(),
}; };
/**
* The shipped schedule is parsed once at start up so a broken default can never
* take the app down - it would simply report an error in the script panel.
*/
function buildInitialPositionScript(): RootState["event"]["positionScript"] { function buildInitialPositionScript(): RootState["event"]["positionScript"] {
const { file, error } = parsePositionScriptSafe(DEFAULT_POSITION_SCRIPT_JSON); const { file, error } = parsePositionScriptSafe(DEFAULT_POSITION_SCRIPT_JSON);
return { return {
@@ -131,11 +111,6 @@ function buildInitialPositionScript(): RootState["event"]["positionScript"] {
}; };
} }
/**
* Gives every car the track position of the rank it now occupies. The set of
* distances is preserved, so the gaps between the cars - and therefore the
* interval column - survive a reshuffle untouched.
*/
function applyRunningOrder( function applyRunningOrder(
state: RootState["event"], state: RootState["event"],
orderedGridSpots: GridSpot[], orderedGridSpots: GridSpot[],
@@ -162,13 +137,6 @@ function applyRunningOrder(
return true; return true;
} }
/**
* Puts the script's `order` list onto the track.
*
* Returns `null` on success, or a readable reason why it could not be applied.
* An unresolvable code used to fail silently, which made one typo in `order`
* look like the whole feature was broken.
*/
function applyInitialOrder(state: RootState["event"]): Optional<string> { function applyInitialOrder(state: RootState["event"]): Optional<string> {
const { initialOrder } = state.positionScript; const { initialOrder } = state.positionScript;
if (initialOrder.length === 0) return null; if (initialOrder.length === 0) return null;
@@ -204,7 +172,6 @@ interface SetCarStatusAction {
status: CarStatus; status: CarStatus;
} }
/** Every driver attribute the roster editor is allowed to touch. */
export type DriverEditableField = export type DriverEditableField =
| "firstName" | "firstName"
| "lastName" | "lastName"
@@ -238,10 +205,6 @@ export interface PositionScriptResultAction {
error: Optional<string>; error: Optional<string>;
} }
/**
* The lap counter shown by the status indicator: whatever the simulation
* derives from the leader's distance, plus any laps the director added by hand.
*/
function recalculateLapCount(state: RootState["event"], leaderDistance: Meters) { function recalculateLapCount(state: RootState["event"], leaderDistance: Meters) {
state.eventProgress.lapCount = Math.max( state.eventProgress.lapCount = Math.max(
1, 1,
@@ -251,12 +214,6 @@ function recalculateLapCount(state: RootState["event"], leaderDistance: Meters)
); );
} }
/**
* Re-sorts the field by distance and recomputes every derived value: positions,
* the running order and the lap counter. Extracted from the reducer of the same
* name because the position script needs to run it in the middle of its own
* reducer.
*/
function recalculateRunningOrder(state: RootState["event"]) { function recalculateRunningOrder(state: RootState["event"]) {
const sortingGrid = state.grid.map((car, index): Car & { const sortingGrid = state.grid.map((car, index): Car & {
gridSpot: GridSpot, gridSpot: GridSpot,
@@ -272,58 +229,36 @@ function recalculateRunningOrder(state: RootState["event"]) {
+ state.trackStartFinishDelta; + state.trackStartFinishDelta;
sortingGrid.forEach((entry, sortedPosition) => { sortingGrid.forEach((entry, sortedPosition) => {
// Don't update positions of cars who have crossed the finish line.
if (entry.distance < raceEndDistance) { if (entry.distance < raceEndDistance) {
state.grid[entry.gridSpot].position = sortedPosition + 1; state.grid[entry.gridSpot].position = sortedPosition + 1;
} }
}); });
/**
* Calculate which lap we're on by taking the leader's distance.
* Also must consider the fact that the race distance 0 is at the start
* line, but the race ends at the finish line, which is often (always?)
* behind the start line by some distance.
*
* Any laps the director added by hand are layered on top, so the counter can
* be pushed forward without rewriting the race itself.
*/
recalculateLapCount(state, sortingGrid[0].distance); recalculateLapCount(state, sortingGrid[0].distance);
} }
/**
* Note: Add `state.lastUpdate = Date.now();` to the end of every reducer to
* keep components up to date that watch for changes with useEffect() functions.
*/
export const eventSlice = createSlice({ export const eventSlice = createSlice({
name: "event", name: "event",
initialState, initialState,
reducers: { reducers: {
setCourseFlag: (state, action: PayloadAction<CourseFlag>) => { setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
state.courseStatus.courseFlag = action.payload; state.courseStatus.courseFlag = action.payload;
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
setEventStatus: (state, action: PayloadAction<EventStatus>) => { setEventStatus: (state, action: PayloadAction<EventStatus>) => {
state.eventStatus = action.payload; state.eventStatus = action.payload;
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
refreshRunningOrder: (state) => { refreshRunningOrder: (state) => {
recalculateRunningOrder(state); recalculateRunningOrder(state);
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
increaseDistance: (state, action: PayloadAction<IncreaseDistanceAction>) => { increaseDistance: (state, action: PayloadAction<IncreaseDistanceAction>) => {
const gridMap = driverToGridMap(state.grid); const gridMap = driverToGridMap(state.grid);
const { gridSpots, distance, randomness, usePerformance } = action.payload; const { gridSpots, distance, randomness, usePerformance } = action.payload;
gridSpots.forEach(gridSpot => { gridSpots.forEach(gridSpot => {
const car = state.grid[gridSpot]; const car = state.grid[gridSpot];
// Do not update cars that are DNS, retired, or finished.
// This does remind me that Finished cars must be treated and reported
// differently...
if (orMatch(car.status, CarStatus.DidNotStart, CarStatus.Finished, CarStatus.Retired)) { if (orMatch(car.status, CarStatus.DidNotStart, CarStatus.Finished, CarStatus.Retired)) {
return; return;
} }
@@ -343,7 +278,6 @@ export const eventSlice = createSlice({
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
awardFastestLap: (state, action: PayloadAction<GridSpot>) => { awardFastestLap: (state, action: PayloadAction<GridSpot>) => {
// Awards fastest lap to provided car. Removes fastest lap from anyone else.
state.grid.forEach((car, index) => { state.grid.forEach((car, index) => {
const fastestLapNoticeIndex = car.notices.findIndex( const fastestLapNoticeIndex = car.notices.findIndex(
notice => notice === CarNotice.FastestLap, notice => notice === CarNotice.FastestLap,
@@ -369,46 +303,21 @@ export const eventSlice = createSlice({
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
/**
* Driver roster editing.
*
* The grid holds the only copy of a driver that the broadcast ever renders,
* so an edit is written straight onto the car sitting in that grid slot and
* every graphic picks it up on the next render.
*/
updateDriver: (state, action: PayloadAction<UpdateDriverAction>) => { updateDriver: (state, action: PayloadAction<UpdateDriverAction>) => {
const { gridSpot, field, value } = action.payload; const { gridSpot, field, value } = action.payload;
const driver = state.grid[gridSpot]?.driver; const driver = state.grid[gridSpot]?.driver;
if (driver == null) return; if (driver == null) return;
switch (field) { switch (field) {
case "firstName": case "firstName": driver.firstName = String(value); break;
driver.firstName = String(value); case "lastName": driver.lastName = String(value); break;
break; case "initials": driver.initials = String(value).toUpperCase().slice(0, 4); break;
case "lastName": case "number": driver.number = clampDriverNumber(Number(value)); break;
driver.lastName = String(value); case "nationality": driver.nationality = String(value).toUpperCase(); break;
break; case "performance": driver.performance = clampPerformance(Number(value)); break;
case "initials": case "yellowTCam": driver.yellowTCam = Boolean(value); break;
driver.initials = String(value).toUpperCase().slice(0, 4); case "portrait": driver.portrait = sanitizePortrait(value); break;
break; default: return;
case "number":
driver.number = clampDriverNumber(Number(value));
break;
case "nationality":
driver.nationality = String(value).toUpperCase();
break;
case "performance":
driver.performance = clampPerformance(Number(value));
break;
case "yellowTCam":
driver.yellowTCam = Boolean(value);
break;
case "portrait":
driver.portrait = sanitizePortrait(value);
break;
default:
return;
} }
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
@@ -420,10 +329,8 @@ export const eventSlice = createSlice({
if (driver == null || team == null) return; if (driver == null || team == null) return;
driver.team = team; driver.team = team;
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
/** Exchanges two cars' drivers without disturbing the race they are running. */
swapDrivers: (state, action: PayloadAction<SwapDriversAction>) => { swapDrivers: (state, action: PayloadAction<SwapDriversAction>) => {
const { a, b } = action.payload; const { a, b } = action.payload;
if (a === b || state.grid[a] == null || state.grid[b] == null) return; if (a === b || state.grid[a] == null || state.grid[b] == null) return;
@@ -434,20 +341,14 @@ export const eventSlice = createSlice({
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
/** Restores a single driver to the stock record that ships with the app. */
resetDriver: (state, action: PayloadAction<GridSpot>) => { resetDriver: (state, action: PayloadAction<GridSpot>) => {
const car = state.grid[action.payload]; const car = state.grid[action.payload];
const stock = car == null ? null : cloneDriver(car.driver.id); const stock = car == null ? null : cloneDriver(car.driver.id);
if (car == null || stock == null) return; if (car == null || stock == null) return;
car.driver = stock; car.driver = stock;
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
/**
* Restores the starting lineup. Cars keep the distance they have covered -
* this puts the original drivers back into the slots they started in.
*/
resetRoster: (state) => { resetRoster: (state) => {
state.grid.forEach((car, index) => { state.grid.forEach((car, index) => {
const driverId = INITIAL_LINEUP[index]; const driverId = INITIAL_LINEUP[index];
@@ -457,11 +358,6 @@ export const eventSlice = createSlice({
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
/**
* Bulk replacement used by localStorage rehydration and by the editor's
* import button. Entries are matched to grid slots by index and every
* field is validated before it is allowed anywhere near the state.
*/
applyRoster: (state, action: PayloadAction<Array<Partial<DriverRosterEntry>>>) => { applyRoster: (state, action: PayloadAction<Array<Partial<DriverRosterEntry>>>) => {
const entries = action.payload; const entries = action.payload;
if (!Array.isArray(entries)) return; if (!Array.isArray(entries)) return;
@@ -474,14 +370,6 @@ export const eventSlice = createSlice({
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
// --------------------------------------------------------------- lap count
/**
* Nudges the LAP counter. The offset is remembered separately from the lap
* the simulation derives from the leader's distance, so the two never fight
* each other: press +1 and the counter reads one lap further on for the rest
* of the race.
*/
adjustLap: (state, action: PayloadAction<number>) => { adjustLap: (state, action: PayloadAction<number>) => {
state.eventProgress.lapAdjust += action.payload; state.eventProgress.lapAdjust += action.payload;
@@ -490,20 +378,12 @@ export const eventSlice = createSlice({
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
// -------------------------------------------------------------- show clock
/**
* The stopwatch beside the LAP counter. Its zero is the moment the timing
* graphics appeared, which is also the zero the position script is timed
* against.
*/
startShowClock: (state) => { startShowClock: (state) => {
if (state.showClock.startedAt != null) return; if (state.showClock.startedAt != null) return;
state.showClock.startedAt = Date.now(); state.showClock.startedAt = Date.now();
if (!state.showClock.hasStarted) { if (!state.showClock.hasStarted) {
// First run: lay down the script's starting order and arm the schedule.
state.showClock.hasStarted = true; state.showClock.hasStarted = true;
state.positionScript.firedCount = 0; state.positionScript.firedCount = 0;
state.positionScript.orderError = applyInitialOrder(state); state.positionScript.orderError = applyInitialOrder(state);
@@ -519,10 +399,6 @@ export const eventSlice = createSlice({
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
/**
* Back to zero and ready to replay the script from the top. The manual lap
* offset is rewound too, so a replay reproduces the run exactly.
*/
resetShowClock: (state) => { resetShowClock: (state) => {
state.showClock.accumulatedMs = 0; state.showClock.accumulatedMs = 0;
state.showClock.startedAt = Date.now(); state.showClock.startedAt = Date.now();
@@ -535,16 +411,9 @@ export const eventSlice = createSlice({
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
// ---------------------------------------------------------- position script
setPositionScriptJson: (state, action: PayloadAction<string>) => { setPositionScriptJson: (state, action: PayloadAction<string>) => {
state.positionScript.json = action.payload; state.positionScript.json = action.payload;
}, },
/**
* Result of parsing whatever the user has typed. Nothing is thrown away on a
* bad edit: the error is stored and the last good schedule keeps running.
* A genuinely different schedule rewinds the run so it can play again.
*/
applyPositionScriptResult: ( applyPositionScriptResult: (
state, state,
action: PayloadAction<PositionScriptResultAction>, action: PayloadAction<PositionScriptResultAction>,
@@ -562,13 +431,6 @@ export const eventSlice = createSlice({
state.positionScript.error = error; state.positionScript.error = error;
if (next !== previous) { if (next !== previous) {
/**
* A changed schedule is meant to be watched. Rewinding the run is what
* makes editing the JSON feel like "press play": previously only
* `firedCount` was cleared, so an edit made after a few seconds put every
* earlier line into the past at once and they all fired together in a
* burst, which looked like the script had jumped or had not run at all.
*/
state.positionScript.firedCount = 0; state.positionScript.firedCount = 0;
state.eventProgress.lapAdjust = 0; state.eventProgress.lapAdjust = 0;
@@ -577,16 +439,11 @@ export const eventSlice = createSlice({
state.showClock.startedAt = Date.now(); state.showClock.startedAt = Date.now();
} }
// `order` takes effect on the spot instead of waiting for a reset.
state.positionScript.orderError = applyInitialOrder(state); state.positionScript.orderError = applyInitialOrder(state);
} }
state.lastUpdate = Date.now(); state.lastUpdate = Date.now();
}, },
/**
* Fires every script line that has come due, in one go, so the running order
* is only reshuffled once per tick no matter how many lines are waiting.
*/
runPositionScript: (state, action: PayloadAction<{ elapsedMs: number }>) => { runPositionScript: (state, action: PayloadAction<{ elapsedMs: number }>) => {
const script = state.positionScript; const script = state.positionScript;
const { events } = script; const { events } = script;
@@ -608,8 +465,6 @@ export const eventSlice = createSlice({
const gridSpot = findGridSpotByRef(state.grid, reference); const gridSpot = findGridSpotByRef(state.grid, reference);
if (gridSpot != null && !spots.includes(gridSpot)) spots.push(gridSpot); if (gridSpot != null && !spots.includes(gridSpot)) spots.push(gridSpot);
} }
// An unresolvable name is skipped rather than stalling the schedule.
// "lap" is the one action that carries no driver to resolve.
if (spots.length === 0 && event.action !== "lap") continue; if (spots.length === 0 && event.action !== "lap") continue;
switch (event.action) { switch (event.action) {
@@ -644,8 +499,6 @@ export const eventSlice = createSlice({
} }
} }
// Nothing came due: leave the state untouched so the 100ms tick does not
// ripple a re-render through the whole broadcast.
if (fired === script.firedCount) return; if (fired === script.firedCount) return;
script.firedCount = fired; script.firedCount = fired;
+1 -1
View File
@@ -1 +1 @@
<svg stroke-miterlimit="10" viewBox="0 0 743.5 371.75" xmlns="http://www.w3.org/2000/svg" clip-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><path d="M296.633 65.667c.919 0 1.854-.15 2.719-.352l31.185 105.977h.027c3.464 11.824 20.686 20.809 41.414 20.809 20.74 0 37.923-8.982 41.426-20.809h.015l31.158-105.908c.73.15 1.541.285 2.382.285 6.062 0 10.959-4.897 10.959-10.986 0-6.02-4.884-10.946-10.959-10.946-6.035 0-10.959 4.912-10.959 10.946 0 4.398 2.544 8.132 6.251 9.889l-36.126 77.427 5.792-104.325h.243c6.035 0 10.974-4.897 10.974-10.946 0-6.047-4.924-10.986-10.974-10.986-6.02 0-10.974 4.939-10.974 10.986 0 4.993 3.368 9.174 7.915 10.511l-24.014 101.96-11.595-112.375c5.329-.784 9.39-5.344 9.39-10.865C382.882 9.924 377.998 5 371.936 5c-6.074 0-10.974 4.912-10.974 10.959 0 5.521 4.113 10.121 9.43 10.865l-11.554 112.159-23.987-101.756c4.614-1.298 8.024-5.494 8.024-10.511 0-6.047-4.924-10.986-10.959-10.986-6.074 0-10.986 4.939-10.986 10.986 0 6.035 4.912 10.946 10.986 10.946h.15l5.804 104.268-36.205-77.51a10.933 10.933 0 005.939-9.769c0-6.02-4.884-10.946-10.974-10.946-6.047 0-10.946 4.912-10.946 10.946.002 6.116 4.887 11.016 10.949 11.016zm75.14 96.694c18.968 0 34.324 4.857 34.324 10.809 0 5.981-15.357 10.797-34.324 10.797s-34.339-4.803-34.339-10.797c.003-5.952 15.372-10.809 34.339-10.809zM250.701 236.543c-31.443 0-56.933 25.531-56.933 56.148 0 30.657 25.489 56.161 56.933 56.161 31.416 0 56.891-25.516 56.891-56.161 0-30.617-25.477-56.148-56.891-56.148zm23.648 88.592c-1.758 2.638-3.965 4.993-6.549 6.885-4.208 3.368-9.009 5.317-14.11 5.494-.961.108-1.976.216-2.989.216-1.055 0-2.043-.108-3.043-.216-5.101-.189-9.862-2.124-14.083-5.494a26.92 26.92 0 01-6.549-6.885c-5.912-8.171-9.619-19.617-9.619-32.336 0-11.959 3.301-22.81 8.564-30.779 2.962-5.302 7.603-9.499 13.287-11.959.042-.015.081-.042.135-.069.258-.108.529-.216.826-.312a25.118 25.118 0 012.301-.811 29.148 29.148 0 018.186-1.177c2.842 0 5.588.42 8.171 1.177.799.243 1.556.487 2.328.799.258.123.529.231.826.324.027.054.081.054.135.069 5.629 2.463 10.337 6.657 13.26 11.959 5.302 8.024 8.564 18.86 8.564 30.779-.022 12.717-3.714 24.177-9.641 32.336zM420.331 304.392h-7.874v15.829c-.243 9.484-7.97 17.114-17.507 17.114-.042 0-.081-.015-.108-.015v.027h-33.269v-88.938h15.248v-7.915H321.838v7.915h15.261v88.944h-15.261v7.928h98.494v-.027h.081v-25.87h-.081v-14.992h-.001zM540.582 240.52H436.958v7.928h14.951v88.956h-14.951v7.928h104.193v-37.719h-7.982v12.488c-.081 9.58-7.888 17.331-17.507 17.331H476.398v-44.158h12.572c7.09.081 12.839 5.846 12.839 12.935 0 .123 0 .216-.015.285h.015V312.285h7.21v-43.852h-7.198v5.086h-.015c0 .096.015.204.015.285 0 7.102-5.75 12.163-12.854 12.244h-12.569v-37.585h39.331c9.592.054 17.345 7.78 17.426 17.318v10.782h7.982V240.532h-.556v-.012h.001zM676.498 337.728c-7.603-.189-9.39-2.53-15.261-9.295l-34.676-43.159 22.945-27.397v.015c6.155-7.048 7.82-9.484 15.747-9.607h5.993v-7.657H628.955v7.657h9.28v.027h.027c2.003 0 3.611 1.583 3.611 3.572 0 .799-.258 1.502-.664 2.097l-20.349 24.218-15.964-19.875-3.328-4.221c-.501-.61-.838-1.394-.838-2.232 0-1.976 1.61-3.572 3.584-3.599h9.105v-7.657h-52.886v7.657h2.517c6.738.312 8.685 2.611 13.99 8.7l30.698 38.221-27.64 32.984v-.069c-6.182 7.075-7.861 9.457-15.801 9.607h-6.452v7.63h45.225v-7.63h-11.145a3.612 3.612 0 01-3.611-3.626c0-.838.312-1.61.826-2.22l24.543-29.318 20.389 25.423 3.112 3.869c.487.637.826 1.406.826 2.247a3.634 3.634 0 01-3.626 3.626h-9.808v7.63h57.026v-7.63h-5.101v.012h-.003zM175.813 337.229l-6.927-20.145c-3.26-8.943-5.548-13.002-10.607-17.616-3.341-2.989-7.997-4.398-11.46-5.398 12.893-2.043 22.716-13.233 22.716-26.679 0-14.924-12.082-27.031-27.004-27.031-.15 0-.312.027-.514.027v-.026H62.139v7.888h14.735v89.037H61.896v7.928h54.538v-7.93h-15.059v-42.781h11.689c.379.015.73.027 1.096.054h2.367c3.734.135 6.981.676 9.877 1.502 2.707.703 5.588 1.622 7.483 2.854 2.571 1.677 5.329 4.004 7.753 8.144a65.706 65.706 0 011.731 3.328c4.452 8.387 7.129 20.01 10.093 34.757h18.021v.027h16.222v-7.943h-11.895v.003h.001zm-48.854-50.681h-25.531v-38.356h25.516c10.986.42 19.752 8.09 19.752 19.172s-8.764 18.697-19.737 19.184z" fill="#faff04" fill-rule="evenodd"/></svg> <svg></svg>

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 11 B

+25 -120
View File
@@ -84,7 +84,7 @@ export interface OverlayItem {
export interface Event { export interface Event {
trackName: string; trackName: string;
trackLength: Meters; trackLength: Meters;
trackStartFinishDelta: Meters; // Negative if finish behind start line. trackStartFinishDelta: Meters;
courseStatus: CourseStatus; courseStatus: CourseStatus;
eventStatus: EventStatus; eventStatus: EventStatus;
eventMode: EventMode; eventMode: EventMode;
@@ -92,74 +92,47 @@ export interface Event {
grid: Grid; grid: Grid;
sortedGridSpots: GridSpot[]; sortedGridSpots: GridSpot[];
lastUpdate: number; lastUpdate: number;
/** Time elapsed since the timing graphics first appeared on screen. */
showClock: ShowClock; showClock: ShowClock;
/** A JSON authored schedule of running order changes. */
positionScript: PositionScript; positionScript: PositionScript;
} }
export interface EventProgress { export interface EventProgress {
startTime: Milliseconds; startTime: Milliseconds;
timeLimit: Milliseconds; timeLimit: Milliseconds;
lapCount: number; lapCount: number;
/**
* Laps added by hand on top of the lap the simulation derives from the
* leader's distance, so the director can push the counter forward (or back)
* without disturbing the race itself.
*/
lapAdjust: number; lapAdjust: number;
scheduledLaps: number; scheduledLaps: number;
} }
/**
* The stopwatch that runs alongside the LAP counter. Its zero is the moment the
* timing board appeared, which is also what the position script is timed
* against.
*/
export interface ShowClock { export interface ShowClock {
/** Timestamp the clock was last started, or null while it is paused. */
startedAt: Optional<number>; startedAt: Optional<number>;
/** Milliseconds banked by the runs that came before. */
accumulatedMs: Milliseconds; accumulatedMs: Milliseconds;
/** True once the clock has run at least once. */
hasStarted: boolean; hasStarted: boolean;
} }
export type PositionScriptAction = "swap" | "move" | "retire" | "restore" | "lap"; export type PositionScriptAction = "swap" | "move" | "retire" | "restore" | "lap";
export interface PositionScriptEvent { export interface PositionScriptEvent {
/** Milliseconds after the clock's zero. */
at: Milliseconds; at: Milliseconds;
action: PositionScriptAction; action: PositionScriptAction;
/**
* Driver references. A reference may be a driver id ("verstappen"), a three
* letter code ("VER") or a car number ("33").
*/
drivers: string[]; drivers: string[];
/** Target position (1 based) for "move". */
to?: number; to?: number;
/** Lap delta for "lap". */
value?: number; value?: number;
} }
export interface PositionScript { export interface PositionScript {
/** Exactly what the user is editing, kept as text. */
json: string; json: string;
/** The last schedule that parsed, sorted by time. */
events: PositionScriptEvent[]; events: PositionScriptEvent[];
/** Drivers placed at the start of a run, in running order. */
initialOrder: string[]; initialOrder: string[];
autoStart: boolean; autoStart: boolean;
error: Optional<string>; error: Optional<string>;
/** Why the `order` list could not be put on track, if it could not. */
orderError: Optional<string>; orderError: Optional<string>;
/** How many events of the current run have already fired. */
firedCount: number; firedCount: number;
} }
export enum EventStatus { export enum EventStatus {
Waiting, // Event is waiting to start. Waiting,
Running, // Event is running. Running,
Stopped, // Event has concluded. Stopped,
Suspended, // Event is suspended (ex: rain delay). Suspended,
} }
export enum EventMode { export enum EventMode {
Race, Race,
@@ -195,15 +168,13 @@ export enum SectorFlag {
export enum SafetyCarStatus { Clear, Starting, Out, Ending } export enum SafetyCarStatus { Clear, Starting, Out, Ending }
export enum VirtualSafetyCarStatus { Clear, Active, Ending } export enum VirtualSafetyCarStatus { Clear, Active, Ending }
export type Grid = Car[]; // Grid order does not change. export type Grid = Car[];
export type GridSpot = number; // GridSpot doesn't change. Starts at 0. export type GridSpot = number;
export interface Car { export interface Car {
position: number; // Position is DERIVED from distance and status. position: number;
driver: Driver; driver: Driver;
status: CarStatus; status: CarStatus;
tyre: Tyre; tyre: Tyre;
// tyreHistory: Tyre[];
// pitsCompleted: number;
notices: CarNotice[]; notices: CarNotice[];
distance: Meters; distance: Meters;
} }
@@ -215,39 +186,13 @@ export interface Driver {
team: Team; team: Team;
yellowTCam: boolean; yellowTCam: boolean;
initials: string; initials: string;
nationality: string; // ISO 3166-1 alpha-3 codes nationality: string;
performance: Fraction; // Versus teammate performance: Fraction;
/**
* Optional portrait override. Portraits are picked from the images bundled in
* public/images/drivers/front. When omitted the driver's own id is used, so
* any driver that never gets edited keeps behaving exactly as before.
*/
portrait?: string; portrait?: string;
} }
export type DriverId =
| "albon" // 【关键修复】:改成了 string,彻底解除限制
| "alonso" export type DriverId = string;
| "bottas"
| "gasly"
| "giovinazzi"
| "hamilton"
| "kubica"
| "latifi"
| "leclerc"
| "mazepin"
| "norris"
| "ocon"
| "perez"
| "raikkonen"
| "ricciardo"
| "russell"
| "sainz"
| "schumacher"
| "stroll"
| "tsunoda"
| "verstappen"
| "vettel"
| "zhou";
export enum CarStatus { export enum CarStatus {
Normal, Normal,
@@ -286,55 +231,23 @@ export enum TyreCompound {
Intermediate, Intermediate,
} }
export interface Team { export interface Team {
id: TeamId; id: TeamId;
shortName: TeamShortName; shortName: TeamShortName;
fullName: TeamFullName; fullName: TeamFullName;
nationality: string; // ISO 3166-1 alpha-3 codes nationality: string;
performance: Fraction; performance: Fraction;
// logo: string;
} }
export type TeamId =
| "alfaRomeo" // 【关键修复】:车队全部改成 string,不再限制只能填 F1 车队
| "alphaTauri" export type TeamId = string;
| "alpine" export type TeamShortName = string;
| "astonMartin" export type TeamFullName = string;
| "ferrari"
| "haas"
| "mclaren"
| "mercedes"
| "redBull"
| "williams";
export type TeamShortName =
| "Alfa Romeo"
| "AlphaTauri"
| "Alpine"
| "Aston Martin"
| "Ferrari"
| "Haas F1 Team"
| "McLaren"
| "Mercedes"
| "Red Bull Racing"
| "Williams";
export type TeamFullName =
| "Alfa Romeo F1 Team ORLEN"
| "Scuderia AlphaTauri"
| "Alpine F1 Team"
| "Aston Martin Cognizant Formula One Team"
| "Scuderia Ferrari"
| "Uralkali Haas F1 Team"
| "McLaren F1 Team"
| "Mercedes-AMG Petronas Formula One Team"
| "Red Bull Racing"
| "Williams Racing";
// Broadcast Director // Broadcast Director
export interface BroadcastDirector { export interface BroadcastDirector {
selectedCars: GridSpot[]; selectedCars: GridSpot[];
/** The car the keyboard cursor is parked on. Never changes on its own. */
cursorGridSpot: Optional<GridSpot>; cursorGridSpot: Optional<GridSpot>;
/** Everything the chyron director controls need to build a chyron. */
chyronSettings: ChyronSettings; chyronSettings: ChyronSettings;
} }
export interface ChyronSettings { export interface ChyronSettings {
@@ -350,17 +263,11 @@ export interface ChyronSettings {
export interface BGBaseState { export interface BGBaseState {
openState: OpenState; openState: OpenState;
} }
/**
* -1 closing, 0 closed, 1 open, 2... different states (for progressive anims)
*/
export type OpenState = number; export type OpenState = number;
export interface BroadcastGraphics { export interface BroadcastGraphics {
timingBoard: BGTimingBoard; timingBoard: BGTimingBoard;
// indicators: BGIndicators
chyrons: Optional<BGChyrons>; chyrons: Optional<BGChyrons>;
// gems: BGGems
// toasts: BGToasts;
} }
// Timing Board // Timing Board
@@ -374,8 +281,8 @@ export interface BGStatusIndicator {
mode: BGStatusIndicatorModes; mode: BGStatusIndicatorModes;
} }
export enum BGStatusIndicatorModes { export enum BGStatusIndicatorModes {
LapNarrow, // "LAP" above "##/##" lap count. LapNarrow,
LapWide, // "LAP" to the left of "##/##" lap count. LapWide,
} }
// Timing Tower // Timing Tower
@@ -393,15 +300,14 @@ export enum BGTimingTowerDisplayMode {
FullLeft, FullLeft,
} }
export enum BGTimingTowerSplitsMode { export enum BGTimingTowerSplitsMode {
Leader, // Leader timing. Leader,
Interval, // Interval timing. Interval,
} }
export enum BGTimingTowerFocusedCarsMode { export enum BGTimingTowerFocusedCarsMode {
None, // When no special treatments are made. None,
Portrait, // When it shows the portrait of the driver. Portrait,
} }
// Chyrons // Chyrons
export type BGChyronMode = string; export type BGChyronMode = string;
export type BGChyronSubMode = string; export type BGChyronSubMode = string;
@@ -412,7 +318,6 @@ export interface BGChyrons extends BGBaseState {
primary: BGChyronDriver; primary: BGChyronDriver;
secondary: Optional<BGChyronDriver>; secondary: Optional<BGChyronDriver>;
} }
// sponsorGem: BGSponsorGem;
} }
export interface BGChyronDriver { export interface BGChyronDriver {
+26 -7
View File
@@ -35,15 +35,34 @@ export const POSITION_SCRIPT_ACTIONS: PositionScriptAction[] = [
export const DEFAULT_POSITION_SCRIPT: PositionScriptFile = { export const DEFAULT_POSITION_SCRIPT: PositionScriptFile = {
autoStart: true, autoStart: true,
initialOrder: [ initialOrder: [
"VER", "HAM", "BOT", "PER", "SAI", "NOR", "LEC", "RIC", "GAS", "ALO", "YLI", "YUZ", "SQI", "LIU", "ZHA", "YWE", "ZHU", "DEN", "WAN", "WHA",
"OCO", "VET", "STR", "TSU", "RUS", "RAI", "LAT", "GIO", "MSC", "MAZ", "PAN", "JWE", "JQI", "LIA", "XIA", "ZLI", "LUG", "HWE", "LIH",
], ],
events: [ events: [
{ at: 5000, action: "swap", drivers: ["HAM", "VER"] }, { at: 30060, action: "move", drivers: ["LUG"], to: 16 },
{ at: 12000, action: "move", drivers: ["LEC"], to: 3 }, { at: 30060, action: "move", drivers: ["ZLI"], to: 17 },
{ at: 18500, action: "lap", drivers: [], value: 1 }, { at: 33010, action: "move", drivers: ["LIU"], to: 3 },
{ at: 24000, action: "retire", drivers: ["MAZ"] }, { at: 33010, action: "move", drivers: ["SQI"], to: 4 },
{ at: 31000, action: "restore", drivers: ["MAZ"] }, { at: 33200, action: "move", drivers: ["ZLI"], to: 18 },
{ at: 33200, action: "move", drivers: ["HWE"], to: 17 },
{ at: 36000, action: "move", drivers: ["XIA"], to: 13 },
{ at: 36000, action: "move", drivers: ["LIA"], to: 14 },
{ at: 39220, action: "move", drivers: ["YUZ"], to: 1 },
{ at: 39220, action: "move", drivers: ["YLI"], to: 2 },
{ at: 39220, action: "move", drivers: ["ZHA"], to: 4 },
{ at: 39220, action: "move", drivers: ["SQI"], to: 5 },
{ at: 47000, action: "move", drivers: ["JQI"], to: 13 },
{ at: 47000, action: "move", drivers: ["XIA"], to: 12 },
{ at: 55000, action: "move", drivers: ["DEN"], to: 7 },
{ at: 55000, action: "move", drivers: ["ZHU"], to: 8 },
{ at: 60210, action: "move", drivers: ["LIU"], to: 2 },
{ at: 60210, action: "move", drivers: ["YLI"], to: 3 },
{ at: 60210, action: "move", drivers: ["YWE"], to: 5 },
{ at: 60210, action: "move", drivers: ["SQI"], to: 6 },
{ at: 67000, action: "move", drivers: ["DEN"], to: 6 },
{ at: 67000, action: "move", drivers: ["SQI"], to: 7 },
{ at: 89040, action: "move", drivers: ["ZHA"], to: 3 },
{ at: 89040, action: "move", drivers: ["YLI"], to: 4 },
], ],
}; };