CopyEffect copyEffect = (CopyEffect) effect; if (copyEffect.getSourceId().equals(copyFromPermanent.getId())) { MageObject oldBluePrint = ((CopyEffect) effect).getTarget(); if (oldBluePrint instanceof Permanent) { CopyEffect newEffect = new CopyEffect(duration, newBluePrint, copyToPermanentId); newEffect.newId(); newEffect.setApplier(applier); Ability newAbility = source.copy(); newEffect.init(newAbility, this); CopyEffect copyEffect = (CopyEffect) effect; if (copyEffect.getSourceId().equals(copyToPermanentId) && copyEffect.getDuration() == Duration.Custom) { copyEffect.discard();
@Override public boolean apply(Game game, Ability source) { if (affectedObjectList.isEmpty()) { this.discard(); return false; } Permanent permanent = affectedObjectList.get(0).getPermanent(game); if (permanent == null) { permanent = (Permanent) game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD, source.getSourceObjectZoneChangeCounter()); // As long as the permanent is still in the LKI continue to copy to get triggered abilities to TriggeredAbilites for dies events. if (permanent == null) { discard(); return false; } } return copyToPermanent(permanent, game, source); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent lazavTheMultifarious = game.getPermanent(source.getSourceId()); Permanent newBluePrint = null; if (controller != null && lazavTheMultifarious != null) { Card copyFromCard = game.getCard(source.getFirstTarget()); if (copyFromCard != null) { newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game); newBluePrint.assignNewId(); ApplyToPermanent applier = new LazavTheMultifariousApplier(); applier.apply(game, newBluePrint, source, lazavTheMultifarious.getId()); CopyEffect copyEffect = new CopyEffect(Duration.Custom, newBluePrint, lazavTheMultifarious.getId()); copyEffect.newId(); copyEffect.setApplier(applier); Ability newAbility = source.copy(); copyEffect.init(newAbility, game); game.addEffect(copyEffect, newAbility); } return true; } return false; } }
newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game); newBluePrint.assignNewId(); CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, newBluePrint, permanent.getId()); copyEffect.newId(); Ability newAbility = source.copy(); copyEffect.init(newAbility, game); game.addEffect(copyEffect, newAbility);
@Override public CopyEffect copy() { return new CopyEffect(this); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); if (controller != null && permanent != null) { permanent.removeAllAbilities(source.getSourceId(), game); // Set any previous copy effects to 'discarded' for (Effect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) { if (effect instanceof CopyEffect) { CopyEffect copyEffect = (CopyEffect) effect; if (copyEffect.getSourceId().equals(permanent.getId())) { copyEffect.discard(); } } } permanent.turnFaceDown(game, source.getControllerId()); permanent.setManifested(false); permanent.setMorphed(true); return permanent.isFaceDown(game); } return false; } }
CopyEffect copyEffect = (CopyEffect) effect; if (copyEffect.getSourceId().equals(permanent.getId())) { MageObject object = ((CopyEffect) effect).getTarget(); if (object instanceof Permanent) { copyFromPermanent = (Permanent) object; if (copyEffect.getApplier() != null) { applier = copyEffect.getApplier();
if (copyFromObject instanceof Permanent) { for (Ability ability : ((Permanent) copyFromObject).getAbilities(game)) { permanent.addAbility(ability, getSourceId(), game, false); // no new Id so consumed replacement effects are known while new continuousEffects.apply happen. permanent.addAbility(ability, getSourceId(), game, false); // no new Id so consumed replacement effects are known while new continuousEffects.apply happen.
@Override public void init(Ability source, Game game) { super.init(source, game); if (!(copyFromObject instanceof Permanent) && (copyFromObject instanceof Card)) { this.copyFromObject = new PermanentCard((Card) copyFromObject, source.getControllerId(), game); } Permanent permanent = game.getPermanent(copyToObjectId); if (permanent != null) { affectedObjectList.add(new MageObjectReference(permanent, game)); } else if (source.getAbilityType() == AbilityType.STATIC) { // for replacement effects that let a permanent enter the battlefield as a copy of another permanent we need to apply that copy // before the permanent is added to the battlefield permanent = game.getPermanentEntering(copyToObjectId); if (permanent != null) { copyToPermanent(permanent, game, source); // set reference to the permanent later on the battlefield so we have to add already one (if no token) to the zone change counter int ZCCDiff = 1; if (permanent instanceof PermanentToken) { ZCCDiff = 0; } affectedObjectList.add(new MageObjectReference(permanent.getId(), game.getState().getZoneChangeCounter(copyToObjectId) + ZCCDiff, game)); } } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent lazavDimirMastermind = game.getPermanent(source.getSourceId()); Permanent newBluePrint = null; if (controller != null && lazavDimirMastermind != null) { Card copyFromCard = game.getCard(((FixedTarget) getTargetPointer()).getTarget()); if (copyFromCard != null) { newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game); newBluePrint.assignNewId(); ApplyToPermanent applier = new LazavDimirMastermindApplier(); applier.apply(game, newBluePrint, source, lazavDimirMastermind.getId()); CopyEffect copyEffect = new CopyEffect(Duration.Custom, newBluePrint, lazavDimirMastermind.getId()); copyEffect.newId(); copyEffect.setApplier(applier); Ability newAbility = source.copy(); copyEffect.init(newAbility, game); game.addEffect(copyEffect, newAbility); } return true; } return false; } }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { game.addEffect(new CopyEffect(Duration.Custom, new AngelVigilanceToken(), event.getTargetId()), source); return false; }
@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(); ApplyToPermanent applier = new DimirDoppelgangerApplier(); 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; } }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourceObject != null) { Permanent permanentReset = sourceObject.copy(); permanentReset.getCounters(game).clear(); permanentReset.getPower().resetToBaseValue(); permanentReset.getToughness().resetToBaseValue(); game.addEffect(new CopyEffect(Duration.Custom, permanentReset, event.getTargetId()), source); } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player != null && sourcePermanent != null) { if (player.searchLibrary(target, game)) { for (UUID cardId : target.getTargets()) { Card card = player.getLibrary().getCard(cardId, game); if (card != null) { player.moveCards(card, Zone.GRAVEYARD, source, game); CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, card, source.getSourceId()); game.addEffect(copyEffect, source); } } } player.shuffleLibrary(source, game); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { Target target = new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")); target.setNotTarget(true); if (target.canChoose(source.getControllerId(), game)) { player.choose(outcome, target, source.getSourceId(), game); Card copyFromCard = game.getCard(target.getFirstTarget()); if (copyFromCard != null) { CopyEffect copyEffect = new CopyEffect(Duration.Custom, copyFromCard, source.getSourceId()); game.addEffect(copyEffect, source); } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player activePlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); MageObject sourceObject = game.getObject(source.getSourceId()); if (activePlayer != null && sourceObject != null) { Card card = activePlayer.getLibrary().getFromTop(game); if (card != null) { activePlayer.revealCards(sourceObject.getIdName(), new CardsImpl(card), game); if (card.isCreature()) { activePlayer.moveCards(activePlayer.getLibrary().getTopCards(game, 1), Zone.GRAVEYARD, source, game); CopyEffect copyEffect = new CopyEffect(Duration.Custom, card, source.getSourceId()); game.addEffect(copyEffect, source); } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); if (targetPlayer != null) { TargetCard targetCard = new TargetCard(0, 1, Zone.HAND, new FilterCreatureCard()); controller.choose(outcome, targetPlayer.getHand(), targetCard, game); Card copyFromCard = game.getCard(targetCard.getFirstTarget()); if (copyFromCard != null) { game.informPlayers(controller.getLogName() + " chooses to copy " + copyFromCard.getName()); CopyEffect copyEffect = new CopyEffect(Duration.Custom, copyFromCard, source.getSourceId()); game.addEffect(copyEffect, source); } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && permanent != null && sourcePermanent != null) { Permanent permanentReset = permanent.copy(); permanentReset.getCounters(game).clear(); permanentReset.getPower().resetToBaseValue(); permanentReset.getToughness().resetToBaseValue(); CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, permanentReset, source.getSourceId()); if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) { // Copy exiled permanent game.addEffect(copyEffect, source); // Create delayed triggered ability Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(); effect.setText("Return the exiled card to the battlefield under its owner's control at the beginning of the next end step"); effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source); return true; } } return false; }
cardsToExile.add(cardForCounters); controller.moveCards(cardsToExile, Zone.EXILED, source, game); CopyEffect copyEffect = new CopyEffect(Duration.Custom, cardToCopy, source.getSourceId()); game.addEffect(copyEffect, source); permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), source, game);