Skip to content

Integrate hasValuableMoves into game-over detection in the scene #400

@SorraTheOrc

Description

@SorraTheOrc

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

  1. Import the new hasValuableMoves function from BeleagueredCastleRules.ts.
  2. 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).
  3. Alternatively, keep hasNoMoves and add an additional condition: hasNoMoves(state) || !hasValuableMoves(state).
  4. The overlay message should still be appropriate ('No Moves Available' or similar -- could be updated to 'No Useful Moves' but this is optional).
  5. 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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions