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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations