mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Dauthi Voidwalker - fixed that it doesn't work with cards (related to a3ca9fc03a
);
This commit is contained in:
parent
bf172f7c8f
commit
0e1abaec5d
3 changed files with 52 additions and 7 deletions
|
@ -19,7 +19,6 @@ import mage.filter.FilterCard;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInExile;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
@ -82,11 +81,15 @@ class DauthiVoidwalkerReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
if (controller == null || permanent == null) {
|
||||
Card card = ((ZoneChangeEvent) event).getTarget();
|
||||
if (card == null) {
|
||||
card = game.getCard(event.getTargetId());
|
||||
}
|
||||
|
||||
if (controller == null || card == null) {
|
||||
return false;
|
||||
}
|
||||
CardUtil.moveCardWithCounter(game, source, controller, permanent, Zone.EXILED, CounterType.VOID.createInstance());
|
||||
CardUtil.moveCardWithCounter(game, source, controller, card, Zone.EXILED, CounterType.VOID.createInstance());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
public class DauthiVoidwalkerTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void test_Play() {
|
||||
public void test_FromBattlefield() {
|
||||
// If a card would be put into an opponent's graveyard from anywhere, instead exile it with a void counter on it.
|
||||
// {T}, Sacrifice Dauthi Voidwalker: Choose an exiled card an opponent owns with a void counter on it. You may play it this turn without paying its mana cost.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dauthi Voidwalker", 1);
|
||||
|
@ -39,4 +39,40 @@ public class DauthiVoidwalkerTest extends CardTestPlayerBase {
|
|||
execute();
|
||||
assertAllCommandsUsed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_FromStack() {
|
||||
// If a card would be put into an opponent's graveyard from anywhere, instead exile it with a void counter on it.
|
||||
// {T}, Sacrifice Dauthi Voidwalker: Choose an exiled card an opponent owns with a void counter on it. You may play it this turn without paying its mana cost.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dauthi Voidwalker", 1);
|
||||
//
|
||||
addCard(Zone.HAND, playerB, "Lightning Bolt");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Mountain");
|
||||
//
|
||||
// Counter target spell
|
||||
addCard(Zone.HAND, playerA, "Cancel"); // {1}{U}{U}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||
|
||||
// B try to cast and get counter
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {U}", 3);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cancel", "Lightning Bolt", "Lightning Bolt");
|
||||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||
// countered bolt must be exiled and got void counter
|
||||
checkExileCount("after exile", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", 1);
|
||||
|
||||
// can play it for free
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}, Sacrifice");
|
||||
setChoice(playerA, "Lightning Bolt");
|
||||
waitStackResolved(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20 - 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import mage.abilities.hint.HintUtils;
|
|||
import mage.cards.*;
|
||||
import mage.constants.*;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.CardState;
|
||||
|
@ -1381,7 +1380,7 @@ public final class CardUtil {
|
|||
* @param game
|
||||
* @param source
|
||||
* @param controller
|
||||
* @param card can be card or permanent
|
||||
* @param card can be card or permanent
|
||||
* @param toZone
|
||||
* @param counter
|
||||
*/
|
||||
|
@ -1390,6 +1389,13 @@ public final class CardUtil {
|
|||
throw new IllegalArgumentException("Wrong code usage - method doesn't support moving to battlefield zone");
|
||||
}
|
||||
|
||||
// workaround:
|
||||
// in ZONE_CHANGE replace events you must set new zone by event's setToZone,
|
||||
// BUT for counter effect you need to complete zone change event first (so moveCards calls here)
|
||||
// TODO: must be fixed someday by:
|
||||
// * or by new event ZONE_CHANGED to apply counter effect on it
|
||||
// * or by counter effects applier in ZONE_CHANGE event (see copy or token as example)
|
||||
|
||||
// move to zone
|
||||
if (!controller.moveCards(card, toZone, source, game)) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue