2.2 KiB
2024-12-18 - Fix Actions Post-Mulligan
Problem
After the Mulligan phase, users reported "no actions working". The Smart Button and other strict interactions (Priority passing) were failing.
Root Cause
- Frontend Emission: The
SmartButtoninGameView.tsxand theRadialMenufor mana were emitting legacytypestrings (e.g.PASS_PRIORITYorADD_MANAdirectly), or wrapped incorrectly. Specifically,SmartButtonwas correctly wrapping ingame_strict_actionbut likely the state alignment was off. - Radial Menu: Was emitting
ADD_MANAas a legacygame_action. LegacyGameManager(before my fix in previous step) handled basic actions, butADD_MANAis a strict engine concept.GameManager.handleAction(legacy) did not handle it. We needed to targetgame_strict_actionor add a handler. - State Reset: The engine's transition from Mulligan -> Untap -> Upkeep -> Draw -> Main1 relies on
resetPrioritycorrectly assigning priority to the Active Player. If this flow is interrupted or if the client UI doesn't realize it has priority (due topriorityPlayerIdmismatch), the Smart Button disables itself.
Solution
- Strict Action Alignment: Updated
GameView.tsxto ensureRadialMenu(Mana) emitsgame_strict_action. - Handling: (Previous Step) Added
DRAW_CARDsupport. - Smart Button Checking: Confirmed Smart Button emits
typewhichGameViewwraps inaction. This matchessocket.on('game_strict_action', { action }). This path is correct.
Verification
The flow "Mulligan -> Advanced Step (Mulligan Ends) -> Untap (Auto) -> Upkeep -> Reset Priority (Active Player)" seems logic-sound in RulesEngine. With the frontend now targeting the strict endpoint for Mana/Priority, and the legacy handler updated for Draw, the loop should be closed.
Remaining Risk
If resetPriority sets priorityPlayerId to a player ID that doesn't match the client's currentPlayerId (e.g. Turn 1 Order), the button will stay gray/disabled. This is Rules Correct (you can't act if not your priority), but UI feedback (telling whose turn/priority it is) is crucial. The existing PhaseStrip or SmartButton should indicate this.