Search in sources :

Example 71 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class SavageSwipeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    if (permanent.getPower().getValue() == 2) {
        ContinuousEffect effect = new BoostTargetEffect(2, 2, Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
        game.getState().processAction(game);
    }
    return new FightTargetsEffect().apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) FightTargetsEffect(mage.abilities.effects.common.FightTargetsEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 72 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class SkyclawThrashEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent sourcePermanent = game.getPermanent(source.getSourceId());
        if (controller.flipCoin(source, game, true) && sourcePermanent != null) {
            ContinuousEffect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(sourcePermanent, game));
            game.addEffect(effect, source);
            effect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(sourcePermanent, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 73 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class StormHeraldAttachableToPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        FilterCard filter = new FilterCard("aura cards to attach to creatures you control");
        filter.add(SubType.AURA.getPredicate());
        filter.add(new StormHeraldAttachablePredicate(controller.getId()));
        Set<Card> possibleTargets = controller.getGraveyard().getCards(filter, source.getSourceId(), controller.getId(), game);
        if (!possibleTargets.isEmpty()) {
            TargetCard targetAuras = new TargetCard(0, Integer.MAX_VALUE, Zone.GRAVEYARD, filter);
            targetAuras.setNotTarget(true);
            controller.chooseTarget(outcome, new CardsImpl(possibleTargets), targetAuras, source, game);
            // Move the cards to the battlefield to a creature you control
            List<Permanent> toExile = new ArrayList<>();
            for (UUID auraId : targetAuras.getTargets()) {
                Card auraCard = game.getCard(auraId);
                if (auraCard != null) {
                    FilterPermanent filterAttachTo = new FilterControlledCreaturePermanent("creature you control to attach " + auraCard.getIdName() + " to");
                    filterAttachTo.add(new StormHeraldAttachableToPredicate(auraCard));
                    TargetPermanent targetCreature = new TargetPermanent(filterAttachTo);
                    targetCreature.setNotTarget(true);
                    if (controller.choose(Outcome.PutCardInPlay, targetCreature, source.getSourceId(), game)) {
                        Permanent targetPermanent = game.getPermanent(targetCreature.getFirstTarget());
                        if (!targetPermanent.cantBeAttachedBy(auraCard, source, game, true)) {
                            game.getState().setValue("attachTo:" + auraCard.getId(), targetPermanent);
                            controller.moveCards(auraCard, Zone.BATTLEFIELD, source, game);
                            targetPermanent.addAttachment(auraCard.getId(), source, game);
                            Permanent permanent = game.getPermanent(auraId);
                            if (permanent != null) {
                                toExile.add(permanent);
                            }
                        }
                    }
                }
            }
            ContinuousEffect continuousEffect = new StormHeraldReplacementEffect();
            continuousEffect.setTargetPointer(new FixedTargets(toExile, game));
            game.addEffect(continuousEffect, source);
            Effect exileEffect = new ExileTargetEffect("exile those Auras");
            exileEffect.setTargetPointer(new FixedTargets(toExile, game));
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) FixedTargets(mage.target.targetpointer.FixedTargets) ArrayList(java.util.ArrayList) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetCard(mage.target.TargetCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) TargetPermanent(mage.target.TargetPermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 74 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class WingedTempleOfOrazcaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
    if (creature != null && creature.isCreature(game)) {
        int pow = creature.getPower().getValue();
        ContinuousEffect effect = new BoostTargetEffect(pow, pow, Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(creature, game));
        game.addEffect(effect, source);
        effect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(creature, game));
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 75 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class AkroanHorseCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Target target = new TargetOpponent();
    target.setNotTarget(true);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseTarget(outcome, target, source, game)) {
            ContinuousEffect effect = new AkroanHorseGainControlEffect(Duration.Custom, target.getFirstTarget());
            effect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) TargetOpponent(mage.target.common.TargetOpponent) Player(mage.players.Player) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Aggregations

ContinuousEffect (mage.abilities.effects.ContinuousEffect)322 FixedTarget (mage.target.targetpointer.FixedTarget)245 Player (mage.players.Player)225 Permanent (mage.game.permanent.Permanent)202 Card (mage.cards.Card)97 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)76 UUID (java.util.UUID)65 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)55 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)50 MageObject (mage.MageObject)47 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)43 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)37 FilterCard (mage.filter.FilterCard)34 TargetPermanent (mage.target.TargetPermanent)33 Effect (mage.abilities.effects.Effect)32 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)31 OneShotEffect (mage.abilities.effects.OneShotEffect)30 Target (mage.target.Target)30 FilterPermanent (mage.filter.FilterPermanent)24 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)23