Add ability to roll back the last N plays, useful for correcting mistakes or recovering from corrupted plays. Deletes plays from database and reconstructs game state by replaying remaining plays. Database Operations (app/database/operations.py): - delete_plays_after(): Delete plays with play_number > target - delete_substitutions_after(): Delete lineup entries with after_play >= target - delete_rolls_after(): Delete dice rolls (kept for reference, not used) Game Engine (app/core/game_engine.py): - rollback_plays(): Main rollback orchestration - Validates: num_plays > 0, enough plays exist, game not completed - Deletes plays and substitutions from database - Clears in-memory roll tracking - Calls state_manager.recover_game() to rebuild state - Returns updated GameState Terminal Client (terminal_client/commands.py, terminal_client/repl.py): - rollback_plays(): Command wrapper with user-friendly output - do_rollback(): REPL command with argument parsing Usage: ⚾ > rollback 3 Validations: - Cannot roll back more plays than exist - Cannot roll back completed games - Rolling back across innings is allowed - Substitutions after rolled-back plays are undone Testing: - ✅ Successfully rolls back 2 plays from 5-play game - ✅ Correctly validates rollback of 10 plays when only 2 exist - ✅ Game state properly reconstructed via replay Note: Dice rolls kept in database for auditing (don't affect state). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| api | ||
| config | ||
| core | ||
| database | ||
| models | ||
| utils | ||
| websocket | ||
| __init__.py | ||
| config.py | ||
| main.py | ||