Files
mtg-online-drafter/docs/development/devlog/2024-12-18-192500_fix_combat_skip.md
2025-12-18 20:26:42 +01:00

1.5 KiB

2024-12-18 - Fix Combat Skip Logic

Problem

The user could not "Skip Combat" (Move past Declare Attackers). The button action DECLARE_ATTACKERS with 0 attackers was working server-side (resetting priority to AP), but the client UI (SmartButton) remained stuck on "Skip Combat". This created a loop where the user clicked, action processed, priority returned, and the UI still asked them to declare attackers.

Root Cause

The SmartButton logic relied solely on gameState.step === 'declare_attackers'. It did not differentiate between "Need to Declare" (Start of Step) and "After Declaration / Priority Window" (Middle of Step). Strict Rules State did not have a flag to indicate if the Turn-Based Action of declaring attackers had already occurred for the current step.

Solution

  1. Updated Types: Added optional attackersDeclared (and blockersDeclared) boolean flags to StrictGameState (Server + Client).
  2. Updated RulesEngine: In declareAttackers(), set attackersDeclared = true. In cleanupStep(), reset these flags to false.
  3. Updated SmartButton: Added a check. If step === 'declare_attackers' AND attackersDeclared is true, display "Pass (to Blockers)" with PASS_PRIORITY action instead of "Skip Combat" / DECLARE_ATTACKERS.

Outcome

When a user clicks "Skip Combat" (declares 0 attackers), the server updates the state flag. The UI then updates to show a "Pass" button, allowing the user to proceed to the next step.