Add score-o mode and split game map HUD presentation

This commit is contained in:
2026-03-24 12:27:45 +08:00
parent a117a25824
commit 0295893b56
18 changed files with 1121 additions and 113 deletions

View File

@@ -42,7 +42,7 @@ export interface RemoteMapConfig {
course: OrienteeringCourseData | null
courseStatusText: string
cpRadiusMeters: number
gameMode: 'classic-sequential'
gameMode: 'classic-sequential' | 'score-o'
punchPolicy: 'enter' | 'enter-confirm'
punchRadiusMeters: number
autoFinishOnLastControl: boolean
@@ -57,7 +57,7 @@ interface ParsedGameConfig {
mapMeta: string
course: string | null
cpRadiusMeters: number
gameMode: 'classic-sequential'
gameMode: 'classic-sequential' | 'score-o'
punchPolicy: 'enter' | 'enter-confirm'
punchRadiusMeters: number
autoFinishOnLastControl: boolean
@@ -209,6 +209,23 @@ function parsePunchPolicy(rawValue: unknown): 'enter' | 'enter-confirm' {
return rawValue === 'enter' ? 'enter' : 'enter-confirm'
}
function parseGameMode(rawValue: unknown): 'classic-sequential' | 'score-o' {
if (typeof rawValue !== 'string') {
return 'classic-sequential'
}
const normalized = rawValue.trim().toLowerCase()
if (normalized === 'classic-sequential' || normalized === 'classic' || normalized === 'sequential') {
return 'classic-sequential'
}
if (normalized === 'score-o' || normalized === 'scoreo' || normalized === 'score') {
return 'score-o'
}
throw new Error(`暂不支持的 game.mode: ${rawValue}`)
}
function parseTelemetryConfig(rawValue: unknown): TelemetryConfig {
const normalized = normalizeObjectRecord(rawValue)
if (!Object.keys(normalized).length) {
@@ -679,11 +696,8 @@ function parseGameConfigFromJson(text: string, gameConfigUrl: string): ParsedGam
throw new Error('game.json 缺少 map 或 mapmeta 字段')
}
const gameMode = 'classic-sequential' as const
const modeValue = typeof normalizedGame.mode === 'string' ? normalizedGame.mode : normalized.gamemode
if (typeof modeValue === 'string' && modeValue !== gameMode) {
throw new Error(`暂不支持的 game.mode: ${modeValue}`)
}
const gameMode = parseGameMode(modeValue)
return {
mapRoot,
@@ -738,10 +752,7 @@ function parseGameConfigFromYaml(text: string, gameConfigUrl: string): ParsedGam
throw new Error('game.yaml 缺少 map 或 mapmeta 字段')
}
const gameMode = 'classic-sequential' as const
if (config.gamemode && config.gamemode !== gameMode) {
throw new Error(`暂不支持的 game.mode: ${config.gamemode}`)
}
const gameMode = parseGameMode(config.gamemode)
return {
mapRoot,