- another update of AI blocking.

This commit is contained in:
jendave
2011-08-06 12:33:57 +00:00
parent 35a1b9a265
commit 1b54b42783

View File

@@ -467,6 +467,31 @@ public class CombatUtil {
return n;
}
//Returns the damage unblocked attackers would deal
private static int sumAttack(CardList attackers)
{
int sum = 0;
for(int i = 0; i < attackers.size(); i++) {
Card a = attackers.get(i);
if (!a.hasKeyword("Infect")) sum += getAttack(a);
}
return sum;
}
//Returns the number of poison counters unblocked attackers would deal
private static int sumPoison(CardList attackers)
{
int sum = 0;
for(int i = 0; i < attackers.size(); i++) {
Card a = attackers.get(i);
if (a.hasKeyword("Infect")) sum += getAttack(a);
if (a.hasKeyword("Poisonous")) sum += a.getKeywordMagnitude("Poisonous");
}
return sum;
}
//Checks if the life of the attacked Player/Planeswalker is in danger
public static boolean lifeInDanger(Combat combat) {
@@ -493,6 +518,9 @@ public class CombatUtil {
}
}
damage += sumAttack(unblocked);
poison += sumPoison(unblocked);
if (combat.getPlaneswalker() == null) {
if (damage + 3 > AllZone.ComputerPlayer.getLife() || poison + 2 > 10 - AllZone.ComputerPlayer.getPoisonCounters())
return true;