Search in sources :

Example 31 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class TigerTribeHunterEffect 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, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true);
    player.choose(outcome, target, source.getSourceId(), game);
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    int power = Math.max(permanent.getPower().getValue(), 0);
    if (!permanent.sacrifice(source, game)) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(power), false, "{this} deals damage equal to the sacrificed creature's power to target creature.");
    ability.addTarget(new TargetCreaturePermanent());
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 32 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class EdgarsAwakeningTriggeredAbility method makeAbility.

private static final ReflexiveTriggeredAbility makeAbility() {
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ReturnFromGraveyardToHandTargetEffect(), false, "return target creature card from your graveyard to your hand");
    ability.addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
    return ability;
}
Also used : ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect)

Example 33 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class ExplosionOfRichesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        if (!playerId.equals(source.getControllerId()) && !player.chooseUse(outcome, "Draw a card?", source, game)) {
            continue;
        }
        if (player.drawCards(1, source, game) >= 1) {
            continue;
        }
        ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(5), false, "{this} deals damage to target opponent chosen at random");
        Target target = new TargetOpponent();
        target.setRandom(true);
        ability.addTarget(target);
        game.fireReflexiveTriggeredAbility(ability, source);
    }
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetOpponent(mage.target.common.TargetOpponent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) UUID(java.util.UUID) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 34 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class MountVelusManticoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Card card = player.discard(0, 1, false, source, game).getRandom(game);
    if (card == null) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(card.getCardType(game).size()), false, "{this} deals X damage " + "to any target, where X is the number of card types the discarded card has");
    ability.addTarget(new TargetAnyTarget());
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : Player(mage.players.Player) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) Card(mage.cards.Card) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 35 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class TheRoyalScionsCreateReflexiveTriggerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    effect.apply(game, source);
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(CardsInControllerHandCount.instance), false, "{this} deals damage to any target equal to the number of cards in your hand");
    ability.addTarget(new TargetAnyTarget());
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetAnyTarget(mage.target.common.TargetAnyTarget)

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