clone

a browser grid puzzle game where you push words around to rewrite the rules of each level

Open initial Win after proof scene handoff

Dami committed 5c49232
commit
5c49232565d1183a48881a71d5d01e5fcd778be1
parent
1a04d702cea64778065807e87bad5077f4deb07d
author
Dami <dami.etoile@gmail.com>
2 files changed, +17 -3
Mopenspec/changes/animate-stage-motion-language/specs/game-stage/spec.md4++++
Msrc/main.js16+++++++++++++---
M openspec/changes/animate-stage-motion-language/specs/game-stage/spec.md +4 -0
M src/main.js +13 -3
@@ -204,13 +204,23 @@ function scheduleInitialWin() {
204204 presentationClock.clearTimeout(winTimer);205205 if (!game?.getState().won) return;206206 const level = currentLevels()[levelNo];207+ const expectedGame = game;208+ const expectedLevelId = level?.id;207209 if (level?.packId && level?.localId) {208210 progress.markSolved(level.packId, level.localId);209211 refreshIndex(level.id);210212 }211- winTimer = presentationClock.setTimeout(() => {212- if (game?.getState().won && stage.scene === 'proof') stage.show('win', { steps: game.getState().moves, nodeId: level?.id, instant: true });213- }, 0);213+ const promote = () => {214+ if (game !== expectedGame || currentLevels()[levelNo]?.id !== expectedLevelId || !game?.getState().won) return;215+ if (stage.scene === 'proof') {216+ stage.show('win', { steps: game.getState().moves, nodeId: expectedLevelId, instant: true });217+ return;218+ }219+ // Index → proof has a 280ms scene exit. Retry after that visual handoff;220+ // the timer is presentation-clock based, so slowmo timing is preserved.221+ if (stage.scene === 'index-exiting') winTimer = presentationClock.setTimeout(promote, 280);222+ };223+ winTimer = presentationClock.setTimeout(promote, 0);214224 }215225 function paintBoardFrame(now = presentationClock.now()) { stage.setBoard(displayState(),game,activePalette(),glyphs,juice.frame(now)); }216226 function animateBoard(duration = 650) { animationDeadline = Math.max(animationDeadline,presentationClock.now()+duration); if (animationRequest) return; const tick = now => { animationRequest=0; if (stage.scene === 'proof' || stage.scene === 'win') paintBoardFrame(now); if (now < animationDeadline) animationRequest=presentationClock.requestAnimationFrame(tick); }; animationRequest=presentationClock.requestAnimationFrame(tick); }