Search in sources :

Example 11 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class HeatShimmerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (controller != null && permanent != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        ExileTargetEffect exileEffect = new ExileTargetEffect();
        exileEffect.setTargetPointer(new FixedTarget(effect.getAddedPermanents().get(0), 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) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 12 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class MeriekeRiBeritDelayedTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent controlledCreature = game.getPermanent(source.getFirstTarget());
    if (controlledCreature != null) {
        DelayedTriggeredAbility delayedAbility = new MeriekeRiBeritDelayedTriggeredAbility();
        delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(controlledCreature, game));
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)

Example 13 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class TreacherousUrgeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (opponent != null && sourceObject != null) {
        opponent.revealCards(sourceObject.getName(), opponent.getHand(), game);
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            int cardsHand = opponent.getHand().count(StaticFilters.FILTER_CARD_CREATURE, game);
            Card card = null;
            if (cardsHand > 0) {
                TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_CREATURE);
                if (controller.choose(Outcome.Benefit, opponent.getHand(), target, game)) {
                    card = opponent.getHand().get(target.getFirstTarget(), game);
                    if (card != null) {
                        if (controller.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);
                                SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
                                sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
                                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
                                game.addDelayedTriggeredAbility(delayedAbility, source);
                                return true;
                            }
                        }
                    }
                    return false;
                }
            }
        }
        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) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetCard(mage.target.TargetCard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 14 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class CreateTokenCopyTargetEffect method removeTokensCreatedAtEndOf.

private void removeTokensCreatedAtEndOf(Game game, Ability source, PhaseStep phaseStepToExileCards, boolean exile) {
    Effect effect;
    if (exile) {
        effect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD).setText("exile the token copies");
    } else {
        effect = new SacrificeTargetEffect("sacrifice the token copies");
    }
    effect.setTargetPointer(new FixedTargets(addedTokenPermanents, game));
    DelayedTriggeredAbility exileAbility;
    switch(phaseStepToExileCards) {
        case END_TURN:
            exileAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
            break;
        case END_COMBAT:
            exileAbility = new AtTheEndOfCombatDelayedTriggeredAbility(effect);
            break;
        default:
            return;
    }
    game.addDelayedTriggeredAbility(exileAbility, source);
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FixedTargets(mage.target.targetpointer.FixedTargets) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)

Example 15 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class BroodOfCockroachesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedLifeLost = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseLifeSourceControllerEffect(1));
    game.addDelayedTriggeredAbility(delayedLifeLost, source);
    Effect effect = new ReturnToHandTargetEffect();
    effect.setText("return {this} to your hand.");
    effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect)

Aggregations

DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)88 Permanent (mage.game.permanent.Permanent)62 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)61 FixedTarget (mage.target.targetpointer.FixedTarget)61 Player (mage.players.Player)38 Card (mage.cards.Card)30 OneShotEffect (mage.abilities.effects.OneShotEffect)27 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)27 Effect (mage.abilities.effects.Effect)25 ContinuousEffect (mage.abilities.effects.ContinuousEffect)24 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)20 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)19 UUID (java.util.UUID)14 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)14 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)13 FilterCard (mage.filter.FilterCard)9 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)9 ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)8 FilterCreatureCard (mage.filter.common.FilterCreatureCard)7 MageObjectReference (mage.MageObjectReference)6