mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- Further updated mana ritual cards to properly account for Battery effect.
This commit is contained in:
@@ -670,7 +670,7 @@ public class AiController {
|
||||
|
||||
// This is for playing spells regularly (no Cascade/Ripple etc.)
|
||||
private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) {
|
||||
boolean xCost = ComputerUtilMana.hasXInAnyCostPart(sa);
|
||||
boolean xCost = sa.getPayCosts().hasXInAnyCostPart(sa);
|
||||
|
||||
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
|
||||
|
||||
@@ -1556,24 +1556,6 @@ public class ComputerUtilMana {
|
||||
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) {
|
||||
if (sa.getPayCosts() == null || sa.getPayCosts().getCostMana() == null) {
|
||||
return -1;
|
||||
|
||||
@@ -203,8 +203,9 @@ public class ManaEffectAi extends SpellAbilityAi {
|
||||
Predicates.or(CardPredicates.isColorless(), CardPredicates.isColor(producedColor))));
|
||||
|
||||
if ("ManaRitualBattery".equals(sa.getParam("AILogic"))) {
|
||||
// Don't remove more counters than would be needed to cast everything we want to cast
|
||||
int maxCtrs = Aggregates.sum(castableSpells, CardPredicates.Accessors.fnGetCmc);
|
||||
// Don't remove more counters than would be needed to cast the more expensive thing we want to cast,
|
||||
// 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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user