Fix X shards in combat tax missing from total cost (#5154)

This commit is contained in:
tool4ever
2024-04-25 09:32:42 +02:00
committed by GitHub
parent c20c214b9c
commit 7e828fd654
15 changed files with 74 additions and 83 deletions

View File

@@ -286,6 +286,10 @@ public class CombatUtil {
// If there's a better way of handling this somewhere deeper in the code, feel free to remove
final SpellAbility fakeSA = new SpellAbility.EmptySa(attacker, attacker.getController());
fakeSA.setCardState(attacker.getCurrentState());
// need to set this for "CostContainsX" restriction
fakeSA.setPayCosts(attackCost);
// prevent recalculating X
fakeSA.setSVar("X", "0");
return attacker.getController().getController().payManaOptional(attacker, attackCost, fakeSA,
"Pay additional cost to declare " + attacker + " an attacker", ManaPaymentPurpose.DeclareAttacker);
}
@@ -347,6 +351,8 @@ public class CombatUtil {
SpellAbility fakeSA = new SpellAbility.EmptySa(blocker, blocker.getController());
fakeSA.setCardState(blocker.getCurrentState());
fakeSA.setPayCosts(blockCost);
fakeSA.setSVar("X", "0");
return blocker.getController().getController().payManaOptional(blocker, blockCost, fakeSA, "Pay cost to declare " + blocker + " a blocker. ", ManaPaymentPurpose.DeclareBlocker);
}

View File

@@ -138,7 +138,7 @@ public class CostPartMana extends CostPart {
if (isCostPayAnyNumberOfTimes) {
int timesToPay = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getSVar("NumTimes"), sa);
if (timesToPay == 0) {
return ManaCost.NO_COST;
return ManaCost.ZERO;
}
ManaCostBeingPaid totalMana = new ManaCostBeingPaid(getMana());
for (int i = 1; i < timesToPay; i++) {

View File

@@ -254,7 +254,12 @@ public class StaticAbilityCantAttackBlock {
if (remember) {
hostCard.addRemembered(attacker);
}
// keep X shards
boolean addX = costString.startsWith("X");
costString = Integer.toString(AbilityUtils.calculateAmount(hostCard, stAb.getSVar(costString), stAb));
if (addX) {
costString += " X";
}
if (remember) {
hostCard.removeRemembered(attacker);
}
@@ -288,7 +293,11 @@ public class StaticAbilityCantAttackBlock {
}
String costString = stAb.getParam("Cost");
if (stAb.hasSVar(costString)) {
costString = Integer.toString(AbilityUtils.calculateAmount(hostCard, costString, stAb));
boolean addX = costString.startsWith("X");
costString = Integer.toString(AbilityUtils.calculateAmount(hostCard, stAb.getSVar(costString), stAb));
if (addX) {
costString += " X";
}
}
return new Cost(costString, true);