use of mage.game.permanent.PermanentCard 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.game.permanent.PermanentCard 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