Search in sources :

Example 6 with TargetAnyTarget

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

the class HankyuCost method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent == null) {
        return false;
    }
    Permanent creature = game.getPermanent(permanent.getAttachedTo());
    if (creature == null) {
        return false;
    }
    creature.addAbility(new SimpleActivatedAbility(new AddCountersTargetEffect(CounterType.AIM.createInstance()).setTargetPointer(new FixedTarget(permanent, game)).setText("put an aim counter on " + permanent.getName()), new TapSourceCost()), source.getSourceId(), game);
    Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(HankyuValue.instance).setText("this creature deals damage to any target equal " + "to the number of aim counters removed this way"), new TapSourceCost());
    ability.addCost(new HankyuCost().setMageObjectReference(source, game));
    ability.addTarget(new TargetAnyTarget());
    creature.addAbility(ability, source.getSourceId(), game);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) EquipAbility(mage.abilities.keyword.EquipAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) TapSourceCost(mage.abilities.costs.common.TapSourceCost) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 7 with TargetAnyTarget

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

the class KeranosGodOfStormsTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getPlayerId().equals(this.getControllerId())) {
        return false;
    }
    if (!game.isActivePlayer(this.getControllerId())) {
        return false;
    }
    CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
    if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) {
        return false;
    }
    Card card = game.getCard(event.getTargetId());
    Player controller = game.getPlayer(this.getControllerId());
    Permanent sourcePermanent = (Permanent) getSourceObject(game);
    if (card == null || controller == null || sourcePermanent == null) {
        return false;
    }
    controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
    this.getTargets().clear();
    this.getEffects().clear();
    if (card.isLand(game)) {
        this.addEffect(new DrawCardSourceControllerEffect(1));
    } else {
        this.addEffect(new DamageTargetEffect(3));
        this.addTarget(new TargetAnyTarget());
    }
    return true;
}
Also used : CardsAmountDrawnThisTurnWatcher(mage.watchers.common.CardsAmountDrawnThisTurnWatcher) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 8 with TargetAnyTarget

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

the class MagmaPummelerEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    int damage = event.getAmount();
    preventDamageAction(event, source, game);
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    int beforeCounters = permanent.getCounters(game).getCount(CounterType.P1P1);
    permanent.removeCounters(CounterType.P1P1.createInstance(damage), source, game);
    int countersRemoved = beforeCounters - permanent.getCounters(game).getCount(CounterType.P1P1);
    if (countersRemoved > 0) {
        ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(countersRemoved), false, "{this} deals that much damage to any target");
        ability.addTarget(new TargetAnyTarget());
        game.fireReflexiveTriggeredAbility(ability, source);
    }
    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 9 with TargetAnyTarget

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

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

the class ManaPoolTest method test_MultipleMana_OneXAbility.

@Test
public void test_MultipleMana_OneXAbility() {
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
    // 
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new DamageTargetEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl("{X}"));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("damage X", playerA, ability);
    // make mana
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 4);
    // use for ability
    // showAvailableAbilities("before ability", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{X}:", playerB);
    setChoice(playerA, "X=3");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 4 - 3);
    checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 3);
    setStopAt(1, PhaseStep.END_TURN);
    setStrictChooseMode(true);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleManaAbility(mage.abilities.mana.SimpleManaAbility) 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) Test(org.junit.Test)

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