Add sub abilities in TokenImpl.addAbility and PermanentImpl.addAbility (fixes #8343)

This commit is contained in:
Daniel Bomar 2021-10-22 17:32:51 -05:00
parent ed4bc46164
commit 060ea7da83
No known key found for this signature in database
GPG key ID: C86C8658F4023918
3 changed files with 53 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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());
}
}

View file

@ -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