Search in sources :

Example 21 with TargetAnyTarget

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

the class KothOfTheHammerThirdEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    switch(layer) {
        case AbilityAddingRemovingEffects_6:
            if (sublayer == SubLayer.NA) {
                for (Permanent permanent : game.getBattlefield().getActivePermanents(mountains, source.getControllerId(), source.getSourceId(), game)) {
                    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost());
                    ability.addTarget(new TargetAnyTarget());
                    permanent.addAbility(ability, source.getSourceId(), game);
                }
            }
            break;
    }
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TapSourceCost(mage.abilities.costs.common.TapSourceCost) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 22 with TargetAnyTarget

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

the class CalibratedBlastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl();
    for (Card card : player.getLibrary().getCards(game)) {
        cards.add(card);
        if (card.isLand(game)) {
            continue;
        }
        ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(card.getManaValue()), false, "When you reveal " + "a nonland card this way, {this} deals damage equal to that card's mana value to any target");
        ability.addTarget(new TargetAnyTarget());
        game.fireReflexiveTriggeredAbility(ability, source);
        break;
    }
    player.revealCards(source, cards, game);
    player.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 23 with TargetAnyTarget

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

the class HumanPlayer method assignDamage.

@Override
public void assignDamage(int damage, java.util.List<UUID> targets, String singleTargetName, UUID attackerId, Ability source, Game game) {
    updateGameStatePriority("assignDamage", game);
    int remainingDamage = damage;
    while (remainingDamage > 0 && canRespond()) {
        Target target = new TargetAnyTarget();
        target.setNotTarget(true);
        if (singleTargetName != null) {
            target.setTargetName(singleTargetName);
        }
        choose(Outcome.Damage, target, source.getSourceId(), game);
        if (targets.isEmpty() || targets.contains(target.getFirstTarget())) {
            int damageAmount = getAmount(0, remainingDamage, "Select amount", game);
            Permanent permanent = game.getPermanent(target.getFirstTarget());
            if (permanent != null) {
                permanent.damage(damageAmount, attackerId, source, game, false, true);
                remainingDamage -= damageAmount;
            } else {
                Player player = game.getPlayer(target.getFirstTarget());
                if (player != null) {
                    player.damage(damageAmount, attackerId, source, game);
                    remainingDamage -= damageAmount;
                }
            }
        }
    }
}
Also used : TargetAnyTarget(mage.target.common.TargetAnyTarget) Target(mage.target.Target) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) 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