- Make some more use of the isCardInPlay function.

This commit is contained in:
Sloth
2014-10-17 14:41:24 +00:00
parent cf52edd1bc
commit b2707e9e13
3 changed files with 10 additions and 12 deletions

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}