Search in sources :

Example 6 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class NorrittDelayedDestroyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    DestroyTargetEffect effect = new DestroyTargetEffect();
    effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance));
    delayedAbility.getDuration();
    delayedAbility.getTargets().addAll(source.getTargets());
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) InvertCondition(mage.abilities.condition.InvertCondition)

Example 7 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class PsychicTheftWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (opponent == null) {
        return false;
    }
    opponent.revealCards(CardUtil.getSourceName(game, source), opponent.getHand(), game);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int cardsHand = opponent.getHand().count(filter, game);
    Card chosenCard = null;
    if (cardsHand > 0) {
        TargetCard target = new TargetCard(Zone.HAND, filter);
        if (controller.choose(Outcome.Exile, opponent.getHand(), target, game)) {
            chosenCard = opponent.getHand().get(target.getFirstTarget(), game);
        }
    }
    if (chosenCard == null) {
        return false;
    }
    controller.moveCardToExileWithInfo(chosenCard, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source), source, game, Zone.HAND, true);
    CardUtil.makeCardPlayable(game, source, chosenCard, Duration.Custom, false);
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ConditionalOneShotEffect(new ReturnFromExileEffect(Zone.HAND), new PsychicTheftCondition(chosenCard, game), "if you haven't cast it, return it to its owner's hand.")), source);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ReturnFromExileEffect(mage.abilities.effects.common.ReturnFromExileEffect) TargetCard(mage.target.TargetCard) ConditionalOneShotEffect(mage.abilities.decorator.ConditionalOneShotEffect) TargetCard(mage.target.TargetCard) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) Card(mage.cards.Card)

Example 8 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class PuppeteerCliqueEffect 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 hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
    hasteEffect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(hasteEffect, source);
    ExileTargetEffect exileEffect = new ExileTargetEffect("exile " + permanent.getLogName());
    exileEffect.setTargetPointer(new FixedTarget(permanent, game));
    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.YOU);
    game.addDelayedTriggeredAbility(delayedAbility, 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) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 9 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class MistmeadowWitchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (player == null || permanent == null) {
        return false;
    }
    player.moveCardsToExile(permanent, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(Zone.BATTLEFIELD, "return the exiled card to the battlefield under its owner's control")), source);
    return true;
}
Also used : Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent)

Example 10 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class AchHansRunEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    String cardName = ChooseACardNameEffect.TypeOfName.CREATURE_NAME.getChoice(controller, game, source, false);
    game.informPlayers(controller.getLogName() + ": \"Ach! Hans, run! It's the " + cardName + "!\"");
    FilterCard nameFilter = new FilterCard();
    nameFilter.add(new NamePredicate(cardName));
    TargetCardInLibrary target = new TargetCardInLibrary(1, 1, nameFilter);
    if (!controller.searchLibrary(target, source, game)) {
        return false;
    }
    Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
    if (card == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        return false;
    }
    Permanent creature = game.getPermanent(card.getId());
    if (creature == null) {
        return false;
    }
    // gains haste
    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
    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);
    controller.shuffleLibrary(source, game);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Permanent(mage.game.permanent.Permanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) 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