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/cards/CardImpl.java b/Mage/src/main/java/mage/cards/CardImpl.java index 0bd9d7464e..e20db01632 100644 --- a/Mage/src/main/java/mage/cards/CardImpl.java +++ b/Mage/src/main/java/mage/cards/CardImpl.java @@ -305,9 +305,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card { public void addAbility(Ability ability) { ability.setSourceId(this.getId()); abilities.add(ability); - for (Ability subAbility : ability.getSubAbilities()) { - abilities.add(subAbility); - } + abilities.addAll(ability.getSubAbilities()); // dynamic check: you can't add ability to the PermanentCard, use permanent.addAbility(a, source, game) instead // reason: triggered abilities are not processing here diff --git a/Mage/src/main/java/mage/designations/Designation.java b/Mage/src/main/java/mage/designations/Designation.java index 142daffc9f..02dfb6abd1 100644 --- a/Mage/src/main/java/mage/designations/Designation.java +++ b/Mage/src/main/java/mage/designations/Designation.java @@ -119,6 +119,7 @@ public abstract class Designation implements MageObject { public void addAbility(Ability ability) { ability.setSourceId(id); abilites.add(ability); + abilites.addAll(ability.getSubAbilities()); } @Override 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 diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 2feceac5e7..527ace8275 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -2298,6 +2298,7 @@ public abstract class PlayerImpl implements Player, Serializable { public void addAbility(Ability ability) { ability.setSourceId(playerId); this.abilities.add(ability); + this.abilities.addAll(ability.getSubAbilities()); } @Override