- Improved AI handling of Exalted (it now uses all the CombatUtil functions).

This commit is contained in:
Sloth
2012-07-20 16:30:20 +00:00
parent dec5537e6b
commit 3c652ebf15
2 changed files with 23 additions and 14 deletions

View File

@@ -1649,6 +1649,12 @@ public class CombatUtil {
int power = 0; int power = 0;
power += attacker.getKeywordMagnitude("Bushido"); power += attacker.getKeywordMagnitude("Bushido");
//check Exalted only for the first attacker
if (combat != null && combat.getAttackers().isEmpty()) {
for (Card card : attacker.getController().getCardsIn(ZoneType.Battlefield)) {
power += card.getKeywordAmount("Exalted");
}
}
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>(); final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) {
@@ -1698,7 +1704,7 @@ public class CombatUtil {
final HashMap<String, String> trigParams = trigger.getMapParams(); final HashMap<String, String> trigParams = trigger.getMapParams();
final Card source = trigger.getHostCard(); final Card source = trigger.getHostCard();
if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, null) if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, combat)
|| !trigParams.containsKey("Execute")) { || !trigParams.containsKey("Execute")) {
continue; continue;
} }
@@ -1757,7 +1763,7 @@ public class CombatUtil {
return power; return power;
} }
// Predict the Toughness bonus of the blocker if blocking the attacker // Predict the Toughness bonus of the attacker if blocked by the blocker
// (Flanking, Bushido and other triggered abilities) // (Flanking, Bushido and other triggered abilities)
/** /**
* <p> * <p>
@@ -1775,6 +1781,13 @@ public class CombatUtil {
public static int predictToughnessBonusOfAttacker(final Card attacker, final Card defender, final Combat combat) { public static int predictToughnessBonusOfAttacker(final Card attacker, final Card defender, final Combat combat) {
int toughness = 0; int toughness = 0;
//check Exalted only for the first attacker
if (combat != null && combat.getAttackers().isEmpty()) {
for (Card card : attacker.getController().getCardsIn(ZoneType.Battlefield)) {
toughness += card.getKeywordAmount("Exalted");
}
}
final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>(); final ArrayList<Trigger> theTriggers = new ArrayList<Trigger>();
for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers()); theTriggers.addAll(card.getTriggers());
@@ -1816,7 +1829,7 @@ public class CombatUtil {
final HashMap<String, String> trigParams = trigger.getMapParams(); final HashMap<String, String> trigParams = trigger.getMapParams();
final Card source = trigger.getHostCard(); final Card source = trigger.getHostCard();
if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, null) if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, combat)
|| !trigParams.containsKey("Execute")) { || !trigParams.containsKey("Execute")) {
continue; continue;
} }
@@ -1888,7 +1901,6 @@ public class CombatUtil {
bonus = bonus.replace("TriggerCount$NumBlockers", "Number$1"); bonus = bonus.replace("TriggerCount$NumBlockers", "Number$1");
} }
toughness += CardFactoryUtil.xCount(source, bonus); toughness += CardFactoryUtil.xCount(source, bonus);
} }
} }
return toughness; return toughness;

View File

@@ -548,21 +548,17 @@ public class ComputerUtilAttack {
} }
} }
if (exalted) { if (exalted) {
Card att = CardFactoryUtil.getBestCreatureAI(attackersLeft);
CardListUtil.sortAttack(this.attackers); CardListUtil.sortAttack(this.attackers);
for (Card attacker : this.attackers) {
if (!CombatUtil.canBeBlocked(attacker, this.blockers)) {
att = attacker;
break;
}
}
if ((att != null) && CombatUtil.canAttack(att, combat)) {
combat.addAttacker(att);
System.out.println("Exalted"); System.out.println("Exalted");
this.aiAggression = 3;
for (Card attacker : this.attackers) {
if (CombatUtil.canAttack(attacker, combat) && this.shouldAttack(attacker, this.blockers, combat)) {
combat.addAttacker(attacker);
return combat; return combat;
} }
} }
} }
}
// ******************* // *******************
// Evaluate the creature forces // Evaluate the creature forces
@@ -894,7 +890,8 @@ public class ComputerUtilAttack {
&& numberOfPossibleBlockers == 1)) { && numberOfPossibleBlockers == 1)) {
canBeBlocked = true; canBeBlocked = true;
} }
/*System.out.println(attacker + " canBeKilledByOne: " + canBeKilledByOne + " canKillAll: "
+ canKillAll + " isWorthLessThanAllKillers: " + isWorthLessThanAllKillers + " canBeBlocked: " + canBeBlocked);*/
// decide if the creature should attack based on the prevailing strategy // decide if the creature should attack based on the prevailing strategy
// choice in aiAggression // choice in aiAggression
switch (this.aiAggression) { switch (this.aiAggression) {