This commit is contained in:
2026-10-18 01:38:02 +07:00
parent 7f2a02b69f
commit b591287072
16 changed files with 1308 additions and 52 deletions
+23
View File
@@ -11,6 +11,7 @@ import type {
State,
ScreenMode,
TimerState,
ScreenStep,
} from '../src/types/screen.js'
import { parseResults } from './results.js'
import type { LocalPackage } from './package-store.js'
@@ -345,6 +346,28 @@ export class Controller {
this.timerDeadline = timer.status === 'running' ? this.now() + timer.remainingMs : null
this.broadcast()
}
setPlan(steps: ScreenStep[]) {
if (isDeepStrictEqual(steps, this.state.catalog.steps)) return
const index = this.state.scene.stepIndex
const old = index === null ? null : this.state.catalog.steps[index]
this.state.catalog.steps = structuredClone(steps)
if (index !== null && !isDeepStrictEqual(old, steps[index])) this.state.scene.stepIndex = null
this.broadcast()
}
markStep(index: number) {
const step = this.state.catalog.steps[index]
const scene = this.state.scene
if (!step || step.mode !== scene.mode || (step.mode === 8 && step.text !== scene.text)) return
if (
step.mode === 7 &&
(step.timerLabel !== this.state.timer.label ||
step.timerDurationSeconds * 1000 !== this.state.timer.durationMs)
)
return
if (scene.stepIndex === index) return
scene.stepIndex = index
this.broadcast()
}
setResults(value: unknown) {
const key = this.state.catalog.key
if (value !== null && !key) throw new Error('Сначала выберите пакет игры')