Search in sources :

Example 1 with AtTheBeginOfNextUpkeepDelayedTriggeredAbility

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

the class ArcaneDenialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = null;
    boolean countered = false;
    UUID targetId = this.getTargetPointer().getFirst(game, source);
    if (targetId != null) {
        controller = game.getPlayer(game.getControllerId(targetId));
    }
    if (targetId != null && game.getStack().counter(targetId, source, game)) {
        countered = true;
    }
    if (controller != null) {
        Effect effect = new DrawCardTargetEffect(StaticValue.get(2), false, true);
        effect.setTargetPointer(new FixedTarget(controller.getId()));
        effect.setText("Its controller may draw up to two cards");
        DelayedTriggeredAbility ability = new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(effect);
        game.addDelayedTriggeredAbility(ability, source);
    }
    return countered;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) AtTheBeginOfNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) UUID(java.util.UUID)

Example 2 with AtTheBeginOfNextUpkeepDelayedTriggeredAbility

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

the class LatNamsLegacyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !controller.getHand().isEmpty()) {
        TargetCard target = new TargetCard(Zone.HAND, new FilterCard("card to shuffle into your library"));
        controller.choose(Outcome.Detriment, controller.getHand(), target, game);
        Card card = controller.getHand().get(target.getFirstTarget(), game);
        if (card != null) {
            boolean successful = controller.moveCards(card, Zone.LIBRARY, source, game);
            controller.shuffleLibrary(source, game);
            if (successful) {
                new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new DrawCardSourceControllerEffect(2)), false).apply(game, source);
            }
        }
        return true;
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) AtTheBeginOfNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Aggregations

AtTheBeginOfNextUpkeepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility)2 CreateDelayedTriggeredAbilityEffect (mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect)2 DrawCardSourceControllerEffect (mage.abilities.effects.common.DrawCardSourceControllerEffect)2 Player (mage.players.Player)2 UUID (java.util.UUID)1 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 DrawCardTargetEffect (mage.abilities.effects.common.DrawCardTargetEffect)1 Card (mage.cards.Card)1 FilterCard (mage.filter.FilterCard)1 TargetCard (mage.target.TargetCard)1 FixedTarget (mage.target.targetpointer.FixedTarget)1