Search in sources :

Example 16 with TargetAnyTarget

use of mage.target.common.TargetAnyTarget in project mage by magefree.

the class HidetsuguDevouringChaosEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Card card = player.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    PlayFromNotOwnHandZoneTargetEffect.exileAndPlayFromExile(game, source, card, TargetController.YOU, Duration.EndOfTurn, false, false, false);
    if (card.isLand(game)) {
        return true;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(card.getManaValue()), false);
    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 17 with TargetAnyTarget

use of mage.target.common.TargetAnyTarget in project mage by magefree.

the class CustomTestCard method addCustomEffect_TargetDamage.

/**
 * Add target damage ability that can be called by text: "target damage xxx"
 *
 * @param controller
 * @param damageAmount
 */
protected void addCustomEffect_TargetDamage(TestPlayer controller, int damageAmount) {
    Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(damageAmount).setText("target damage " + damageAmount), new ManaCostsImpl(""));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("target damage " + damageAmount + " for " + controller.getName(), controller, ability);
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SpellAbility(mage.abilities.SpellAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 18 with TargetAnyTarget

use of mage.target.common.TargetAnyTarget in project mage by magefree.

the class FireballTargetCreatureOrPlayer method getTargetOptions.

/**
 * This is only used by AI players
 *
 * @param source
 * @param game
 * @return
 */
@Override
public List<TargetAnyTarget> getTargetOptions(Ability source, Game game) {
    List<TargetAnyTarget> options = new ArrayList<>();
    int xVal = source.getManaCostsToPay().getX();
    if (xVal < 1) {
        return options;
    }
    for (int numberTargets = 1; numberTargets == 1 || xVal / (numberTargets - 1) > 1; numberTargets++) {
        Set<UUID> possibleTargets = possibleTargets(source.getSourceId(), source.getControllerId(), game);
        // less possible targets than we're trying to set
        if (possibleTargets.size() < numberTargets) {
            return options;
        }
        // less than 1 damage per target = 0, add no such options
        if ((xVal - (numberTargets - 1)) / numberTargets < 1) {
            continue;
        }
        possibleTargets.removeAll(getTargets());
        for (UUID targetId : possibleTargets) {
            TargetAnyTarget target = this.copy();
            target.clearChosen();
            target.addTarget(targetId, source, game, true);
            if (target.getTargets().size() == numberTargets) {
                chosen = true;
            }
            if (!target.isChosen()) {
                Iterator<UUID> it2 = possibleTargets.iterator();
                while (it2.hasNext() && !target.isChosen()) {
                    UUID nextTargetId = it2.next();
                    target.addTarget(nextTargetId, source, game, true);
                    if (target.getTargets().size() == numberTargets) {
                        chosen = true;
                    }
                }
            }
            if (target.isChosen()) {
                options.add(target);
            }
        }
    }
    return options;
}
Also used : TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 19 with TargetAnyTarget

use of mage.target.common.TargetAnyTarget 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 20 with TargetAnyTarget

use of mage.target.common.TargetAnyTarget 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

TargetAnyTarget (mage.target.common.TargetAnyTarget)23 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)20 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)11 Permanent (mage.game.permanent.Permanent)9 Player (mage.players.Player)8 Ability (mage.abilities.Ability)7 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)7 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)6 SimpleManaAbility (mage.abilities.mana.SimpleManaAbility)4 Test (org.junit.Test)4 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 Card (mage.cards.Card)3 TapSourceCost (mage.abilities.costs.common.TapSourceCost)2 CounterUnlessPaysEffect (mage.abilities.effects.common.CounterUnlessPaysEffect)2 AddConditionalManaEffect (mage.abilities.effects.mana.AddConditionalManaEffect)2 SimpleActivatedAbilityManaBuilder (mage.abilities.mana.builder.common.SimpleActivatedAbilityManaBuilder)2 Target (mage.target.Target)2 TargetPermanent (mage.target.TargetPermanent)2 TargetSpell (mage.target.TargetSpell)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2