From b06637df53d2a8aef19cadf4e40b3c802ad0ba08 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 28 Nov 2014 17:38:20 +0100 Subject: [PATCH] * Fixed a problem that dies triggered abilities did not work for token permanents. Fixed that triggered and continuous effects from token from tokens that left the gane were not removed from the game. --- Mage/src/mage/game/permanent/PermanentToken.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Mage/src/mage/game/permanent/PermanentToken.java b/Mage/src/mage/game/permanent/PermanentToken.java index a50b962e25a..19c8e5216b7 100644 --- a/Mage/src/mage/game/permanent/PermanentToken.java +++ b/Mage/src/mage/game/permanent/PermanentToken.java @@ -88,7 +88,10 @@ public class PermanentToken extends PermanentImpl { if (!game.replaceEvent(new ZoneChangeEvent(this, this.getControllerId(), Zone.BATTLEFIELD, zone))) { game.rememberLKI(objectId, Zone.BATTLEFIELD, this); if (game.getPlayer(controllerId).removeFromBattlefield(this, game)) { + game.setZone(objectId, zone); // needed for triggered dies abilities game.fireEvent(new ZoneChangeEvent(this, this.getControllerId(), Zone.BATTLEFIELD, zone)); + game.getState().resetTriggersForSourceId(this.getId());// if token is gone triggered abilities no longer needed + game.getState().getContinuousEffects().removeGainedEffectsForSource(this.getId()); return true; } } @@ -116,4 +119,14 @@ public class PermanentToken extends PermanentImpl { return new PermanentToken(this); } + @Override + public void addAbility(Ability ability, Game game) { + if (!abilities.containsKey(ability.getId())) { + Ability copyAbility = ability.copy(); + copyAbility.setControllerId(controllerId); + copyAbility.setSourceId(objectId); + game.getState().addAbility(copyAbility, this.getId(), this); + abilities.add(copyAbility); + } + } }