- Cleanup of two functions using predictThreatenedObjects.

This commit is contained in:
Sloth
2015-09-28 22:10:19 +00:00
parent f7c93e5ed2
commit 94cf3886b8
2 changed files with 6 additions and 8 deletions

View File

@@ -14,6 +14,7 @@ import forge.ai.ComputerUtilCost;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.card.MagicColor; import forge.card.MagicColor;
import forge.game.Game; import forge.game.Game;
import forge.game.GameObject;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
import forge.game.ability.ApiType; import forge.game.ability.ApiType;
import forge.game.ability.effects.ProtectEffect; import forge.game.ability.effects.ProtectEffect;
@@ -110,6 +111,7 @@ public class ProtectAi extends SpellAbilityAi {
final PhaseHandler ph = game.getPhaseHandler(); final PhaseHandler ph = game.getPhaseHandler();
CardCollection list = ai.getCreaturesInPlay(); CardCollection list = ai.getCreaturesInPlay();
final List<GameObject> threatenedObjects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
list = CardLists.filter(list, new Predicate<Card>() { list = CardLists.filter(list, new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
@@ -122,12 +124,9 @@ public class ProtectAi extends SpellAbilityAi {
return false; return false;
} }
if (!game.stack.isEmpty()) { if (threatenedObjects.contains(c)) {
//counter bad effect on stack
if (ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(c)) {
return true; return true;
} }}
}
if (combat != null) { if (combat != null) {
//creature is blocking and would be destroyed itself //creature is blocking and would be destroyed itself

View File

@@ -139,12 +139,11 @@ public class PumpAllAi extends PumpAiBase {
boolean pumpAgainstRemoval(Player ai, SpellAbility sa, List<Card> comp) { boolean pumpAgainstRemoval(Player ai, SpellAbility sa, List<Card> comp) {
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa); final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
final List<Card> threatenedTargets = new ArrayList<Card>();
for (final Card c : comp) { for (final Card c : comp) {
if (objects.contains(c)) { if (objects.contains(c)) {
threatenedTargets.add(c); return true;
} }
} }
return !threatenedTargets.isEmpty(); return false;
} }
} }