Add config-driven game host updates

This commit is contained in:
2026-03-25 13:58:51 +08:00
parent f0ced54805
commit d1cc6cc473
28 changed files with 3247 additions and 105 deletions

View File

@@ -20,6 +20,12 @@ export function buildGameDefinitionFromCourse(
autoFinishOnLastControl = true,
punchPolicy: PunchPolicyType = 'enter-confirm',
punchRadiusMeters = 5,
requiresFocusSelection = false,
skipEnabled = false,
skipRadiusMeters = 30,
skipRequiresConfirm = true,
controlScoreOverrides: Record<string, number> = {},
defaultControlScore: number | null = null,
): GameDefinition {
const controls: GameControl[] = []
@@ -31,22 +37,28 @@ export function buildGameDefinitionFromCourse(
kind: 'start',
point: start.point,
sequence: null,
score: null,
displayContent: null,
})
}
for (const control of sortBySequence(course.layers.controls)) {
const label = control.label || String(control.sequence)
const controlId = `control-${control.sequence}`
const score = controlId in controlScoreOverrides
? controlScoreOverrides[controlId]
: defaultControlScore
controls.push({
id: `control-${control.sequence}`,
id: controlId,
code: label,
label,
kind: 'control',
point: control.point,
sequence: control.sequence,
score,
displayContent: {
title: `收集 ${label}`,
body: buildDisplayBody(label, control.sequence),
title: score !== null ? `收集 ${label} (+${score}分)` : `收集 ${label}`,
body: score !== null ? `${buildDisplayBody(label, control.sequence)} · ${score}` : buildDisplayBody(label, control.sequence),
},
})
}
@@ -59,6 +71,7 @@ export function buildGameDefinitionFromCourse(
kind: 'finish',
point: finish.point,
sequence: null,
score: null,
displayContent: null,
})
}
@@ -70,6 +83,10 @@ export function buildGameDefinitionFromCourse(
controlRadiusMeters,
punchRadiusMeters,
punchPolicy,
requiresFocusSelection,
skipEnabled,
skipRadiusMeters,
skipRequiresConfirm,
controls,
autoFinishOnLastControl,
}