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){ else if (sa.getPayCosts() != null){
Cost payCosts = sa.getPayCosts(); Cost payCosts = sa.getPayCosts();
ManaCost mana = payCosts.getTotalMana(); ManaCost mana = payCosts.getTotalMana();
if (mana!= null && mana.countX() > 0) { if (mana != null) {
// Set PayX here to maximum value. if(mana.countX() > 0) {
final int xPay = ComputerUtilMana.determineLeftoverMana(sa, player); // Set PayX here to maximum value.
if (xPay <= 0) { final int xPay = ComputerUtilMana.determineLeftoverMana(sa, player);
return AiPlayDecision.CantAffordX; 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;
}
} }
card.setSVar("PayX", Integer.toString(xPay));
} }
} }
if (checkCurseEffects(sa)) { if (checkCurseEffects(sa)) {
@@ -691,6 +699,12 @@ public class AiController {
} }
card.setSVar("PayX", Integer.toString(xPay)); 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 // Check for valid targets before casting