- Check if creatures in combat are actually still creatures during state checks

This commit is contained in:
Sol
2014-03-19 01:34:18 +00:00
parent e67a152654
commit 6c747b5857
2 changed files with 12 additions and 8 deletions

View File

@@ -874,6 +874,9 @@ public class GameAction {
// 704.5m World rule // 704.5m World rule
checkAgain |= this.handleWorldRule(); checkAgain |= this.handleWorldRule();
if (game.getCombat() != null)
game.getCombat().removeAbsentCombatants();
if (!checkAgain) { if (!checkAgain) {
break; // do not continue the loop break; // do not continue the loop
} }

View File

@@ -378,26 +378,27 @@ public class Combat {
public final void removeAbsentCombatants() { public final void removeAbsentCombatants() {
// iterate all attackers and remove them // iterate all attackers and remove them
List<Card> missingCombatants = new ArrayList<>();
for(Entry<GameEntity, AttackingBand> ee : attackedByBands.entries()) { for(Entry<GameEntity, AttackingBand> ee : attackedByBands.entries()) {
List<Card> atk = ee.getValue().getAttackers(); List<Card> atk = ee.getValue().getAttackers();
for(int i = atk.size() - 1; i >= 0; i--) { // might remove items from collection, so no iterators for(int i = atk.size() - 1; i >= 0; i--) { // might remove items from collection, so no iterators
Card c = atk.get(i); Card c = atk.get(i);
if ( !c.isInPlay() ) { if ( !c.isInPlay() || !c.isCreature() ) {
unregisterAttacker(c, ee.getValue()); missingCombatants.add(c);
} }
} }
} }
Collection<Card> toRemove = Lists.newArrayList(); Collection<Card> toRemove = Lists.newArrayList();
for(Entry<AttackingBand, Card> be : blockedBands.entries()) { for(Entry<AttackingBand, Card> be : blockedBands.entries()) {
if ( !be.getValue().isInPlay() ) { Card blocker = be.getValue();
unregisterDefender(be.getValue(), be.getKey()); if ( !blocker.isInPlay() || !blocker.isCreature() ) {
toRemove.add(be.getValue()); missingCombatants.add(blocker);
} }
} }
blockedBands.values().removeAll(toRemove); for (Card c : missingCombatants)
removeFromCombat(c);
} // verifyCreaturesInPlay() }
// Call this method right after turn-based action of declare blockers has been performed // Call this method right after turn-based action of declare blockers has been performed