From b2707e9e1351257a8cc3e253932b0f19faaafb8c Mon Sep 17 00:00:00 2001 From: Sloth Date: Fri, 17 Oct 2014 14:41:24 +0000 Subject: [PATCH] - Make some more use of the isCardInPlay function. --- .../main/java/forge/ai/AiAttackController.java | 16 +++++++--------- .../main/java/forge/ai/ability/ChangeZoneAi.java | 4 ++-- .../src/main/java/forge/ai/ability/TokenAi.java | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 49da31d94b7..26591449e74 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -310,14 +310,14 @@ public class AiAttackController { final int humanExaltedBonus = this.countExaltedBonus(opp); if (humanExaltedBonus > 0) { - final int nFinestHours = opp.getCardsIn(ZoneType.Battlefield, "Finest Hour").size(); + final boolean finestHour = opp.isCardInPlay("Finest Hour"); - if (((blockersNeeded == 0) || (nFinestHours > 0)) && (this.oppList.size() > 0)) { + if ((blockersNeeded == 0 || finestHour) && !this.oppList.isEmpty()) { // // total attack = biggest creature + exalted, *2 if Rafiq is in // play int humanBasePower = this.getAttack(this.oppList.get(0)) + humanExaltedBonus; - if (nFinestHours > 0) { + if (finestHour) { // For Finest Hour, one creature could attack and get the // bonus TWICE humanBasePower = humanBasePower + humanExaltedBonus; @@ -325,15 +325,13 @@ public class AiAttackController { final int totalExaltedAttack = opp.isCardInPlay("Rafiq of the Many") ? 2 * humanBasePower : humanBasePower; if (ai.getLife() - 3 <= totalExaltedAttack) { - // We will lose if there is an Exalted attack -- keep one - // blocker - if ((blockersNeeded == 0) && (notNeededAsBlockers.size() > 0)) { + // We will lose if there is an Exalted attack -- keep one blocker + if ((blockersNeeded == 0) && !notNeededAsBlockers.isEmpty()) { notNeededAsBlockers.remove(0); } - // Finest Hour allows a second Exalted attack: keep a - // blocker for that too - if ((nFinestHours > 0) && (notNeededAsBlockers.size() > 0)) { + // Finest Hour allows a second Exalted attack: keep a blocker for that too + if (finestHour && !notNeededAsBlockers.isEmpty()) { notNeededAsBlockers.remove(0); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index b8db6eb7ba6..73a57667ed3 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -267,7 +267,7 @@ public class ChangeZoneAi extends SpellAbilityAi { @Override public boolean apply(final Card c) { if (c.getType().isLegendary()) { - if (!ai.getCardsIn(ZoneType.Battlefield, c.getName()).isEmpty()) { + if (ai.isCardInPlay(c.getName())) { return false; } } @@ -1141,7 +1141,7 @@ public class ChangeZoneAi extends SpellAbilityAi { @Override public boolean apply(final Card c) { if (c.getType().isLegendary()) { - if (!decider.getCardsIn(ZoneType.Battlefield, c.getName()).isEmpty()) { + if (decider.isCardInPlay(c.getName())) { return false; } } diff --git a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java index 1cdbdf1c8a6..275e94f119f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java @@ -96,7 +96,7 @@ public class TokenAi extends SpellAbilityAi { for (final String type : this.tokenTypes) { if (type.equals("Legendary")) { // Don't kill AIs Legendary tokens - if (!ai.getCardsIn(ZoneType.Battlefield, this.tokenName).isEmpty()) { + if (ai.isCardInPlay(this.tokenName)) { return false; } }