use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.
the class RavenousRotbellyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetPermanent target = new TargetPermanent(0, 3, filter, true);
player.choose(outcome, target, source.getSourceId(), game);
int amount = 0;
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null && permanent.sacrifice(source, game)) {
amount++;
}
}
if (amount < 1) {
return false;
}
game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new SacrificeOpponentsEffect(amount, StaticFilters.FILTER_PERMANENT_CREATURES), false, "each opponent sacrifices that many creatures"), source);
return true;
}
use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.
the class ViviensInvocationDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
if (cards.isEmpty()) {
return true;
}
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
target.setNotTarget(true);
controller.choose(Outcome.PutCreatureInPlay, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card == null) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
cards.remove(card);
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ViviensInvocationDamageEffect(new MageObjectReference(permanent, game)), false, "it deals damage equals to its power to target creature an opponent controls");
ability.addTarget(new TargetOpponentsCreaturePermanent());
game.fireReflexiveTriggeredAbility(ability, source);
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.
the class WildbornPreserverCreateReflexiveTriggerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ManaCosts cost = new ManaCostsImpl("{X}");
if (player == null) {
return false;
}
if (!player.chooseUse(outcome, "Pay " + cost.getText() + "?", source, game)) {
return false;
}
int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
cost.add(new GenericManaCost(costX));
if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
return false;
}
game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(costX)), false, "put X +1/+1 counters on {this}"), source);
return true;
}
use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.
the class InfernoOfTheStarMountsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null && permanent.getPower().getValue() == 20) {
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(20), false, this.staticText);
ability.addTarget(new TargetAnyTarget());
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
return false;
}
use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.
the class LavabrinkFloodgatesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player == null || permanent == null) {
return false;
}
Choice choice = new ChoiceImpl();
choice.setChoices(new HashSet(Arrays.asList("Add a doom counter", "Remove a doom counter", "Do nothing")));
player.choose(outcome, choice, game);
switch(choice.getChoice()) {
case "Add a doom counter":
permanent.addCounters(CounterType.DOOM.createInstance(), player.getId(), source, game);
break;
case "Remove a doom counter":
permanent.removeCounters(CounterType.DOOM.createInstance(), source, game);
break;
case "Do nothing":
default:
break;
}
if (permanent.getCounters(game).getCount(CounterType.DOOM) < 3 || !permanent.sacrifice(source, game)) {
return true;
}
game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new DamageAllEffect(6, StaticFilters.FILTER_PERMANENT_CREATURE), false, "it deals 6 damage to each creature."), source);
return true;
}
Aggregations