Search in sources :

Example 6 with TargetSpell

use of mage.target.TargetSpell in project mage by magefree.

the class ManaPoolTest method test_MultipleMana_OneXPart.

@Test
public void test_MultipleMana_OneXPart() {
    // {R}
    addCard(Zone.HAND, playerA, "Lightning Bolt");
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1 + 3 + 1);
    // 
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new DamageTargetEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl(""));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("damage X", playerA, ability);
    // 
    // {X}: Counter target spell
    ability = new SimpleActivatedAbility(Zone.ALL, new CounterUnlessPaysEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl("{X}"));
    ability.addTarget(new TargetSpell());
    addCustomCardWithAbility("counter until pay X", playerB, ability);
    addCard(Zone.BATTLEFIELD, playerB, "Island", 3);
    // make mana for spell
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    checkManaPool("mana spell", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 1);
    // cast spell
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
    // make mana for pay X to prevent
    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}");
    // one must be saved in pool
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
    checkManaPool("mana prevent", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 4);
    // counter by X=3
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{X}: Counter");
    setChoice(playerB, "X=3");
    addTarget(playerB, "Lightning Bolt");
    // pay to prevent
    // pay 3 to prevent counter
    setChoice(playerA, true);
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkManaPool("mana after", 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) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetSpell(mage.target.TargetSpell) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget) Test(org.junit.Test)

Example 7 with TargetSpell

use of mage.target.TargetSpell in project mage by magefree.

the class InvasiveSurgeryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    String cardName = "";
    UUID spellController = null;
    if (source.getTargets().get(0) instanceof TargetSpell) {
        UUID objectId = source.getFirstTarget();
        StackObject stackObject = game.getStack().getStackObject(objectId);
        if (stackObject != null) {
            MageObject targetObject = game.getObject(stackObject.getSourceId());
            if (targetObject instanceof Card) {
                cardName = targetObject.getName();
            }
            spellController = stackObject.getControllerId();
            game.getStack().counter(objectId, source, game);
        }
    }
    // Check the Delirium condition
    if (!DeliriumCondition.instance.apply(game, source)) {
        return true;
    }
    return this.applySearchAndExile(game, source, cardName, spellController);
}
Also used : Player(mage.players.Player) StackObject(mage.game.stack.StackObject) MageObject(mage.MageObject) TargetSpell(mage.target.TargetSpell) UUID(java.util.UUID) Card(mage.cards.Card)

Example 8 with TargetSpell

use of mage.target.TargetSpell in project mage by magefree.

the class ReverberationEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    DamageEvent damageEvent = (DamageEvent) event;
    Spell targetSpell = game.getStack().getSpell(source.getFirstTarget());
    if (targetSpell != null) {
        return damageEvent.getAmount() > 0;
    }
    return false;
}
Also used : DamageEvent(mage.game.events.DamageEvent) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Example 9 with TargetSpell

use of mage.target.TargetSpell in project mage by magefree.

the class CounterTargetAndSearchGraveyardHandLibraryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean result = false;
    String cardName = "";
    UUID searchPlayerId = null;
    if (source.getTargets().get(0) instanceof TargetSpell) {
        UUID objectId = source.getFirstTarget();
        StackObject stackObject = game.getStack().getStackObject(objectId);
        if (stackObject != null) {
            MageObject targetObject = game.getObject(stackObject.getSourceId());
            if (targetObject instanceof Card) {
                cardName = targetObject.getName();
            }
            searchPlayerId = stackObject.getControllerId();
            result = game.getStack().counter(objectId, source, game);
        }
    }
    // 5/1/2008: If the targeted spell can't be countered (it's Vexing Shusher, for example),
    // that spell will remain on the stack. Counterbore will continue to resolve. You still
    // get to search for and exile all other cards with that name.
    this.applySearchAndExile(game, source, cardName, searchPlayerId);
    return result;
}
Also used : StackObject(mage.game.stack.StackObject) MageObject(mage.MageObject) TargetSpell(mage.target.TargetSpell) UUID(java.util.UUID) Card(mage.cards.Card)

Aggregations

TargetSpell (mage.target.TargetSpell)9 Spell (mage.game.stack.Spell)5 Card (mage.cards.Card)4 Player (mage.players.Player)4 UUID (java.util.UUID)3 FilterSpell (mage.filter.FilterSpell)3 MageObject (mage.MageObject)2 Ability (mage.abilities.Ability)2 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)2 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)2 CounterUnlessPaysEffect (mage.abilities.effects.common.CounterUnlessPaysEffect)2 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)2 SimpleManaAbility (mage.abilities.mana.SimpleManaAbility)2 DamageEvent (mage.game.events.DamageEvent)2 StackObject (mage.game.stack.StackObject)2 TargetAnyTarget (mage.target.common.TargetAnyTarget)2 Test (org.junit.Test)2 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)1 AddConditionalManaEffect (mage.abilities.effects.mana.AddConditionalManaEffect)1 SimpleActivatedAbilityManaBuilder (mage.abilities.mana.builder.common.SimpleActivatedAbilityManaBuilder)1