Search in sources :

Example 1 with BecomesAuraSourceEffect

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;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Target(mage.target.Target) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ManifestEffect(mage.abilities.effects.keyword.ManifestEffect) BecomesAuraSourceEffect(mage.abilities.effects.common.continuous.BecomesAuraSourceEffect) Card(mage.cards.Card)

Aggregations

BecomesAuraSourceEffect (mage.abilities.effects.common.continuous.BecomesAuraSourceEffect)1 ManifestEffect (mage.abilities.effects.keyword.ManifestEffect)1 Card (mage.cards.Card)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 Target (mage.target.Target)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1