Handle tokens correctly in the new zone change code.

This commit is contained in:
Samuel Sandeen 2016-09-15 19:44:32 -04:00
parent 377a0edec9
commit 17d4d6c190
4 changed files with 93 additions and 129 deletions

View file

@ -30,9 +30,7 @@ package mage.game.permanent;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.token.Token;
/**
@ -94,31 +92,6 @@ public class PermanentToken extends PermanentImpl {
this.tokenDescriptor = token.getTokenDescriptor();
}
@Override
public boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag) {
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.addSimultaneousEvent(new ZoneChangeEvent(this, this.getControllerId(), Zone.BATTLEFIELD, zone));
return true;
}
}
return false;
}
@Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game) {
if (!game.replaceEvent(new ZoneChangeEvent(this, sourceId, this.getControllerId(), Zone.BATTLEFIELD, Zone.EXILED))) {
game.rememberLKI(objectId, Zone.BATTLEFIELD, this);
if (game.getPlayer(controllerId).removeFromBattlefield(this, game)) {
game.addSimultaneousEvent(new ZoneChangeEvent(this, sourceId, this.getControllerId(), Zone.BATTLEFIELD, Zone.EXILED));
return true;
}
}
return false;
}
public Token getToken() {
return token;
}