diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DecayedTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DecayedTest.java new file mode 100644 index 0000000000..63f082fac3 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DecayedTest.java @@ -0,0 +1,51 @@ +package org.mage.test.cards.abilities.keywords; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +public class DecayedTest extends CardTestPlayerBase { + + @Test + public void decayedToken() { + addCard(Zone.HAND, playerA, "Falcon Abomination", 1); + addCard(Zone.BATTLEFIELD, playerA, "Island", 3); + setStrictChooseMode(true); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Falcon Abomination"); + attack(3, playerA, "Zombie"); + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertAllCommandsUsed(); + assertPermanentCount(playerA, "Falcon Abomination", 1); + assertPermanentCount(playerA, "Zombie", 0); + } + + @Test + public void decayedPermanent() { + addCard(Zone.BATTLEFIELD, playerA, "Gisa, Glorious Resurrector", 1); + addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears", 1); + addCard(Zone.HAND, playerA, "Doom Blade", 1); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); + setStrictChooseMode(true); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Doom Blade"); + addTarget(playerA, "Grizzly Bears"); + // Gisa - "If a creature an opponent controls would die, exile it instead." + checkExileCount("Gisa Exile Ability", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Grizzly Bears", 1); + + attack(5, playerA, "Grizzly Bears"); + setStopAt(5, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertAllCommandsUsed(); + assertPermanentCount(playerA, "Gisa, Glorious Resurrector", 1); + assertPermanentCount(playerA, "Grizzly Bears", 0); + assertPermanentCount(playerB, "Grizzly Bears", 0); + assertExileCount("Grizzly Bears", 0); + // Grizzly Bears should sacrifice after combat and go to playerB's graveyard + assertGraveyardCount(playerB, "Grizzly Bears", 1); + } +} diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 78dcabfa8b..26b10e2d08 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -386,6 +386,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { game.getState().addAbility(copyAbility, sourceId, this); } abilities.add(copyAbility); + abilities.addAll(ability.getSubAbilities()); } } diff --git a/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java b/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java index fd73338f47..5014b16350 100644 --- a/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java +++ b/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java @@ -125,6 +125,7 @@ public abstract class TokenImpl extends MageObjectImpl implements Token { public void addAbility(Ability ability) { ability.setSourceId(this.getId()); abilities.add(ability); + abilities.addAll(ability.getSubAbilities()); } @Override