1.3 KiB
1.3 KiB
2024-12-18 17:35:00 - Strict Rules Engine Implementation
Description
Implemented a comprehensive Magic: The Gathering rules engine (Core Logic) to replace the sandbox mode with strict rules enforcement. This includes a State Machine for Turn Structure, Priority System, Stack, and State-Based Actions.
Key Changes
- Core Types: Created
src/server/game/types.tsdefiningPhase,Step,StrictGameState,StackObject, etc. - Rules Engine: Created
src/server/game/RulesEngine.tsimplementing:- Turn Structure: Untap, Upkeep, Draw, Main, Combat (Steps), End.
- Priority System: Passing priority, stack resolution, phase transition.
- Actions:
playLand,castSpellwith validation. - State-Based Actions: Lethal damage, Zero toughness, Player loss checks.
- Game Manager Refactor:
- Updated
GameManager.tsto useStrictGameState. - Implemented
handleStrictActionto delegate toRulesEngine. - Retained
handleActionfor legacy/sandbox/admin support.
- Updated
- Socket Handling:
- Added
game_strict_actionevent listener inserver/index.ts.
- Added
Next Steps
- Client-side integration: The frontend needs to be updated to visualize the Phases, Stack, and Priority (Pass Button).
- Move from "Sandbox" UI to "Rules Enforcement" UI.