mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 12:52:06 -08:00
Merge branch 'master' of https://github.com/magefree/mage
This commit is contained in:
commit
7ba3a8f637
5 changed files with 59 additions and 12 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetNonlandPermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.common.SpellsCastWatcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -114,7 +115,7 @@ class MonkClassEffect extends OneShotEffect {
|
|||
}
|
||||
player.moveCards(card, Zone.EXILED, source, game);
|
||||
game.addEffect(new GainAbilityTargetEffect(
|
||||
new SimpleStaticAbility(new MonkClassCastEffect()),
|
||||
new SimpleStaticAbility(Zone.EXILED, new MonkClassCastEffect()),
|
||||
Duration.Custom, null, true
|
||||
).setTargetPointer(new FixedTarget(card, game)), source);
|
||||
return true;
|
||||
|
|
@ -134,12 +135,13 @@ class MonkClassCastEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (!sourceId.equals(source.getSourceId()) || !source.isControlledBy(affectedControllerId)) {
|
||||
UUID mainCardId = CardUtil.getMainCardId(game, sourceId);
|
||||
if (!mainCardId.equals(source.getSourceId()) || !source.isControlledBy(affectedControllerId)) {
|
||||
return false;
|
||||
}
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
Card card = game.getCard(sourceId);
|
||||
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
|
||||
return card != null && watcher != null
|
||||
return card != null && watcher != null && !card.isLand(game)
|
||||
&& watcher.getSpellsCastThisTurn(affectedControllerId).size() > 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class StrengthOfTheTajuruAddCountersTargetEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int affectedTargets = 0;
|
||||
int amount = source.getManaCostsToPay().getX() + 1;
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
Counter counter = CounterType.P1P1.createInstance(amount);
|
||||
for (UUID uuid : targetPointer.getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue