Fix casting with unpayable cost if no alternative provided

This commit is contained in:
tool4EvEr
2023-07-20 20:56:24 +02:00
parent 99e28e4106
commit 4941da593f

View File

@@ -370,15 +370,23 @@ public class PlayEffect extends SpellAbilityEffect {
if ((sa.hasParam("WithoutManaCost") || sa.hasParam("PlayCost")) && tgtSA.costHasManaX() && !tgtSA.getPayCosts().getCostMana().canXbe0()) { if ((sa.hasParam("WithoutManaCost") || sa.hasParam("PlayCost")) && tgtSA.costHasManaX() && !tgtSA.getPayCosts().getCostMana().canXbe0()) {
continue; continue;
} }
boolean unpayableCost = tgtSA.getHostCard().getManaCost().isNoCost();
if (sa.hasParam("WithoutManaCost")) { if (sa.hasParam("WithoutManaCost")) {
tgtSA = tgtSA.copyWithNoManaCost(); tgtSA = tgtSA.copyWithNoManaCost();
} else if (sa.hasParam("PlayCost")) { } else if (sa.hasParam("PlayCost")) {
Cost abCost; Cost abCost;
String cost = sa.getParam("PlayCost"); String cost = sa.getParam("PlayCost");
if (cost.equals("ManaCost")) { if (cost.equals("ManaCost")) {
if (unpayableCost) {
continue;
}
abCost = new Cost(source.getManaCost(), false); abCost = new Cost(source.getManaCost(), false);
} else { } else {
if (cost.contains("ConvertedManaCost")) { if (cost.contains("ConvertedManaCost")) {
if (unpayableCost) {
continue;
}
final String costcmc = Integer.toString(tgtCard.getCMC()); final String costcmc = Integer.toString(tgtCard.getCMC());
cost = cost.replace("ConvertedManaCost", costcmc); cost = cost.replace("ConvertedManaCost", costcmc);
} }
@@ -386,6 +394,8 @@ public class PlayEffect extends SpellAbilityEffect {
} }
tgtSA = tgtSA.copyWithManaCostReplaced(tgtSA.getActivatingPlayer(), abCost); tgtSA = tgtSA.copyWithManaCostReplaced(tgtSA.getActivatingPlayer(), abCost);
} else if (unpayableCost) {
continue;
} }
if (!optional) { if (!optional) {