From 6c747b5857ebe936527b522355c7ecbdeb76d6f9 Mon Sep 17 00:00:00 2001 From: Sol Date: Wed, 19 Mar 2014 01:34:18 +0000 Subject: [PATCH] - Check if creatures in combat are actually still creatures during state checks --- .../src/main/java/forge/game/GameAction.java | 3 +++ .../src/main/java/forge/game/combat/Combat.java | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index ab717c1497f..99ea1651838 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -874,6 +874,9 @@ public class GameAction { // 704.5m World rule checkAgain |= this.handleWorldRule(); + if (game.getCombat() != null) + game.getCombat().removeAbsentCombatants(); + if (!checkAgain) { break; // do not continue the loop } diff --git a/forge-game/src/main/java/forge/game/combat/Combat.java b/forge-game/src/main/java/forge/game/combat/Combat.java index 029a036c9ca..9f35f12260d 100644 --- a/forge-game/src/main/java/forge/game/combat/Combat.java +++ b/forge-game/src/main/java/forge/game/combat/Combat.java @@ -378,26 +378,27 @@ public class Combat { public final void removeAbsentCombatants() { // iterate all attackers and remove them + List missingCombatants = new ArrayList<>(); for(Entry ee : attackedByBands.entries()) { List atk = ee.getValue().getAttackers(); for(int i = atk.size() - 1; i >= 0; i--) { // might remove items from collection, so no iterators Card c = atk.get(i); - if ( !c.isInPlay() ) { - unregisterAttacker(c, ee.getValue()); + if ( !c.isInPlay() || !c.isCreature() ) { + missingCombatants.add(c); } } } Collection toRemove = Lists.newArrayList(); for(Entry be : blockedBands.entries()) { - if ( !be.getValue().isInPlay() ) { - unregisterDefender(be.getValue(), be.getKey()); - toRemove.add(be.getValue()); + Card blocker = be.getValue(); + if ( !blocker.isInPlay() || !blocker.isCreature() ) { + missingCombatants.add(blocker); } } - blockedBands.values().removeAll(toRemove); - - } // verifyCreaturesInPlay() + for (Card c : missingCombatants) + removeFromCombat(c); + } // Call this method right after turn-based action of declare blockers has been performed