- 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
checkAgain |= this.handleWorldRule();
if (game.getCombat() != null)
game.getCombat().removeAbsentCombatants();
if (!checkAgain) {
break; // do not continue the loop
}

View File

@@ -378,26 +378,27 @@ public class Combat {
public final void removeAbsentCombatants() {
// iterate all attackers and remove them
List<Card> missingCombatants = new ArrayList<>();
for(Entry<GameEntity, AttackingBand> ee : attackedByBands.entries()) {
List<Card> 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<Card> toRemove = Lists.newArrayList();
for(Entry<AttackingBand, Card> 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