- 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;
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>();
for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) {
@@ -1698,7 +1704,7 @@ public class CombatUtil {
final HashMap<String, String> trigParams = trigger.getMapParams();
final Card source = trigger.getHostCard();
if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, null)
if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, combat)
|| !trigParams.containsKey("Execute")) {
continue;
}
@@ -1757,7 +1763,7 @@ public class CombatUtil {
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)
/**
* <p>
@@ -1775,6 +1781,13 @@ public class CombatUtil {
public static int predictToughnessBonusOfAttacker(final Card attacker, final Card defender, final Combat combat) {
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>();
for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) {
theTriggers.addAll(card.getTriggers());
@@ -1816,7 +1829,7 @@ public class CombatUtil {
final HashMap<String, String> trigParams = trigger.getMapParams();
final Card source = trigger.getHostCard();
if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, null)
if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, combat)
|| !trigParams.containsKey("Execute")) {
continue;
}
@@ -1888,7 +1901,6 @@ public class CombatUtil {
bonus = bonus.replace("TriggerCount$NumBlockers", "Number$1");
}
toughness += CardFactoryUtil.xCount(source, bonus);
}
}
return toughness;

View File

@@ -548,19 +548,15 @@ public class ComputerUtilAttack {
}
}
if (exalted) {
Card att = CardFactoryUtil.getBestCreatureAI(attackersLeft);
CardListUtil.sortAttack(this.attackers);
System.out.println("Exalted");
this.aiAggression = 3;
for (Card attacker : this.attackers) {
if (!CombatUtil.canBeBlocked(attacker, this.blockers)) {
att = attacker;
break;
if (CombatUtil.canAttack(attacker, combat) && this.shouldAttack(attacker, this.blockers, combat)) {
combat.addAttacker(attacker);
return combat;
}
}
if ((att != null) && CombatUtil.canAttack(att, combat)) {
combat.addAttacker(att);
System.out.println("Exalted");
return combat;
}
}
}
@@ -894,7 +890,8 @@ public class ComputerUtilAttack {
&& numberOfPossibleBlockers == 1)) {
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
// choice in aiAggression
switch (this.aiAggression) {