1.2 KiB
1.2 KiB
2024-12-18 - Fix Initial Draw Logic
Problem
The user reported that upon entering the game and being prompted to Mulligan, their hand was empty. This prevented them from making an informed decision.
Root Cause
The GameManager initialized the game state with step: 'mulligan', but the RulesEngine was never invoked to perform the initial turn-based actions (specifically the initial draw). The cards were added to the library zone, but no logic moved them to the hand zone before the game start update was sent to the client.
Solution
- Updated
RulesEngine.ts: Added a publicstartGame()method that logs the start and callsperformTurnBasedActions().performTurnBasedActions()already contained the logic to draw 7 cards if the step is 'mulligan' and the hand is empty. - Updated
server/index.ts: Modified all game initialization flows (player_ready,start_solo_test,start_game, and the global timer loop) to instantiate aRulesEngineand callstartGame()immediately after populating the deck cards.
outcome
When a game starts, the server now proactively triggers the initial draw logic. Clients receive the initial game state with 7 cards in hand, allowing the Mulligan UI to display the cards correctly.