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.
|
* a {@link forge.Player} object.
|
||||||
* @return a int.
|
* @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;
|
int sum = 0;
|
||||||
for (Card attacker : attackers) {
|
for (Card attacker : attackers) {
|
||||||
sum += damageIfUnblocked(attacker, attacked, null);
|
sum += damageIfUnblocked(attacker, attacked, null);
|
||||||
@@ -888,7 +888,7 @@ public class CombatUtil {
|
|||||||
* a {@link forge.Player} object.
|
* a {@link forge.Player} object.
|
||||||
* @return a int.
|
* @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;
|
int sum = 0;
|
||||||
for (Card attacker : attackers) {
|
for (Card attacker : attackers) {
|
||||||
sum += poisonIfUnblocked(attacker, attacked, null);
|
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
|
// 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
|
// presumes the Human will block
|
||||||
for (int i = 0; i < (attackers.size() - blockers.size()); i++) {
|
for (int i = 0; i < blockers.size(); i++) {
|
||||||
totalAttack += getAttack(attackers.get(i));
|
remainingAttackers.remove(attackers.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockerLife <= totalAttack;
|
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 false;
|
||||||
} // doAssault()
|
} // doAssault()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user