Search in sources :

Example 16 with GainAbilityTargetEffect

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

the class FormOfTheSquirrelCantCastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player sourceController = game.getPlayer(source.getControllerId());
    if (sourceController != null) {
        CreateTokenEffect effect = new CreateTokenEffect(new SquirrelToken());
        effect.apply(game, source);
        game.getState().setValue(source.getSourceId() + "_token", effect.getLastAddedTokenIds());
        for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
            Effect loseGameEffect = new LoseGameTargetPlayerEffect();
            loseGameEffect.setTargetPointer(new FixedTarget(sourceController.getId(), game));
            LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(loseGameEffect, false);
            ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
            continuousEffect.setTargetPointer(new FixedTarget(addedTokenId, game));
            game.addEffect(continuousEffect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) LeavesBattlefieldTriggeredAbility(mage.abilities.common.LeavesBattlefieldTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) LoseGameTargetPlayerEffect(mage.abilities.effects.common.LoseGameTargetPlayerEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) LoseGameTargetPlayerEffect(mage.abilities.effects.common.LoseGameTargetPlayerEffect) CantAttackYouAllEffect(mage.abilities.effects.common.combat.CantAttackYouAllEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) SquirrelToken(mage.game.permanent.token.SquirrelToken)

Example 17 with GainAbilityTargetEffect

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

the class GisaGloriousResurrectorReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Ability exiledWithSource = (Ability) game.getState().getValue("GisaGloriousResurrectorExile" + source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()));
    if (exiledWithSource == null) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, exiledWithSource));
    if (player == null || exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    Cards cards = new CardsImpl(exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game));
    if (cards.isEmpty()) {
        return false;
    }
    player.moveCards(cards, Zone.BATTLEFIELD, source, game);
    cards.retainZone(Zone.BATTLEFIELD, game);
    if (cards.isEmpty()) {
        return false;
    }
    game.addEffect(new GainAbilityTargetEffect(new DecayedAbility(), Duration.Custom).setTargetPointer(new FixedTargets(cards, game)), source);
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) DecayedAbility(mage.abilities.keyword.DecayedAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ExileZone(mage.game.ExileZone) DecayedAbility(mage.abilities.keyword.DecayedAbility) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 18 with GainAbilityTargetEffect

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

the class GiverOfRunesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    if (player.chooseUse(outcome, "Give the targeted creature protection from colorless?", null, "Yes", "No (choose a color instead)", source, game)) {
        game.addEffect(new GainAbilityTargetEffect(new ProtectionAbility(filter), Duration.EndOfTurn), source);
        return true;
    }
    game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) GainProtectionFromColorTargetEffect(mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 19 with GainAbilityTargetEffect

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

the class GreasefangOkibaBossEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (controller == null || card == null || game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
        return false;
    }
    controller.moveCards(card, Zone.BATTLEFIELD, source, game);
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent != null) {
        ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
        hasteEffect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(hasteEffect, source);
        Effect bounceEffect = new ReturnToHandTargetEffect().setText("return it to your hand");
        bounceEffect.setTargetPointer(new FixedTarget(permanent, game));
        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(bounceEffect), source);
    }
    return true;
}
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) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 20 with GainAbilityTargetEffect

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

the class MacabreMockeryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card == null) {
        return false;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        return false;
    }
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return false;
    }
    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
    effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(effect, source);
    effect = new BoostTargetEffect(2, 0, Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(effect, source);
    Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + permanent.getLogName(), controller.getId());
    sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) Card(mage.cards.Card)

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