Search in sources :

Example 1 with AttachEffect

use of mage.abilities.effects.common.AttachEffect in project mage by magefree.

the class GaleaKindlerOfHopeEffect method makeAbility.

private static Ability makeAbility() {
    Ability ability = new EntersBattlefieldTriggeredAbility(new AttachEffect(Outcome.BoostCreature, "attach it to target creature you control"), false).setTriggerPhrase("When this Equipment enters the battlefield, ");
    ability.addTarget(new TargetControlledCreaturePermanent());
    return ability;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) Ability(mage.abilities.Ability) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) AttachEffect(mage.abilities.effects.common.AttachEffect)

Example 2 with AttachEffect

use of mage.abilities.effects.common.AttachEffect in project mage by magefree.

the class OldGrowthTrollContinuousEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    if (game.getState().getZoneChangeCounter(source.getSourceId()) > zoneChangeCounter) {
        discard();
        return false;
    }
    Permanent sourceObject = game.getPermanent(source.getSourceId());
    if (sourceObject == null) {
        sourceObject = game.getPermanentEntering(source.getSourceId());
    }
    if (sourceObject == null) {
        return false;
    }
    Permanent troll = sourceObject;
    switch(layer) {
        case TypeChangingEffects_4:
            troll.removeAllCardTypes(game);
            troll.addCardType(game, CardType.ENCHANTMENT);
            troll.removeAllSubTypes(game);
            troll.addSubType(game, SubType.AURA);
            break;
        case AbilityAddingRemovingEffects_6:
            // Spell Ability can be null with clone effects (ex. Moritte)
            if (troll.getSpellAbility() == null) {
                troll.addAbility(new SpellAbility(null, null), source.getSourceId(), game);
            }
            troll.getSpellAbility().getTargets().clear();
            troll.getSpellAbility().getEffects().clear();
            TargetPermanent auraTarget = new TargetPermanent(filter);
            troll.getSpellAbility().addTarget(auraTarget);
            troll.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
            troll.addAbility(new EnchantAbility(auraTarget.getTargetName()), source.getSourceId(), game);
            // add the activated ability
            troll.addAbility(makeAbility(), source.getSourceId(), game);
    }
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) SpellAbility(mage.abilities.SpellAbility) TargetPermanent(mage.target.TargetPermanent) EnchantAbility(mage.abilities.keyword.EnchantAbility) AttachEffect(mage.abilities.effects.common.AttachEffect)

Example 3 with AttachEffect

use of mage.abilities.effects.common.AttachEffect in project mage by magefree.

the class ScytheOfTheWretchedReanimateEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (card != null && controller != null) {
        controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        Effect effect = new AttachEffect(Outcome.AddAbility);
        effect.setTargetPointer(new FixedTarget(card.getId()));
        effect.apply(game, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AttachEffect(mage.abilities.effects.common.AttachEffect) BoostEquippedEffect(mage.abilities.effects.common.continuous.BoostEquippedEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) Card(mage.cards.Card) AttachEffect(mage.abilities.effects.common.AttachEffect)

Example 4 with AttachEffect

use of mage.abilities.effects.common.AttachEffect in project mage by magefree.

the class SteamVinesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent steamVines = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (steamVines != null) {
        Permanent enchantedLand = game.getPermanentOrLKIBattlefield(steamVines.getAttachedTo());
        Player controller = game.getPlayer(source.getControllerId());
        if (enchantedLand != null && controller != null) {
            Player landsController = game.getPlayer(enchantedLand.getControllerId());
            if (game.getState().getZone(enchantedLand.getId()) == Zone.BATTLEFIELD) {
                // if 2 or more Steam Vines were on a land
                enchantedLand.destroy(source, game, false);
                if (landsController != null) {
                    landsController.damage(1, source.getSourceId(), source, game);
                }
            }
            if (!game.getBattlefield().getAllActivePermanents(CardType.LAND, game).isEmpty()) {
                // lands are available on the battlefield
                Target target = new TargetLandPermanent();
                // not a target, it is chosen
                target.setNotTarget(true);
                Card steamVinesCard = game.getCard(source.getSourceId());
                if (steamVinesCard != null && landsController != null) {
                    if (landsController.choose(Outcome.DestroyPermanent, target, source.getId(), game)) {
                        if (target.getFirstTarget() != null) {
                            Permanent landChosen = game.getPermanent(target.getFirstTarget());
                            if (landChosen != null) {
                                for (Target targetTest : steamVinesCard.getSpellAbility().getTargets()) {
                                    Filter filterTest = targetTest.getFilter();
                                    if (filterTest.match(landChosen, game)) {
                                        if (game.getBattlefield().containsPermanent(landChosen.getId())) {
                                            // verify that it is still on the battlefield
                                            game.informPlayers(landsController.getLogName() + " attaches " + steamVines.getLogName() + " to " + landChosen.getLogName());
                                            Effect effect = new AttachEffect(Outcome.Neutral);
                                            effect.setTargetPointer(new FixedTarget(landChosen, game));
                                            return effect.apply(game, source);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) Filter(mage.filter.Filter) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) TargetLandPermanent(mage.target.common.TargetLandPermanent) Card(mage.cards.Card) AttachEffect(mage.abilities.effects.common.AttachEffect)

Example 5 with AttachEffect

use of mage.abilities.effects.common.AttachEffect in project mage by magefree.

the class LicidSpecialActionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent licid = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (licid != null) {
        UUID messageId = UUID.randomUUID();
        LicidContinuousEffect effect = new LicidContinuousEffect(messageId);
        effect.setTargetPointer(new FixedTarget(licid, game));
        game.addEffect(effect, source);
        new AttachEffect(Outcome.Neutral).apply(game, source);
        SpecialAction specialAction = new LicidSpecialAction(this.specialActionCost, messageId, licid.getIdName());
        new CreateSpecialActionEffect(specialAction).apply(game, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SpecialAction(mage.abilities.SpecialAction) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) UUID(java.util.UUID) CreateSpecialActionEffect(mage.abilities.effects.common.CreateSpecialActionEffect) AttachEffect(mage.abilities.effects.common.AttachEffect)

Aggregations

AttachEffect (mage.abilities.effects.common.AttachEffect)8 Permanent (mage.game.permanent.Permanent)6 Ability (mage.abilities.Ability)4 Player (mage.players.Player)4 SpellAbility (mage.abilities.SpellAbility)3 Effect (mage.abilities.effects.Effect)3 EnchantAbility (mage.abilities.keyword.EnchantAbility)3 Card (mage.cards.Card)3 Target (mage.target.Target)3 TargetPermanent (mage.target.TargetPermanent)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 UUID (java.util.UUID)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 ZoneChangeEvent (mage.game.events.ZoneChangeEvent)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2 ArrayList (java.util.ArrayList)1 MageObject (mage.MageObject)1 SpecialAction (mage.abilities.SpecialAction)1 DiesSourceTriggeredAbility (mage.abilities.common.DiesSourceTriggeredAbility)1 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)1