AiController: canPlaySa add check if the mana cost is zero, but the card cost does contain X

should not play this spell for free.
This commit is contained in:
Hanmac
2016-09-26 20:11:47 +00:00
parent a67f807f7c
commit b5d7e071eb

View File

@@ -654,13 +654,21 @@ public class AiController {
else if (sa.getPayCosts() != null){
Cost payCosts = sa.getPayCosts();
ManaCost mana = payCosts.getTotalMana();
if (mana!= null && mana.countX() > 0) {
if (mana != null) {
if(mana.countX() > 0) {
// Set PayX here to maximum value.
final int xPay = ComputerUtilMana.determineLeftoverMana(sa, player);
if (xPay <= 0) {
return AiPlayDecision.CantAffordX;
}
card.setSVar("PayX", Integer.toString(xPay));
} else if (mana.isZero()) {
// if mana is zero, but card mana cost does have X, then something is wrong
ManaCost cardCost = card.getManaCost();
if (cardCost != null && cardCost.countX() > 0) {
return AiPlayDecision.CantPlayAi;
}
}
}
}
if (checkCurseEffects(sa)) {
@@ -691,6 +699,12 @@ public class AiController {
}
card.setSVar("PayX", Integer.toString(xPay));
}
} else if (mana.isZero()) {
// if mana is zero, but card mana cost does have X, then something is wrong
ManaCost cardCost = card.getManaCost();
if (cardCost != null && cardCost.countX() > 0) {
return AiPlayDecision.CantPlayAi;
}
}
// Check for valid targets before casting