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