Search in sources :

Example 31 with SacrificeTargetEffect

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

the class ThunderkinAwakenerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card creatureCard = game.getCard(this.getTargetPointer().getFirst(game, source));
    if (controller != null && creatureCard != null) {
        // Return that card to the battlefield tapped and attacking
        Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect(false, true, true);
        effect.setTargetPointer(new FixedTarget(creatureCard.getId()));
        effect.apply(game, source);
        Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (permanent != null) {
            // Sacrifice it at the beginning of the next end step
            SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice " + permanent.getName(), source.getControllerId());
            sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
            game.addDelayedTriggeredAbility(delayedAbility, source);
            // info
            InfoEffect.addInfoToPermanent(game, source, permanent, "<i><b>Warning</b>: It will be sacrificed at the beginning of the next end step<i>");
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) InfoEffect(mage.abilities.effects.common.InfoEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 32 with SacrificeTargetEffect

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

the class PhantasmalMountDelayedTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetCreature = game.getPermanent(source.getFirstTarget());
    if (targetCreature != null) {
        ContinuousEffect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
        game.addEffect(effect, source);
        Effect sacrificeCreatureEffect = new SacrificeTargetEffect();
        Effect sacrificePhantasmalMountEffect = new SacrificeTargetEffect();
        ContinuousEffect gainAbility = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
        gainAbility.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
        game.addEffect(gainAbility, source);
        sacrificeCreatureEffect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
        sacrificePhantasmalMountEffect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
        DelayedTriggeredAbility dTA = new PhantasmalMountDelayedTriggeredAbility(sacrificeCreatureEffect, source.getSourceId());
        DelayedTriggeredAbility dTA2 = new PhantasmalMountDelayedTriggeredAbility(sacrificePhantasmalMountEffect, source.getFirstTarget());
        game.addDelayedTriggeredAbility(dTA, source);
        game.addDelayedTriggeredAbility(dTA2, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect)

Example 33 with SacrificeTargetEffect

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

the class PurphorossInterventionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new PurphorossInterventionToken(source.getManaCostsToPay().getX());
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    token.getLastAddedTokenIds().stream().forEach(uuid -> game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeTargetEffect().setText("sacrifice this creature").setTargetPointer(new FixedTarget(uuid, game))), source));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) PurphorossInterventionToken(mage.game.permanent.token.PurphorossInterventionToken) PurphorossInterventionToken(mage.game.permanent.token.PurphorossInterventionToken) Token(mage.game.permanent.token.Token) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect)

Example 34 with SacrificeTargetEffect

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

the class PurphurosBronzeBloodedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || !controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
        return true;
    }
    TargetCardInHand target = new TargetCardInHand(filter);
    if (!controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
        return true;
    }
    Card card = game.getCard(target.getFirstTarget());
    if (card == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        return false;
    }
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return true;
    }
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId()).setTargetPointer(new FixedTarget(permanent, game))), 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) TargetCardInHand(mage.target.common.TargetCardInHand) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 35 with SacrificeTargetEffect

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

the class WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards cards = new CardsImpl(getTargetPointer().getTargets(game, source));
        controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
        List<Permanent> toSacrifice = new ArrayList<>(cards.size());
        for (UUID targetId : cards) {
            Permanent creature = game.getPermanent(targetId);
            if (creature != null) {
                toSacrifice.add(creature);
            }
        }
        Effect effect = new SacrificeTargetEffect("Sacrifice those creatures at the beginning of the next end step", source.getControllerId());
        effect.setTargetPointer(new FixedTargets(toSacrifice, game));
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) ArrayList(java.util.ArrayList) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Aggregations

SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)40 Permanent (mage.game.permanent.Permanent)35 FixedTarget (mage.target.targetpointer.FixedTarget)34 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)31 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)20 Player (mage.players.Player)19 Card (mage.cards.Card)16 OneShotEffect (mage.abilities.effects.OneShotEffect)14 ContinuousEffect (mage.abilities.effects.ContinuousEffect)13 Effect (mage.abilities.effects.Effect)13 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)13 UUID (java.util.UUID)9 FilterCard (mage.filter.FilterCard)6 Token (mage.game.permanent.token.Token)6 TargetCardInHand (mage.target.common.TargetCardInHand)6 FixedTargets (mage.target.targetpointer.FixedTargets)6 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 MageObject (mage.MageObject)4 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)4 FilterCreatureCard (mage.filter.common.FilterCreatureCard)4