- Further updated mana ritual cards to properly account for Battery effect.

This commit is contained in:
Agetian
2018-12-04 12:21:04 +03:00
parent 9e6b1acf89
commit 373cd9bd24
4 changed files with 22 additions and 21 deletions

View File

@@ -670,7 +670,7 @@ public class AiController {
// This is for playing spells regularly (no Cascade/Ripple etc.) // This is for playing spells regularly (no Cascade/Ripple etc.)
private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) { private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) {
boolean xCost = ComputerUtilMana.hasXInAnyCostPart(sa); boolean xCost = sa.getPayCosts().hasXInAnyCostPart(sa);
if (!xCost && !ComputerUtilCost.canPayCost(sa, player)) { if (!xCost && !ComputerUtilCost.canPayCost(sa, player)) {
// for most costs, it's OK to check if they can be paid early in order to avoid running a heavy API check // for most costs, it's OK to check if they can be paid early in order to avoid running a heavy API check

View File

@@ -1556,24 +1556,6 @@ public class ComputerUtilMana {
return convoke; return convoke;
} }
public static boolean hasXInAnyCostPart(SpellAbility sa) {
boolean xCost = false;
if (sa.getPayCosts() != null) {
for (CostPart p : sa.getPayCosts().getCostParts()) {
if (p instanceof CostPartMana) {
if (((CostPartMana) p).getAmountOfX() > 0) {
xCost = true;
break;
}
} else if (p.getAmount().equals("X")) {
xCost = true;
break;
}
}
}
return xCost;
}
public static int determineMaxAffordableX(Player ai, SpellAbility sa) { public static int determineMaxAffordableX(Player ai, SpellAbility sa) {
if (sa.getPayCosts() == null || sa.getPayCosts().getCostMana() == null) { if (sa.getPayCosts() == null || sa.getPayCosts().getCostMana() == null) {
return -1; return -1;

View File

@@ -203,8 +203,9 @@ public class ManaEffectAi extends SpellAbilityAi {
Predicates.or(CardPredicates.isColorless(), CardPredicates.isColor(producedColor)))); Predicates.or(CardPredicates.isColorless(), CardPredicates.isColor(producedColor))));
if ("ManaRitualBattery".equals(sa.getParam("AILogic"))) { if ("ManaRitualBattery".equals(sa.getParam("AILogic"))) {
// Don't remove more counters than would be needed to cast everything we want to cast // Don't remove more counters than would be needed to cast the more expensive thing we want to cast,
int maxCtrs = Aggregates.sum(castableSpells, CardPredicates.Accessors.fnGetCmc); // otherwise the AI grabs too many counters at once.
int maxCtrs = Aggregates.max(castableSpells, CardPredicates.Accessors.fnGetCmc) - 1;
sa.setSVar("ChosenX", "Number$" + Math.min(numCounters, maxCtrs)); sa.setSVar("ChosenX", "Number$" + Math.min(numCounters, maxCtrs));
} }

View File

@@ -935,5 +935,23 @@ public class Cost implements Serializable {
return true; return true;
} }
public boolean hasXInAnyCostPart(SpellAbility sa) {
boolean xCost = false;
if (sa.getPayCosts() != null) {
for (CostPart p : sa.getPayCosts().getCostParts()) {
if (p instanceof CostPartMana) {
if (((CostPartMana) p).getAmountOfX() > 0) {
xCost = true;
break;
}
} else if (p.getAmount().equals("X")) {
xCost = true;
break;
}
}
}
return xCost;
}
public static final Cost Zero = new Cost(0); public static final Cost Zero = new Cost(0);
} }