fixed tapped for mana events not working for sacrificed tokens

This commit is contained in:
Evan Kranzler 2021-07-30 21:54:00 -04:00
parent f4e454c54c
commit 4125d1eb46
2 changed files with 25 additions and 0 deletions

View file

@ -13,6 +13,7 @@ public class KinnanBonderProdigyTest extends CardTestPlayerBase {
private static final String kinnan = "Kinnan, Bonder Prodigy";
private static final String egg = "Golden Egg";
private static final String hovermyr = "Hovermyr";
private static final String strike = "Strike It Rich";
@Test
public void testSacrificedPermanent() {
@ -32,4 +33,23 @@ public class KinnanBonderProdigyTest extends CardTestPlayerBase {
assertPermanentCount(playerA, egg, 0);
assertGraveyardCount(playerA, egg, 1);
}
@Test
public void testSacrificedToken() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
addCard(Zone.BATTLEFIELD, playerA, kinnan);
addCard(Zone.HAND, playerA, strike);
addCard(Zone.HAND, playerA, hovermyr);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, strike);
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hovermyr);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, hovermyr, 1);
assertPermanentCount(playerA, "Treasure", 0);
}
}

View file

@ -22,6 +22,7 @@ import mage.game.command.Emblem;
import mage.game.command.Plane;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.game.stack.Spell;
import mage.game.stack.StackAbility;
import mage.players.Player;
@ -1258,6 +1259,10 @@ public abstract class AbilityImpl implements Ability {
@Override
public Permanent getSourcePermanentOrLKI(Game game) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getSourceId());
if (permanent instanceof PermanentToken) {
return permanent;
}
if (getSourceObjectZoneChangeCounter() == 0
|| getSourceObjectZoneChangeCounter() == game.getState().getZoneChangeCounter(getSourceId())) {
return game.getPermanent(getSourceId());