From 177f72c8d8c8075cc205cbe2252562e9fef26ca2 Mon Sep 17 00:00:00 2001 From: Steven Knipe Date: Thu, 16 Nov 2023 18:21:02 -0800 Subject: [PATCH] Altered ego X value should be separate --- Mage.Sets/src/mage/cards/a/AlteredEgo.java | 10 +++++-- .../mage/test/cards/copy/AlteredEgoTest.java | 30 +++++++++++++++++++ .../mage/abilities/keyword/KickerAbility.java | 2 +- Mage/src/main/java/mage/util/CardUtil.java | 6 ++-- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AlteredEgo.java b/Mage.Sets/src/mage/cards/a/AlteredEgo.java index 1573b57df86..d19897a7741 100644 --- a/Mage.Sets/src/mage/cards/a/AlteredEgo.java +++ b/Mage.Sets/src/mage/cards/a/AlteredEgo.java @@ -6,7 +6,7 @@ import mage.abilities.Ability; import mage.abilities.common.CantBeCounteredSourceAbility; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.effects.common.CopyPermanentEffect; -import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -14,6 +14,7 @@ import mage.constants.SubType; import mage.counters.CounterType; import mage.filter.StaticFilters; import mage.game.Game; +import mage.util.CardUtil; import mage.util.functions.CopyApplier; import java.util.UUID; @@ -65,11 +66,14 @@ class AlteredEgoCopyApplier extends CopyApplier { // effect is applied to that object after applying the copy effect with that exception, the // exception’s effect doesn’t happen. - if (!isCopyOfCopy(source, blueprint, copyToObjectId)) { + if (!isCopyOfCopy(source, blueprint, copyToObjectId) && CardUtil.checkSourceCostsTagExists(game, source, "X")) { // except it enters with an additional X +1/+1 counters on it blueprint.getAbilities().add( - new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance())) + new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance( + (int)CardUtil.getSourceCostsTag(game, source, "X", 0) + ))) ); + CardUtil.getSourceCostsTagsMap(game, source).remove("X"); //X value of Altered Ego is separate from the copied creature's X value } return true; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/AlteredEgoTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/AlteredEgoTest.java index 51603c9a477..2877e763827 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/copy/AlteredEgoTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/AlteredEgoTest.java @@ -53,4 +53,34 @@ public class AlteredEgoTest extends CardTestPlayerBase { assertGraveyardCount(playerA, "Altered Ego", 1); } + + /** + * If the chosen creature has {X} in its mana cost, that X is considered to be 0. + * The value of X in Altered Ego’s last ability will be whatever value was chosen for X while casting Altered Ego. + * (2016-04-08) + */ + @Test + public void copyXCreature() { + addCard(Zone.BATTLEFIELD, playerA, "Wastes", 2); + addCard(Zone.BATTLEFIELD, playerB, "Tropical Island", 7); + addCard(Zone.HAND, playerA, "Endless One"); // {X}, ETB with X +1/+1 counters, 0/0 + addCard(Zone.HAND, playerB, "Altered Ego"); // {X}{2}{G}{U} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Endless One"); + setChoice(playerA, "X=2"); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Altered Ego"); + setChoice(playerB, "X=3"); + setChoice(playerB, true); // use copy + setChoice(playerB, "Endless One"); // copy target + setChoice(playerB, ""); // Order place counters effects + + setStrictChooseMode(true); + setStopAt(2, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Endless One", 1); + assertPowerToughness(playerA, "Endless One", 2, 2); + assertPermanentCount(playerB, "Endless One", 1); + assertPowerToughness(playerB, "Endless One", 3, 3); //The X should not be copied + } } diff --git a/Mage/src/main/java/mage/abilities/keyword/KickerAbility.java b/Mage/src/main/java/mage/abilities/keyword/KickerAbility.java index 9dd192c5f52..0796eafd1b7 100644 --- a/Mage/src/main/java/mage/abilities/keyword/KickerAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/KickerAbility.java @@ -130,7 +130,7 @@ public class KickerAbility extends StaticAbility implements OptionalAdditionalSo * @return */ public static int getKickedCounterStrict(Game game, Ability source, String needKickerCost) { - Map costsTags = CardUtil.getSourceCostsTags(game, source); + Map costsTags = CardUtil.getSourceCostsTagsMap(game, source); if (costsTags == null) { return 0; } diff --git a/Mage/src/main/java/mage/util/CardUtil.java b/Mage/src/main/java/mage/util/CardUtil.java index d4a0a6a5d5c..932d466806e 100644 --- a/Mage/src/main/java/mage/util/CardUtil.java +++ b/Mage/src/main/java/mage/util/CardUtil.java @@ -1687,7 +1687,7 @@ public final class CardUtil { * @return the tag map (or null) */ // - public static Map getSourceCostsTags(Game game, Ability source) { + public static Map getSourceCostsTagsMap(Game game, Ability source) { Map costTags; costTags = source.getCostsTagMap(); if (costTags == null && source.getSourcePermanentOrLKI(game) != null) { @@ -1705,7 +1705,7 @@ public final class CardUtil { * @return if the tag was found */ public static boolean checkSourceCostsTagExists(Game game, Ability source, String tag) { - Map costTags = getSourceCostsTags(game, source); + Map costTags = getSourceCostsTagsMap(game, source); return costTags != null && costTags.containsKey(tag); } /** @@ -1719,7 +1719,7 @@ public final class CardUtil { * @return The object stored by the tag if found, the default if not */ public static Object getSourceCostsTag(Game game, Ability source, String tag, Object defaultValue){ - Map costTags = getSourceCostsTags(game, source); + Map costTags = getSourceCostsTagsMap(game, source); if (costTags != null) { return costTags.getOrDefault(tag, defaultValue); }