use of mage.util.functions.CopyApplier in project mage by magefree.
the class LazavDimirMastermindCopyApplier method apply.
@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();
CopyApplier applier = new LazavDimirMastermindCopyApplier();
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;
}
use of mage.util.functions.CopyApplier in project mage by magefree.
the class LazavTheMultifariousCopyApplier method apply.
@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();
CopyApplier applier = new LazavTheMultifariousCopyApplier();
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;
}
use of mage.util.functions.CopyApplier in project mage by magefree.
the class ShadowKinApplier method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
cards.addAll(player.millCards(3, source, game));
}
}
if (cards.isEmpty()) {
return false;
}
TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE);
target.setNotTarget(true);
controller.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget());
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (card == null || sourcePermanent == null) {
return true;
}
controller.moveCards(card, Zone.EXILED, source, game);
Permanent blueprint = new PermanentCard(card, source.getControllerId(), game);
blueprint.assignNewId();
CopyApplier applier = new ShadowKinApplier();
applier.apply(game, blueprint, source, sourcePermanent.getId());
CopyEffect copyEffect = new CopyEffect(Duration.Custom, blueprint, sourcePermanent.getId());
copyEffect.newId();
copyEffect.setApplier(applier);
Ability newAbility = source.copy();
copyEffect.init(newAbility, game);
game.addEffect(copyEffect, newAbility);
return true;
}
use of mage.util.functions.CopyApplier in project mage by magefree.
the class VolrathTheShapestealerCopyApplier method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent volrathTheShapestealer = game.getPermanent(source.getSourceId());
Permanent newBluePrint = null;
if (controller == null || volrathTheShapestealer == null) {
return false;
}
Card copyFromCard = game.getPermanent(source.getFirstTarget());
if (copyFromCard == null) {
return true;
}
newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
newBluePrint.assignNewId();
CopyApplier applier = new VolrathTheShapestealerCopyApplier();
applier.apply(game, newBluePrint, source, volrathTheShapestealer.getId());
CopyEffect copyEffect = new CopyEffect(Duration.UntilYourNextTurn, newBluePrint, volrathTheShapestealer.getId());
copyEffect.newId();
copyEffect.setApplier(applier);
Ability newAbility = source.copy();
copyEffect.init(newAbility, game);
game.addEffect(copyEffect, newAbility);
return true;
}
use of mage.util.functions.CopyApplier 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;
}
Aggregations