fixed issues with changeling tokens not counting as they enter

This commit is contained in:
Evan Kranzler 2022-03-13 22:25:44 -04:00
parent 1599b2a49f
commit 82832046b3
2 changed files with 36 additions and 1 deletions

View file

@ -3,6 +3,7 @@ package org.mage.test.cards.continuous;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test; import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase; import org.mage.test.serverside.base.CardTestPlayerBase;
@ -66,10 +67,11 @@ public class ChangelingTest extends CardTestPlayerBase {
assertPowerToughness(playerA, copter, 3, 3); assertPowerToughness(playerA, copter, 3, 3);
} }
private static final String mimic = "Metallic Mimic";
@Test @Test
public void testMetallicMimicChangelingTrigger() { public void testMetallicMimicChangelingTrigger() {
// all creatures with the chosen subtype come into play with a +1/+1 counter // 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, mimic, 1);
addCard(Zone.HAND, playerA, woodlandChangeling, 1); addCard(Zone.HAND, playerA, woodlandChangeling, 1);
@ -86,4 +88,24 @@ public class ChangelingTest extends CardTestPlayerBase {
// 2/2 + +1/+1 counter // 2/2 + +1/+1 counter
assertPowerToughness(playerA, woodlandChangeling, 3, 3); 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);
}
} }

View file

@ -3,8 +3,11 @@ package mage.game.permanent;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCost;
import mage.abilities.keyword.ChangelingAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.constants.EmptyNames; import mage.constants.EmptyNames;
import mage.constants.SubType;
import mage.constants.SubTypeSet;
import mage.game.Game; import mage.game.Game;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.token.Token; import mage.game.permanent.token.Token;
@ -116,4 +119,14 @@ public class PermanentToken extends PermanentImpl {
// token don't have game card, so return itself // token don't have game card, so return itself
return this; 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);
}
} }