Search in sources :

Example 1 with SacrificeSourceEffect

use of mage.abilities.effects.common.SacrificeSourceEffect in project mage by magefree.

the class ViashinoSandswimmerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        if (controller.flipCoin(source, game, true)) {
            new ReturnToHandSourceEffect().apply(game, source);
            return true;
        } else {
            new SacrificeSourceEffect().apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Permanent(mage.game.permanent.Permanent) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect)

Example 2 with SacrificeSourceEffect

use of mage.abilities.effects.common.SacrificeSourceEffect in project mage by magefree.

the class NalathniDragonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ActivationInfo activationInfo = ActivationInfo.getInstance(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    activationInfo.addActivation(game);
    if (activationInfo.getActivationCounter() >= 4) {
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeSourceEffect());
        game.addDelayedTriggeredAbility(delayedAbility, source);
    }
    return true;
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ActivationInfo(mage.abilities.ActivationInfo) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect)

Example 3 with SacrificeSourceEffect

use of mage.abilities.effects.common.SacrificeSourceEffect in project mage by magefree.

the class VaporSnareEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean targetChosen = false;
    Player controller = game.getPlayer(source.getControllerId());
    TargetPermanent target = new TargetPermanent(1, 1, filter, false);
    if (controller != null && target.canChoose(source.getSourceId(), controller.getId(), game)) {
        controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            targetChosen = true;
            controller.moveCards(permanent, Zone.HAND, source, game);
        }
    }
    if (!targetChosen) {
        new SacrificeSourceEffect().apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) TargetPermanent(mage.target.TargetPermanent)

Example 4 with SacrificeSourceEffect

use of mage.abilities.effects.common.SacrificeSourceEffect in project mage by magefree.

the class FarrelitePriestEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ActivationInfo activationInfo = ActivationInfo.getInstance(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    activationInfo.addActivation(game);
    if (activationInfo.getActivationCounter() == 4) {
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeSourceEffect());
        game.addDelayedTriggeredAbility(delayedAbility, source);
    }
    return true;
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ActivationInfo(mage.abilities.ActivationInfo) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect)

Example 5 with SacrificeSourceEffect

use of mage.abilities.effects.common.SacrificeSourceEffect in project mage by magefree.

the class MinionReflectorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        for (Permanent addedToken : effect.getAddedPermanents()) {
            ContinuousEffect continuousEffect = new GainAbilityTargetEffect(new BeginningOfEndStepTriggeredAbility(new SacrificeSourceEffect(), TargetController.ANY, false), Duration.Custom);
            continuousEffect.setTargetPointer(new FixedTarget(addedToken.getId()));
            game.addEffect(continuousEffect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility)

Aggregations

SacrificeSourceEffect (mage.abilities.effects.common.SacrificeSourceEffect)11 Permanent (mage.game.permanent.Permanent)6 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)5 Player (mage.players.Player)5 ActivationInfo (mage.abilities.ActivationInfo)4 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)4 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)3 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 TargetPermanent (mage.target.TargetPermanent)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 TriggeredAbility (mage.abilities.TriggeredAbility)1 BecomesTargetTriggeredAbility (mage.abilities.common.BecomesTargetTriggeredAbility)1 BeginningOfEndStepTriggeredAbility (mage.abilities.common.BeginningOfEndStepTriggeredAbility)1 AtTheBeginOfNextCleanupDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility)1 Cost (mage.abilities.costs.Cost)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Effect (mage.abilities.effects.Effect)1