- Expanded use of dealsFirstStrikeDamage AI function.

This commit is contained in:
Sloth
2014-04-13 19:32:23 +00:00
parent d1598fbd72
commit 9bb6a6477b

View File

@@ -744,10 +744,10 @@ public class ComputerUtilCombat {
// if the attacker has first strike and wither the blocker will deal // if the attacker has first strike and wither the blocker will deal
// less damage than expected // less damage than expected
if (ComputerUtilCombat.dealsFirstStrikeDamage(attacker, withoutAbilities) if (dealsFirstStrikeDamage(attacker, withoutAbilities)
&& (attacker.hasKeyword("Wither") || attacker.hasKeyword("Infect")) && (attacker.hasKeyword("Wither") || attacker.hasKeyword("Infect"))
&& !(blocker.hasKeyword("First Strike") || blocker.hasKeyword("Double Strike") || blocker && !dealsFirstStrikeDamage(blocker, withoutAbilities)
.hasKeyword("CARDNAME can't have counters placed on it."))) { && !blocker.hasKeyword("CARDNAME can't have counters placed on it.")) {
power -= attacker.getNetCombatDamage(); power -= attacker.getNetCombatDamage();
} }
@@ -1065,8 +1065,8 @@ public class ComputerUtilCombat {
if (null != blocker) { if (null != blocker) {
if (ComputerUtilCombat.dealsFirstStrikeDamage(blocker, withoutAbilities) if (ComputerUtilCombat.dealsFirstStrikeDamage(blocker, withoutAbilities)
&& (blocker.hasKeyword("Wither") || blocker.hasKeyword("Infect")) && (blocker.hasKeyword("Wither") || blocker.hasKeyword("Infect"))
&& !(attacker.hasKeyword("First Strike") || attacker.hasKeyword("Double Strike") || attacker && !ComputerUtilCombat.dealsFirstStrikeDamage(attacker, withoutAbilities)
.hasKeyword("CARDNAME can't have counters placed on it."))) { && !attacker.hasKeyword("CARDNAME can't have counters placed on it.")) {
power -= blocker.getNetCombatDamage(); power -= blocker.getNetCombatDamage();
} }
theTriggers.addAll(blocker.getTriggers()); theTriggers.addAll(blocker.getTriggers());
@@ -1614,7 +1614,8 @@ public class ComputerUtilCombat {
else { // no double strike for defender else { // no double strike for defender
// Attacker may kill the blocker before he can deal any damage // Attacker may kill the blocker before he can deal any damage
if (dealsFirstStrikeDamage(attacker, withoutAbilities) if (dealsFirstStrikeDamage(attacker, withoutAbilities)
&& !defender.hasKeyword("Indestructible") && !defender.hasKeyword("First Strike")) { && !defender.hasKeyword("Indestructible")
&& !dealsFirstStrikeDamage(defender, withoutAbilities)) {
if (attackerDamage >= defenderLife) { if (attackerDamage >= defenderLife) {
return false; return false;
@@ -2093,25 +2094,35 @@ public class ComputerUtilCombat {
} }
if (!withoutAbilities) { if (!withoutAbilities) {
for (SpellAbility ability : combatant.getAllSpellAbilities()) { List<String> keywords = new ArrayList<String>();
if (!(ability instanceof AbilityActivated) || ability.getPayCosts() == null) { keywords.add("Double Strike");
continue; keywords.add("First Strike");
} return canGainKeyword(combatant, keywords);
if (ability.getApi() != ApiType.Pump) { }
continue;
}
if (ability.hasParam("ActivationPhases") || ability.hasParam("SorcerySpeed")) { return false;
continue; }
}
if (!ability.hasParam("KW")) { public final static boolean canGainKeyword(final Card combatant, final List<String> keywords) {
continue; for (SpellAbility ability : combatant.getAllSpellAbilities()) {
} if (!(ability instanceof AbilityActivated) || ability.getPayCosts() == null) {
continue;
}
if (ability.getApi() != ApiType.Pump) {
continue;
}
if (ability.getParam("KW").contains("First Strike") && ComputerUtilCost.canPayCost(ability, combatant.getController())) { if (ability.hasParam("ActivationPhases") || ability.hasParam("SorcerySpeed")) {
return true; continue;
} }
if (!ability.hasParam("KW") || !ComputerUtilCost.canPayCost(ability, combatant.getController())) {
continue;
}
for (String keyword : keywords) {
if (ability.getParam("KW").contains(keyword)) {
return true;
}
} }
} }