Summary
Update checkGameEnd() in BeleagueredCastleScene.ts to use hasValuableMoves() instead of (or in addition to) hasNoMoves() for loss detection. If there are legal moves but none of them are valuable, the game should end just as it does when there are no legal moves at all.
Implementation Approach
- Import the new
hasValuableMoves function from BeleagueredCastleRules.ts.
- In
checkGameEnd(), change the loss condition from hasNoMoves(state) to !hasValuableMoves(state) (which already handles the case when there are zero moves, since that also means no valuable moves).
- Alternatively, keep
hasNoMoves and add an additional condition: hasNoMoves(state) || !hasValuableMoves(state).
- The overlay message should still be appropriate ('No Moves Available' or similar -- could be updated to 'No Useful Moves' but this is optional).
- Ensure transcript finalization records the correct outcome ('loss').
Note: The isTriviallyWinnable check happens before the loss check. If the game is trivially winnable, auto-complete starts. The valuable moves check only matters for the loss branch.
Acceptance Criteria
- Game ends when only non-valuable moves remain (same as no moves)
- Win detection and auto-complete detection are unaffected
- Overlay, transcript finalization, and game-ended event fire correctly
- Undo from the no-moves overlay still works (restores previous state)
Summary
Update
checkGameEnd()inBeleagueredCastleScene.tsto usehasValuableMoves()instead of (or in addition to)hasNoMoves()for loss detection. If there are legal moves but none of them are valuable, the game should end just as it does when there are no legal moves at all.Implementation Approach
hasValuableMovesfunction fromBeleagueredCastleRules.ts.checkGameEnd(), change the loss condition fromhasNoMoves(state)to!hasValuableMoves(state)(which already handles the case when there are zero moves, since that also means no valuable moves).hasNoMovesand add an additional condition:hasNoMoves(state) || !hasValuableMoves(state).Note: The
isTriviallyWinnablecheck happens before the loss check. If the game is trivially winnable, auto-complete starts. The valuable moves check only matters for the loss branch.Acceptance Criteria