Fix Embodiment of Agonies counting Asmoranomardicadaistinaculdacar (#6388)

This commit is contained in:
tool4ever
2024-10-20 12:02:48 +02:00
committed by GitHub
parent 42893234b3
commit 98c0959d8f
8 changed files with 13 additions and 30 deletions

View File

@@ -42,7 +42,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
private List<ManaCostShard> shards; private List<ManaCostShard> shards;
private final int genericCost; private final int genericCost;
private final boolean hasNoCost; // lands cost private boolean hasNoCost = true; // lands cost
private String stringValue; // precalculated for toString; private String stringValue; // precalculated for toString;
private Float compareWeight = null; private Float compareWeight = null;
@@ -92,8 +92,8 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
*/ */
public ManaCost(final IParserManaCost parser) { public ManaCost(final IParserManaCost parser) {
final List<ManaCostShard> shardsTemp = Lists.newArrayList(); final List<ManaCostShard> shardsTemp = Lists.newArrayList();
this.hasNoCost = false;
while (parser.hasNext()) { while (parser.hasNext()) {
this.hasNoCost = false;
final ManaCostShard shard = parser.next(); final ManaCostShard shard = parser.next();
if (shard != null && shard != ManaCostShard.GENERIC) { if (shard != null && shard != ManaCostShard.GENERIC) {
shardsTemp.add(shard); shardsTemp.add(shard);
@@ -281,6 +281,9 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
* @return * @return
*/ */
public String getShortString() { public String getShortString() {
if (isNoCost()) {
return "-1";
}
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int generic = getGenericCost(); int generic = getGenericCost();
if (this.isZero()) { if (this.isZero()) {

View File

@@ -54,7 +54,7 @@ public class ManaCostParser implements IParserManaCost {
*/ */
@Override @Override
public final boolean hasNext() { public final boolean hasNext() {
return this.nextToken < this.cost.length; return this.nextToken < this.cost.length && !this.cost[this.nextToken].equals("-1");
} }
/* /*

View File

@@ -2740,6 +2740,7 @@ public class AbilityUtils {
for (Card card : cards) { for (Card card : cards) {
manaCost.add(card.getManaCost().getShortString()); manaCost.add(card.getManaCost().getShortString());
} }
manaCost.remove(ManaCost.NO_COST.getShortString());
return doXMath(manaCost.size(), expr, c, ctb); return doXMath(manaCost.size(), expr, c, ctb);
} }

View File

@@ -389,9 +389,6 @@ public class PlayEffect extends SpellAbilityEffect {
abCost = Iterables.find(tgtCard.getNonManaAbilities(), s -> s.isKeyword(Keyword.SUSPEND)).getPayCosts(); abCost = Iterables.find(tgtCard.getNonManaAbilities(), s -> s.isKeyword(Keyword.SUSPEND)).getPayCosts();
} 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);
} }

View File

@@ -474,15 +474,6 @@ public class PumpEffect extends SpellAbilityEffect {
List<String> affectedKeywords = Lists.newArrayList(keywords); List<String> affectedKeywords = Lists.newArrayList(keywords);
if (!affectedKeywords.isEmpty()) { if (!affectedKeywords.isEmpty()) {
Iterables.removeIf(affectedKeywords, input -> {
if (input.contains("CardManaCost")) {
if (tgtC.getManaCost().isNoCost()) {
return true;
}
}
return false;
});
affectedKeywords = Lists.transform(affectedKeywords, input -> { affectedKeywords = Lists.transform(affectedKeywords, input -> {
if (input.contains("CardManaCost")) { if (input.contains("CardManaCost")) {
input = input.replace("CardManaCost", tgtC.getManaCost().getShortString()); input = input.replace("CardManaCost", tgtC.getManaCost().getShortString());

View File

@@ -1462,7 +1462,7 @@ public class CardFactoryUtil {
final String trigStr = "Mode$ Exiled | ValidCard$ Card.Self | Madness$ True | Secondary$ True" final String trigStr = "Mode$ Exiled | ValidCard$ Card.Self | Madness$ True | Secondary$ True"
+ " | TriggerDescription$ Play Madness " + ManaCostParser.parse(manacost) + " - " + card.getName(); + " | TriggerDescription$ Play Madness " + ManaCostParser.parse(manacost) + " - " + card.getName();
final String playMadnessStr = "DB$ Play | Defined$ Self | PlayCost$ " + manacost + final String playMadnessStr = "DB$ Play | Defined$ Self | ValidSA$ Spell | PlayCost$ " + manacost +
" | ConditionDefined$ Self | ConditionPresent$ Card.StrictlySelf+inZoneExile" + " | ConditionDefined$ Self | ConditionPresent$ Card.StrictlySelf+inZoneExile" +
" | Optional$ True | RememberPlayed$ True | Madness$ True"; " | Optional$ True | RememberPlayed$ True | Madness$ True";

View File

@@ -23,7 +23,6 @@ import forge.game.card.CardCopyService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import forge.card.CardStateName; import forge.card.CardStateName;
import forge.card.mana.ManaCost;
import forge.game.Game; import forge.game.Game;
import forge.game.ability.AbilityKey; import forge.game.ability.AbilityKey;
import forge.game.card.Card; import forge.game.card.Card;
@@ -71,6 +70,11 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
return false; return false;
} }
// CR 118.6 cost is unpayable
if (getPayCosts().hasManaCost() && getPayCosts().getCostMana().getMana().isNoCost()) {
return false;
}
Player activator = this.getActivatingPlayer(); Player activator = this.getActivatingPlayer();
if (activator == null) { if (activator == null) {
activator = card.getController(); activator = card.getController();
@@ -84,9 +88,6 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
return false; return false;
} }
// Save the original cost and the face down info for a later check since the LKI copy will overwrite them
ManaCost origCost = card.getState(card.isFaceDown() ? CardStateName.Original : card.getCurrentStateName()).getManaCost();
// do performanceMode only for cases where the activator is different than controller // do performanceMode only for cases where the activator is different than controller
if (!Spell.performanceMode && !card.getController().equals(activator)) { if (!Spell.performanceMode && !card.getController().equals(activator)) {
// always make a lki copy in this case? // always make a lki copy in this case?
@@ -100,13 +101,6 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
return false; return false;
} }
// for uncastables like lotus bloom, check if manaCost is blank (except for morph spells)
// but ignore if it comes from PlayEffect
if (!isCastFaceDown() && !isCastFromPlayEffect()
&& isBasicSpell() && origCost.isNoCost()) {
return false;
}
if (!CostPayment.canPayAdditionalCosts(this.getPayCosts(), this, false)) { if (!CostPayment.canPayAdditionalCosts(this.getPayCosts(), this, false)) {
return false; return false;
} }

View File

@@ -731,9 +731,6 @@ public final class StaticAbilityContinuous {
final List<String> extraKeywords = Lists.newArrayList(); final List<String> extraKeywords = Lists.newArrayList();
Iterables.removeIf(newKeywords, input -> { Iterables.removeIf(newKeywords, input -> {
if (input.contains("CardManaCost") && affectedCard.getManaCost().isNoCost()) {
return true;
}
// replace one Keyword with list of keywords // replace one Keyword with list of keywords
if (input.startsWith("Protection") && input.contains("CardColors")) { if (input.startsWith("Protection") && input.contains("CardColors")) {
for (Byte color : affectedCard.getColor()) { for (Byte color : affectedCard.getColor()) {