use of mage.util.functions.EmptyCopyApplier in project mage by magefree.
the class MirageMirrorCopyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Permanent copyFromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (sourcePermanent != null && copyFromPermanent != null) {
game.copyPermanent(Duration.EndOfTurn, copyFromPermanent, sourcePermanent.getId(), source, new EmptyCopyApplier());
return true;
}
return false;
}
use of mage.util.functions.EmptyCopyApplier in project mage by magefree.
the class PolymorphousRushCopyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetCreaturePermanent(new FilterCreaturePermanent(""));
target.setNotTarget(true);
target.setTargetName("a creature on the battlefield (creature to copy)");
if (target.canChoose(source.getId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Permanent copyFromCreature = game.getPermanent(target.getFirstTarget());
if (copyFromCreature != null) {
for (UUID copyToId : getTargetPointer().getTargets(game, source)) {
Permanent copyToCreature = game.getPermanent(copyToId);
if (copyToCreature != null) {
game.copyPermanent(Duration.EndOfTurn, copyFromCreature, copyToId, source, new EmptyCopyApplier());
}
}
}
}
return true;
}
return false;
}
use of mage.util.functions.EmptyCopyApplier in project mage by magefree.
the class TruePolymorphEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent copyTo = game.getPermanent(getTargetPointer().getFirst(game, source));
if (copyTo == null) {
return false;
}
Permanent copyFrom = game.getPermanentOrLKIBattlefield(source.getTargets().get(1).getFirstTarget());
if (copyFrom == null) {
return false;
}
game.copyPermanent(Duration.Custom, copyFrom, copyTo.getId(), source, new EmptyCopyApplier());
return true;
}
use of mage.util.functions.EmptyCopyApplier in project mage by magefree.
the class EsixFractalBloomWatcher method copyPermanentToToken.
private static Token copyPermanentToToken(Permanent permanent, Game game, Ability source) {
CopyApplier applier = new EmptyCopyApplier();
// handle copies of copies
Permanent copyFromPermanent = permanent;
for (ContinuousEffect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
if (!(effect instanceof CopyEffect)) {
continue;
}
CopyEffect copyEffect = (CopyEffect) effect;
// there is another copy effect that our targetPermanent copies stats from
if (!copyEffect.getSourceId().equals(permanent.getId())) {
continue;
}
MageObject object = ((CopyEffect) effect).getTarget();
if (!(object instanceof Permanent)) {
continue;
}
copyFromPermanent = (Permanent) object;
if (copyEffect.getApplier() != null) {
applier = copyEffect.getApplier();
}
}
// create token and modify all attributes permanently (without game usage)
EmptyToken token = new EmptyToken();
// needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
CardUtil.copyTo(token).from(copyFromPermanent, game);
applier.apply(game, token, source, permanent.getId());
return token;
}
use of mage.util.functions.EmptyCopyApplier in project mage by magefree.
the class NascentMetamorphEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player == null) {
return false;
}
Cards toReveal = new CardsImpl();
Card toCopy = null;
for (Card card : player.getLibrary().getCards(game)) {
toReveal.add(card);
if (card == null || !card.isCreature(game)) {
continue;
}
toCopy = card;
break;
}
Permanent permanent = game.getPermanent(source.getSourceId());
if (toCopy != null && permanent != null) {
game.copyPermanent(Duration.EndOfTurn, new PermanentCard(toCopy, source.getControllerId(), game), permanent.getId(), source, new EmptyCopyApplier());
}
player.revealCards(source, toReveal, game);
player.putCardsOnBottomOfLibrary(toReveal, game, source, false);
return true;
}
Aggregations