From 82832046b3ce4227f92b1273bb1b93bb06a97fd4 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 13 Mar 2022 22:25:44 -0400 Subject: [PATCH] fixed issues with changeling tokens not counting as they enter --- .../test/cards/continuous/ChangelingTest.java | 24 ++++++++++++++++++- .../mage/game/permanent/PermanentToken.java | 13 ++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ChangelingTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ChangelingTest.java index 4e60df5f3b..6d09b71dfe 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ChangelingTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ChangelingTest.java @@ -3,6 +3,7 @@ package org.mage.test.cards.continuous; import mage.constants.CardType; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.counters.CounterType; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -66,10 +67,11 @@ public class ChangelingTest extends CardTestPlayerBase { assertPowerToughness(playerA, copter, 3, 3); } + private static final String mimic = "Metallic Mimic"; + @Test public void testMetallicMimicChangelingTrigger() { // all creatures with the chosen subtype come into play with a +1/+1 counter - final String mimic = "Metallic Mimic"; addCard(Zone.HAND, playerA, mimic, 1); addCard(Zone.HAND, playerA, woodlandChangeling, 1); @@ -86,4 +88,24 @@ public class ChangelingTest extends CardTestPlayerBase { // 2/2 + +1/+1 counter assertPowerToughness(playerA, woodlandChangeling, 3, 3); } + + private static final String paragon = "Bramblewood Paragon"; + private static final String cohort = "Irregular Cohort"; + + @Test + public void testTokensHaveTypesAsTheyEnter() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 4); + addCard(Zone.BATTLEFIELD, playerA, paragon); + addCard(Zone.HAND, playerA, cohort); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, cohort); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertCounterCount(playerA, cohort, CounterType.P1P1, 1); + assertCounterCount(playerA, "Shapeshifter", CounterType.P1P1, 1); + } } diff --git a/Mage/src/main/java/mage/game/permanent/PermanentToken.java b/Mage/src/main/java/mage/game/permanent/PermanentToken.java index 3229203e6a..a0dbe9a163 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentToken.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentToken.java @@ -3,8 +3,11 @@ package mage.game.permanent; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCost; +import mage.abilities.keyword.ChangelingAbility; import mage.cards.Card; import mage.constants.EmptyNames; +import mage.constants.SubType; +import mage.constants.SubTypeSet; import mage.game.Game; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.token.Token; @@ -116,4 +119,14 @@ public class PermanentToken extends PermanentImpl { // token don't have game card, so return itself return this; } + + @Override + public boolean hasSubtype(SubType value, Game game) { + if (super.hasSubtype(value, game)) { + return true; + } + return this.isCreature(game) + && value.getSubTypeSet() == SubTypeSet.CreatureType + && this.getAbilities(game).containsClass(ChangelingAbility.class); + } }