use of mage.util.functions.CopyApplier in project mage by magefree.
the class DimirDoppelgangerCopyApplier method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent dimirDoppelganger = game.getPermanent(source.getSourceId());
Permanent newBluePrint = null;
if (controller != null && dimirDoppelganger != null) {
Card copyFromCard = game.getCard(source.getFirstTarget());
if (copyFromCard != null) {
Cards cardsToExile = new CardsImpl();
cardsToExile.add(copyFromCard);
controller.moveCards(cardsToExile, Zone.EXILED, source, game);
newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
newBluePrint.assignNewId();
CopyApplier applier = new DimirDoppelgangerCopyApplier();
applier.apply(game, newBluePrint, source, dimirDoppelganger.getId());
CopyEffect copyEffect = new CopyEffect(Duration.Custom, newBluePrint, dimirDoppelganger.getId());
copyEffect.newId();
copyEffect.setApplier(applier);
Ability newAbility = source.copy();
copyEffect.init(newAbility, game);
game.addEffect(copyEffect, newAbility);
}
return true;
}
return false;
}
Aggregations