Search in sources :

Example 21 with SacrificeTargetEffect

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

the class FatalFrenzyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetCreature = game.getPermanent(source.getFirstTarget());
    if (targetCreature != null) {
        SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice this", source.getControllerId());
        sacrificeEffect.setTargetPointer(new FixedTarget(targetCreature, game));
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
        game.addDelayedTriggeredAbility(delayedAbility, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect)

Example 22 with SacrificeTargetEffect

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

the class KamiOfIndustryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (player == null || card == null) {
        return false;
    }
    player.moveCards(card, Zone.BATTLEFIELD, source, game);
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return false;
    }
    game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance()).setTargetPointer(new FixedTarget(permanent, game)), source);
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeTargetEffect("sacrifice it").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) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card) FilterArtifactCard(mage.filter.common.FilterArtifactCard)

Example 23 with SacrificeTargetEffect

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

the class KrovikanVampireDelayedTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent krovikanVampire = game.getPermanent(source.getSourceId());
    creaturesAffected = (Set<UUID>) game.getState().getValue(source.getSourceId() + "creatureToGainControl");
    if (creaturesAffected != null && controller != null && krovikanVampire != null) {
        creaturesAffected.stream().map((creatureId) -> {
            controller.moveCards(game.getCard(creatureId), Zone.BATTLEFIELD, source, game, false, false, false, null);
            return creatureId;
        }).map((creatureId) -> {
            OneShotEffect effect = new SacrificeTargetEffect();
            effect.setText("Sacrifice this if Krovikan Vampire leaves the battlefield or its current controller loses control of it.");
            effect.setTargetPointer(new FixedTarget(creatureId, game));
            return effect;
        }).map((effect) -> new KrovikanVampireDelayedTriggeredAbility(effect, krovikanVampire.getId())).forEachOrdered((dTA) -> {
            game.addDelayedTriggeredAbility(dTA, source);
        });
        creaturesAffected.clear();
        return true;
    }
    return false;
}
Also used : Condition(mage.abilities.condition.Condition) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) Set(java.util.Set) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) MageInt(mage.MageInt) BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility) Player(mage.players.Player) FixedTarget(mage.target.targetpointer.FixedTarget) CardSetInfo(mage.cards.CardSetInfo) HashSet(java.util.HashSet) Game(mage.game.Game) Watcher(mage.watchers.Watcher) Effect(mage.abilities.effects.Effect) GameEvent(mage.game.events.GameEvent) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) mage.constants(mage.constants) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) UUID(java.util.UUID) OneShotEffect(mage.abilities.effects.OneShotEffect)

Example 24 with SacrificeTargetEffect

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

the class SlaveOfBolasEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
        SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice this", source.getControllerId());
        sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect)

Example 25 with SacrificeTargetEffect

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

the class SneakAttackEffect 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(StaticFilters.FILTER_CARD_CREATURE);
    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(CardUtil.getDefaultCardSideForBattlefield(game, card).getId());
    if (permanent == null) {
        return true;
    }
    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
    effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(effect, source);
    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) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) Card(mage.cards.Card)

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