use of mage.abilities.effects.common.CopyEffect in project mage by magefree.
the class IdentityThiefEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && targetPermanent != null && sourcePermanent != null) {
ContinuousEffect copyEffect = new CopyEffect(Duration.EndOfTurn, targetPermanent, source.getSourceId());
copyEffect.setTargetPointer(new FixedTarget(sourcePermanent.getId(), game));
game.addEffect(copyEffect, source);
UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (controller.moveCardsToExile(targetPermanent, source, game, true, exileZoneId, sourcePermanent.getName())) {
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, true);
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;
}
use of mage.abilities.effects.common.CopyEffect in project mage by magefree.
the class TheMimeoplasmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) {
if (new CardsInAllGraveyardsCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this) >= 2) {
if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of"));
targetCopy.setNotTarget(true);
if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) {
Card cardToCopy = game.getCard(targetCopy.getFirstTarget());
if (cardToCopy != null) {
FilterCreatureCard filter = new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters");
filter.add(Predicates.not(new CardIdPredicate(cardToCopy.getId())));
TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(filter);
targetCounters.setNotTarget(true);
if (controller.choose(Outcome.Copy, targetCounters, source.getSourceId(), game)) {
Card cardForCounters = game.getCard(targetCounters.getFirstTarget());
if (cardForCounters != null) {
Cards cardsToExile = new CardsImpl();
cardsToExile.add(cardToCopy);
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.getControllerId(), source, game);
}
}
}
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.CopyEffect in project mage by magefree.
the class DermotaxiCopyApplier method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (sourcePermanent == null) {
return false;
}
Card card = game.getCard(sourcePermanent.getImprinted().get(0));
if (card == null) {
return false;
}
Permanent newBluePrint = new PermanentCard(card, source.getControllerId(), game);
newBluePrint.assignNewId();
DermotaxiCopyApplier applier = new DermotaxiCopyApplier();
applier.apply(game, newBluePrint, source, sourcePermanent.getId());
CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, newBluePrint, sourcePermanent.getId());
copyEffect.newId();
copyEffect.setApplier(applier);
game.addEffect(copyEffect, source);
return true;
}
use of mage.abilities.effects.common.CopyEffect in project mage by magefree.
the class DeceiverOfFormEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Card copyFromCard = controller.getLibrary().getFromTop(game);
if (copyFromCard != null) {
Cards cards = new CardsImpl(copyFromCard);
controller.revealCards(sourceObject.getIdName(), cards, game);
if (copyFromCard.isCreature(game)) {
if (controller.chooseUse(outcome, "Let creatures you control other than " + sourceObject.getLogName() + " becomes copies of " + copyFromCard.getLogName() + " until end of turn?", source, game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
if (!permanent.getId().equals(sourceObject.getId())) {
Permanent newBluePrint = null;
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);
}
}
}
}
if (controller.chooseUse(outcome, "Move " + copyFromCard.getLogName() + " to the bottom of your library?", source, game)) {
controller.moveCardToLibraryWithInfo(copyFromCard, source, game, Zone.LIBRARY, false, true);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.CopyEffect 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