mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Improved the Attack AI deciding to assault (especially with poison involved).
This commit is contained in:
@@ -868,7 +868,7 @@ public class CombatUtil {
|
||||
* a {@link forge.Player} object.
|
||||
* @return a int.
|
||||
*/
|
||||
private static int sumDamageIfUnblocked(final CardList attackers, final Player attacked) {
|
||||
public static int sumDamageIfUnblocked(final CardList attackers, final Player attacked) {
|
||||
int sum = 0;
|
||||
for (Card attacker : attackers) {
|
||||
sum += damageIfUnblocked(attacker, attacked, null);
|
||||
@@ -888,7 +888,7 @@ public class CombatUtil {
|
||||
* a {@link forge.Player} object.
|
||||
* @return a int.
|
||||
*/
|
||||
private static int sumPoisonIfUnblocked(final CardList attackers, final Player attacked) {
|
||||
public static int sumPoisonIfUnblocked(final CardList attackers, final Player attacked) {
|
||||
int sum = 0;
|
||||
for (Card attacker : attackers) {
|
||||
sum += poisonIfUnblocked(attacker, attacked, null);
|
||||
|
||||
@@ -330,15 +330,24 @@ public class ComputerUtilAttack {
|
||||
}
|
||||
|
||||
// I think this is right but the assault code may still be a little off
|
||||
CardListUtil.sortAttackLowFirst(attackers);
|
||||
CardListUtil.sortAttack(attackers);
|
||||
|
||||
int totalAttack = 0;
|
||||
CardList remainingAttackers = new CardList(attackers.toArray());
|
||||
// presumes the Human will block
|
||||
for (int i = 0; i < (attackers.size() - blockers.size()); i++) {
|
||||
totalAttack += getAttack(attackers.get(i));
|
||||
for (int i = 0; i < blockers.size(); i++) {
|
||||
remainingAttackers.remove(attackers.get(i));
|
||||
}
|
||||
|
||||
if(CombatUtil.sumDamageIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) > AllZone.getHumanPlayer().getLife()
|
||||
&& AllZone.getHumanPlayer().canLoseLife()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(CombatUtil.sumPoisonIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) >= 10 - AllZone.getHumanPlayer().getPoisonCounters()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return blockerLife <= totalAttack;
|
||||
return false;
|
||||
} // doAssault()
|
||||
|
||||
/**
|
||||
@@ -643,7 +652,7 @@ public class ComputerUtilAttack {
|
||||
for (int i = 0; i < attackersLeft.size(); i++) {
|
||||
if (CombatUtil.canAttack(attackersLeft.get(i), combat)) {
|
||||
combat.addAttacker(attackersLeft.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("Normal attack");
|
||||
|
||||
Reference in New Issue
Block a user