FX2: wire no-moves reshuffle into the UI swipe-commit path

The rendered swipe-commit path (`plan_and_commit`) bypassed the turn-loop's
no-moves rule: a deadlocked board (no legal swap) stayed stuck on screen because
only `play_turn` checked `!has_legal_swap` and reshuffled, and the UI never calls
`play_turn`.

Factor the post-settle "no legal swaps -> reshuffle" check into a shared
`reshuffle_if_deadlocked` in board.sx and call it from BOTH `play_turn` and
`plan_and_commit`, so the animated UI commit obeys the identical model rule. The
reshuffle runs after the cascade settles (post-`commit_swap`); the AnimMove's
recorded `final` stays the settled pre-reshuffle board, so the cascade animation,
per-round audio, and input gating are unchanged — the reshuffled layout renders on
the next settled frame. No win/lose/turn-accounting change; a reshuffle spends no
move and no score.

Regression test tests/swipe_reshuffle.sx drives the exact UI path (swipe_intent ->
plan_and_commit) on the deadlocked board from tests/level.sx: before = no legal
swaps / in_progress; after = reshuffled (has_legal_swap true, 9 legal swaps, no
immediate match), score/moves/budget unchanged. It FAILS pre-fix (board stays
stuck, has_legal_swap false) and PASSES post-fix.
This commit is contained in:
swipelab
2026-06-06 14:55:38 +03:00
parent 2a196943aa
commit cd89a5c9c0
5 changed files with 199 additions and 14 deletions

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1,23 @@
== deadlocked board: UI swipe-commit path must reshuffle ==
ROYGBPRO
PROYGBPR
BPROYGBP
GBPROYGB
YGBPROYG
OYGBPROY
ROYGBPRO
PROYGBPR
before: matches 0 legal_swaps 0 has_legal_swap false status in_progress
intent (0,0)->(1,0)
commit: legal false rounds 0 awarded 0
after: matches 0 legal_swaps 9 has_legal_swap true status in_progress
after: score 0 moves_made 0 moves_remaining 10
BGGYORYR
RRYGOPBY
YRYBPRGB
OOBGBPRG
RPRPYRPO
OBBPOOPG
OBGGOPGY
YPRYBORP
ok: UI swipe-commit path reshuffles a deadlocked board