}
@Override
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, ArrayList<UUID> appliedEffects){
ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, controllerId, fromZone, Zone.BATTLEFIELD, appliedEffects, tapped);
if (!game.replaceEvent(event)) {
if (fromZone != null) {
boolean removed = false;
switch (fromZone) {
case GRAVEYARD:
removed = game.getPlayer(ownerId).removeFromGraveyard(this, game);
break;
case HAND:
removed = game.getPlayer(ownerId).removeFromHand(this, game);
break;
case LIBRARY:
removed = game.getPlayer(ownerId).removeFromLibrary(this, game);
break;
case EXILED:
game.getExile().removeCard(this, game);
if (isFaceDown()) {
// 110.6b Permanents enter the battlefield untapped, unflipped, face up, and phased in unless a spell or ability says otherwise.
this.setFaceDown(false);
}
removed = true;
break;
case COMMAND:
// command object (commander) is only on the stack, so no removing neccessary here
removed = true;
break;
case PICK:
removed = true;
break;
default:
logger.warn("putOntoBattlefield, not fully implemented: fromZone="+fromZone);
}
game.rememberLKI(objectId, event.getFromZone(), this);
if (!removed) {
logger.warn("Couldn't find card in fromZone, card=" + getName() + ", fromZone=" + fromZone);
}
}
updateZoneChangeCounter();
PermanentCard permanent = new PermanentCard(this, controllerId);
// reset is done to end continuous effects from previous instances of that permanent (e.g undying)
game.resetForSourceId(permanent.getId());
// make sure the controller of all continuous effects of this card are switched to the current controller
game.getContinuousEffects().setController(objectId, controllerId);
game.addPermanent(permanent);
game.setZone(objectId, Zone.BATTLEFIELD);
game.setScopeRelevant(true);
permanent.setTapped(tapped);
permanent.entersBattlefield(sourceId, game, event.getFromZone(), true);
game.setScopeRelevant(false);
game.applyEffects();
game.fireEvent(new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD));
return true;
}
return false;
}