Search in sources :

Example 66 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.

the class TianaShipsCaretakerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
        Effect effect = new ReturnFromGraveyardToHandTargetEffect();
        effect.setTargetPointer(new FixedTarget(card, game));
        effect.setText("return that card to your hand at the beginning of the next end step");
        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect) Card(mage.cards.Card)

Example 67 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.

the class TidalWaveEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new TidalWaveWallToken();
    if (token.putOntoBattlefield(1, game, source, source.getControllerId())) {
        for (UUID tokenId : token.getLastAddedTokenIds()) {
            Permanent tokenPermanent = game.getPermanent(tokenId);
            if (tokenPermanent != null) {
                SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect();
                sacrificeEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) TidalWaveWallToken(mage.game.permanent.token.TidalWaveWallToken) Permanent(mage.game.permanent.Permanent) TidalWaveWallToken(mage.game.permanent.token.TidalWaveWallToken) Token(mage.game.permanent.token.Token) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) UUID(java.util.UUID)

Example 68 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.

the class TilonallisSummonerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        ManaCosts cost = new ManaCostsImpl("{X}{R}");
        if (controller.chooseUse(outcome, "Pay " + cost.getText() + "? If you do, you create X 1/1 red Elemental creature tokens that are tapped and attacking.", source, game)) {
            int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
            cost.add(new GenericManaCost(costX));
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                // otherwise you can undo the payment
                controller.resetStoredBookmark(game);
                CreateTokenEffect effect = new CreateTokenEffect(new TilonallisSummonerElementalToken(), costX, true, true);
                effect.apply(game, source);
                Effect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD).setText("exile those tokens unless you have the city's blessing");
                exileEffect.setTargetPointer(new FixedTargets(new CardsImpl(effect.getLastAddedTokenIds()), game));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.ANY, new InvertCondition(CitysBlessingCondition.instance)), source);
            }
        }
        return true;
    }
    return false;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) TilonallisSummonerElementalToken(mage.game.permanent.token.TilonallisSummonerElementalToken) FixedTargets(mage.target.targetpointer.FixedTargets) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) CitysBlessingHint(mage.abilities.hint.common.CitysBlessingHint) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) InvertCondition(mage.abilities.condition.InvertCondition) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) CardsImpl(mage.cards.CardsImpl) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 69 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.

the class VenserTheSojournerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        if (getTargetPointer().getFirst(game, source) != null) {
            Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
            if (permanent != null) {
                if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
                    // create delayed triggered ability
                    Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect();
                    effect.setText("Return it to the battlefield under your control at the beginning of the next end step");
                    effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
                    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) MageObject(mage.MageObject) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) Effect(mage.abilities.effects.Effect) CantBeBlockedAllEffect(mage.abilities.effects.common.combat.CantBeBlockedAllEffect) GetEmblemEffect(mage.abilities.effects.common.GetEmblemEffect)

Example 70 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility 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)

Aggregations

AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)143 FixedTarget (mage.target.targetpointer.FixedTarget)115 Permanent (mage.game.permanent.Permanent)101 Player (mage.players.Player)86 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)61 Effect (mage.abilities.effects.Effect)60 OneShotEffect (mage.abilities.effects.OneShotEffect)60 Card (mage.cards.Card)57 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)33 ContinuousEffect (mage.abilities.effects.ContinuousEffect)32 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)31 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)29 ReturnToBattlefieldUnderOwnerControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)27 UUID (java.util.UUID)24 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)21 MageObject (mage.MageObject)20 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)17 FilterCard (mage.filter.FilterCard)16 TargetPermanent (mage.target.TargetPermanent)16 FixedTargets (mage.target.targetpointer.FixedTargets)14