- Added the function removeAll to CardList to remove all instances of a card from it (I was shocked that we didn't have this, or am I missing something?).

- Fixed some possible bugs of assigning blockers twice in ComputerUtil_Block2.
This commit is contained in:
Sloth
2011-08-24 21:11:45 +00:00
parent 20c45c1441
commit de68a3b258
2 changed files with 13 additions and 2 deletions

View File

@@ -574,6 +574,17 @@ public class CardList implements Iterable<Card> {
public void remove(Card c) {
list.remove(c);
}
/**
* <p>removeAll.</p>
*
* @param c a {@link forge.Card} object.
*/
public void removeAll(Card c) {
ArrayList<Card> cList = new ArrayList<Card>();
cList.add(c);
list.removeAll(cList);
}
/**
* <p>clear.</p>

View File

@@ -505,7 +505,7 @@ public class ComputerUtil_Block2 {
&& CardFactoryUtil.evaluateCreature(blocker) + getDiff() < CardFactoryUtil.evaluateCreature(attacker)
&& CombatUtil.canBlock(attacker, blocker, combat)) {
combat.addBlocker(attacker, blocker);
getBlockersLeft().remove(blocker);
getBlockersLeft().removeAll(blocker);
}
}
}
@@ -630,7 +630,7 @@ public class ComputerUtil_Block2 {
for (Card blocker : blockers) {
if (CombatUtil.canBlock(attacker, blocker, combat)) {
combat.addBlocker(attacker, blocker);
getBlockersLeft().remove(blocker);
getBlockersLeft().removeAll(blocker);
}
}
}