Better fix for that concurrent modification exception. Don't know what I was thinking.

This commit is contained in:
Krazy
2015-05-25 03:35:40 +00:00
parent 7f060a0b1f
commit 5a4959e59d

View File

@@ -29,9 +29,7 @@ import forge.game.trigger.Trigger;
import forge.game.trigger.TriggerType; import forge.game.trigger.TriggerType;
import forge.util.FCollectionView; import forge.util.FCollectionView;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
/** /**
@@ -117,14 +115,17 @@ public class AiBlockController {
ComputerUtilCard.sortByEvaluateCreature(attackers); ComputerUtilCard.sortByEvaluateCreature(attackers);
CardLists.sortByPowerDesc(attackers); CardLists.sortByPowerDesc(attackers);
//move cards like Phage the Untouchable to the front //move cards like Phage the Untouchable to the front
List<Card> prioritizedAttackers = new ArrayList<>(); Collections.sort(attackers, new Comparator<Card>() {
for (Card attacker : attackers) { @Override
if (attacker.hasSVar("MustBeBlocked")) { public int compare(final Card o1, final Card o2) {
prioritizedAttackers.add(attacker); if (o1.hasSVar("MustBeBlocked") && !o2.hasSVar("MustBeBlocked")) {
} return -1;
} } else if (!o1.hasSVar("MustBeBlocked") && o2.hasSVar("MustBeBlocked")) {
attackers.removeAll((Iterable<Card>) prioritizedAttackers); return 1;
attackers.addAll(0, prioritizedAttackers); }
return 0;
}
});
return attackers; return attackers;
} }