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();
}
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);
}
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;
}
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;
}
Aggregations