- Fixed AI stopping to play lands and permanents when life <= 0.

This commit is contained in:
Sloth
2015-07-11 12:57:32 +00:00
parent 8e01e23acf
commit d9950b2609
3 changed files with 9 additions and 4 deletions

View File

@@ -1081,7 +1081,8 @@ public class AiController {
if (!checkETBEffects(card, spell, null)) {
return AiPlayDecision.BadEtbEffects;
}
if (ComputerUtil.damageFromETB(player, card) >= player.getLife() && player.canLoseLife()) {
if (ComputerUtil.damageFromETB(player, card) >= player.getLife() && !player.cantLoseForZeroOrLessLife()
&& player.canLoseLife()) {
return AiPlayDecision.BadEtbEffects;
}
}
@@ -1096,7 +1097,8 @@ public class AiController {
CardCollection landsWannaPlay = getLandsToPlay();
if (landsWannaPlay != null && !landsWannaPlay.isEmpty() && player.canPlayLand(null)) {
Card land = chooseBestLandToPlay(landsWannaPlay);
if (ComputerUtil.damageFromETB(player, land) < player.getLife() || !player.canLoseLife()) {
if (ComputerUtil.damageFromETB(player, land) < player.getLife() || !player.canLoseLife()
|| player.cantLoseForZeroOrLessLife() ) {
game.PLAY_LAND_SURROGATE.setHostCard(land);
final List<SpellAbility> abilities = new ArrayList<SpellAbility>();
abilities.add(game.PLAY_LAND_SURROGATE);

View File

@@ -177,7 +177,7 @@ public class ComputerUtilCost {
amount = AbilityUtils.calculateAmount(source, payLife.getAmount(), sourceAbility);
}
if ((ai.getLife() - amount) < remainingLife) {
if (ai.getLife() - amount < remainingLife && !ai.cantLoseForZeroOrLessLife()) {
return false;
}
}
@@ -322,6 +322,9 @@ public class ComputerUtilCost {
for (final CostPart part : cost.getCostParts()) {
if (part instanceof CostPayLife) {
if (!ai.cantLoseForZeroOrLessLife()) {
continue;
}
final int remainingLife = ai.getLife();
final int lifeCost = ((CostPayLife) part).convertAmount();
if ((remainingLife - lifeCost) < 10) {

View File

@@ -212,7 +212,7 @@ public abstract class GameState {
playerCards.put(kv.getKey(), processCardsForZone(value.isEmpty() ? new String[0] : value.split(";"), p));
}
if (life > 0) p.setLife(life, null);
if (life >= 0) p.setLife(life, null);
for (Entry<ZoneType, CardCollectionView> kv : playerCards.entrySet()) {
if (kv.getKey() == ZoneType.Battlefield) {
List<Card> cards = new ArrayList<Card>();