if (controller != null && controller.removeFromBattlefield(this, game)) {
if (isFaceDown() && isMorphCard()) {
setFaceDown(false);
game.getCard(this.getId()).setFaceDown(false); //TODO: Do this in a better way
}
ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone, appliedEffects);
if (!game.replaceEvent(event)) {
Player owner = game.getPlayer(ownerId);
game.rememberLKI(objectId, Zone.BATTLEFIELD, this);
if (owner != null) {
this.setControllerId(ownerId); // neccessary for e.g. abilities in graveyard or hand to not have a controller != owner
switch (event.getToZone()) {
case GRAVEYARD:
owner.putInGraveyard(card, game, !flag);
break;
case HAND:
owner.getHand().add(card);
break;
case EXILED:
game.getExile().getPermanentExile().add(card);
break;
case COMMAND:
game.addCommander(new Commander(card));
break;
case LIBRARY:
if (flag) {
owner.getLibrary().putOnTop(card, game);
} else {
owner.getLibrary().putOnBottom(card, game);
}
break;
case BATTLEFIELD:
//should never happen
break;
}
game.setZone(objectId, event.getToZone());
game.addSimultaneousEvent(event);
return game.getState().getZone(objectId) == toZone;
}
}
}