Search in sources :

Example 6 with SacrificeSourceEffect

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

the class ForceProjectionEffect 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) {
        // Create a token that is a copy of target creature
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        // except that it is an Illusion in addition to its other types
        effect.setAdditionalSubType(SubType.SPIRIT);
        effect.apply(game, source);
        // and gains "When this creature becomes the target of a spell, sacrifice it."
        Effect sacrificeEffect = new SacrificeSourceEffect();
        sacrificeEffect.setTargetPointer(new FixedTarget(effect.getAddedPermanents().get(0), game));
        TriggeredAbility ability = new BecomesTargetTriggeredAbility(sacrificeEffect, new FilterSpell());
        game.addTriggeredAbility(ability, null);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) BecomesTargetTriggeredAbility(mage.abilities.common.BecomesTargetTriggeredAbility) Player(mage.players.Player) FilterSpell(mage.filter.FilterSpell) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ScryEffect(mage.abilities.effects.keyword.ScryEffect) Effect(mage.abilities.effects.Effect) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) TriggeredAbility(mage.abilities.TriggeredAbility) BecomesTargetTriggeredAbility(mage.abilities.common.BecomesTargetTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 7 with SacrificeSourceEffect

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

the class GoblinKitesEffect 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)) {
            return true;
        } else {
            new SacrificeSourceEffect().apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect)

Example 8 with SacrificeSourceEffect

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

the class InitiatesOfTheEbonHandEffect 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 9 with SacrificeSourceEffect

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

the class PillarTombsOfAkuEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player activePlayer = game.getPlayer(game.getActivePlayerId());
    if (activePlayer == null) {
        return false;
    }
    if (activePlayer.chooseUse(Outcome.Sacrifice, "Sacrifice a creature?", source, game)) {
        Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
        if (cost.canPay(source, source, activePlayer.getId(), game) && cost.pay(source, game, source, activePlayer.getId(), true)) {
            return true;
        }
    }
    activePlayer.loseLife(5, game, source, false);
    return new SacrificeSourceEffect().apply(game, source);
}
Also used : Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 10 with SacrificeSourceEffect

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

the class DragonWhelpEffect 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)

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