Search in sources :

Example 66 with GainAbilityTargetEffect

use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.

the class PostmortemLungeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getFirstTarget());
    if (card != null) {
        Player cardOwner = game.getPlayer(card.getOwnerId());
        if (cardOwner == null) {
            return false;
        }
        if (cardOwner.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            Permanent permanent = game.getPermanent(card.getId());
            if (permanent != null) {
                ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                effect.setTargetPointer(new FixedTarget(permanent, game));
                game.addEffect(effect, source);
                ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
                exileEffect.setTargetPointer(new FixedTarget(permanent, game));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 67 with GainAbilityTargetEffect

use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.

the class RuneswordCantBeRegeneratedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
    Permanent targetObject = game.getPermanent(this.getTargetPointer().getFirst(game, source));
    if (sourceObject != null && targetObject != null) {
        Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + sourceObject.getName());
        sacrificeEffect.setTargetPointer(new FixedTarget(sourceObject, game));
        LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(sacrificeEffect, false);
        triggerAbility.setRuleVisible(false);
        ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.EndOfTurn);
        continuousEffect.setTargetPointer(new FixedTarget(targetObject, game));
        game.addEffect(continuousEffect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) LeavesBattlefieldTriggeredAbility(mage.abilities.common.LeavesBattlefieldTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 68 with GainAbilityTargetEffect

use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.

the class WhipOfErebosReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && card != null) {
        if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            Permanent creature = game.getPermanent(card.getId());
            if (creature != null) {
                // gains haste
                ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                effect.setTargetPointer(new FixedTarget(creature, game));
                game.addEffect(effect, source);
                // Exile at begin of next end step
                ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
                exileEffect.setTargetPointer(new FixedTarget(creature, game));
                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
                game.addDelayedTriggeredAbility(delayedAbility, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 69 with GainAbilityTargetEffect

use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.

the class FuriousResistanceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(source.getFirstTarget());
    if (target == null) {
        return false;
    }
    ContinuousEffect effect = new BoostTargetEffect(3, 0, Duration.EndOfTurn);
    ContinuousEffect effect2 = new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(target.getId(), game));
    effect2.setTargetPointer(new FixedTarget(target.getId(), game));
    game.addEffect(effect, source);
    game.addEffect(effect2, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 70 with GainAbilityTargetEffect

use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.

the class GiltLeafAmbushCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        CreateTokenEffect effect = new CreateTokenEffect(new ElfWarriorToken(), 2);
        effect.apply(game, source);
        if (ClashEffect.getInstance().apply(game, source)) {
            for (UUID tokenId : effect.getLastAddedTokenIds()) {
                Permanent token = game.getPermanent(tokenId);
                if (token != null) {
                    ContinuousEffect continuousEffect = new GainAbilityTargetEffect(DeathtouchAbility.getInstance(), Duration.EndOfTurn);
                    continuousEffect.setTargetPointer(new FixedTarget(tokenId));
                    game.addEffect(continuousEffect, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) ElfWarriorToken(mage.game.permanent.token.ElfWarriorToken)

Aggregations

GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)125 FixedTarget (mage.target.targetpointer.FixedTarget)96 Permanent (mage.game.permanent.Permanent)93 ContinuousEffect (mage.abilities.effects.ContinuousEffect)76 Player (mage.players.Player)76 Card (mage.cards.Card)42 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)28 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)22 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)21 UUID (java.util.UUID)18 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)17 Effect (mage.abilities.effects.Effect)16 OneShotEffect (mage.abilities.effects.OneShotEffect)15 FilterCard (mage.filter.FilterCard)15 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)15 TargetPermanent (mage.target.TargetPermanent)15 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)14 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)13 FilterCreatureCard (mage.filter.common.FilterCreatureCard)12 FixedTargets (mage.target.targetpointer.FixedTargets)12