Search in sources :

Example 1 with AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility

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

the class GiantOysterLeaveUntapDelayedTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent oyster = game.getPermanent(source.getSourceId());
        Permanent tappedCreature = game.getPermanent(source.getFirstTarget());
        if (oyster != null && tappedCreature != null) {
            Effect addCountersEffect = new AddCountersTargetEffect(CounterType.M1M1.createInstance(1));
            addCountersEffect.setTargetPointer(getTargetPointer().getFixedTarget(game, source));
            DelayedTriggeredAbility drawStepAbility = new AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility(addCountersEffect, Duration.Custom, false);
            drawStepAbility.setControllerId(source.getControllerId());
            UUID drawStepAbilityUUID = game.addDelayedTriggeredAbility(drawStepAbility, source);
            DelayedTriggeredAbility leaveUntapDelayedTriggeredAbility = new GiantOysterLeaveUntapDelayedTriggeredAbility(drawStepAbilityUUID);
            leaveUntapDelayedTriggeredAbility.getEffects().get(0).setTargetPointer(new FixedTarget(tappedCreature, game));
            game.addDelayedTriggeredAbility(leaveUntapDelayedTriggeredAbility, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) RemoveDelayedTriggeredAbilityEffect(mage.abilities.effects.common.RemoveDelayedTriggeredAbilityEffect) RemoveAllCountersTargetEffect(mage.abilities.effects.common.counter.RemoveAllCountersTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DontUntapAsLongAsSourceTappedEffect(mage.abilities.effects.common.DontUntapAsLongAsSourceTappedEffect) AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility) UUID(java.util.UUID) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Aggregations

UUID (java.util.UUID)1 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 DontUntapAsLongAsSourceTappedEffect (mage.abilities.effects.common.DontUntapAsLongAsSourceTappedEffect)1 RemoveDelayedTriggeredAbilityEffect (mage.abilities.effects.common.RemoveDelayedTriggeredAbilityEffect)1 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)1 RemoveAllCountersTargetEffect (mage.abilities.effects.common.counter.RemoveAllCountersTargetEffect)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1