use of mage.abilities.effects.common.continuous.BecomesAuraSourceEffect in project mage by magefree.
the class BecomesAuraAttachToManifestSourceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent enchantment = game.getPermanent(source.getSourceId());
if (controller != null && enchantment != null) {
// manifest top card
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
new ManifestEffect(1).apply(game, source);
Permanent enchantedCreature = game.getPermanent(card.getId());
if (enchantedCreature != null) {
enchantedCreature.addAttachment(enchantment.getId(), source, game);
FilterCreaturePermanent filter = new FilterCreaturePermanent();
Target target = new TargetCreaturePermanent(filter);
target.addTarget(enchantedCreature.getId(), source, game);
game.addEffect(new BecomesAuraSourceEffect(target), source);
}
}
return true;
}
return false;
}
Aggregations