Search in sources :

Example 11 with ReflexiveTriggeredAbility

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;
}
Also used : SacrificeOpponentsEffect(mage.abilities.effects.common.SacrificeOpponentsEffect) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Example 12 with ReflexiveTriggeredAbility

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;
}
Also used : Player(mage.players.Player) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetCard(mage.target.TargetCard) MageObjectReference(mage.MageObjectReference) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard)

Example 13 with ReflexiveTriggeredAbility

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;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 14 with ReflexiveTriggeredAbility

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;
}
Also used : Permanent(mage.game.permanent.Permanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 15 with ReflexiveTriggeredAbility

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;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) DamageAllEffect(mage.abilities.effects.common.DamageAllEffect) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) ChoiceImpl(mage.choices.ChoiceImpl) HashSet(java.util.HashSet)

Aggregations

ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)37 Player (mage.players.Player)23 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)15 Permanent (mage.game.permanent.Permanent)13 TargetPermanent (mage.target.TargetPermanent)12 TargetAnyTarget (mage.target.common.TargetAnyTarget)11 UUID (java.util.UUID)6 Card (mage.cards.Card)6 FilterPermanent (mage.filter.FilterPermanent)6 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)5 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)4 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)4 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)3 DoWhenCostPaid (mage.abilities.effects.common.DoWhenCostPaid)3 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)3 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)3 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Mode (mage.abilities.Mode)2 ManaCosts (mage.abilities.costs.mana.ManaCosts)2