mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
[ICE] fixed Zur's Weirding not allowing players to choose not to pay life (fixes #7793)
This commit is contained in:
parent
95bfcb5ef8
commit
7915e74208
2 changed files with 73 additions and 39 deletions
|
@ -1,7 +1,5 @@
|
||||||
package mage.cards.z;
|
package mage.cards.z;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -12,15 +10,13 @@ import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.TargetController;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Quercitron
|
* @author Quercitron
|
||||||
*/
|
*/
|
||||||
|
@ -30,10 +26,10 @@ public final class ZursWeirding extends CardImpl {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
|
||||||
|
|
||||||
// Players play with their hands revealed.
|
// Players play with their hands revealed.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PlayWithHandRevealedEffect(TargetController.ANY)));
|
this.addAbility(new SimpleStaticAbility(new PlayWithHandRevealedEffect(TargetController.ANY)));
|
||||||
|
|
||||||
// If a player would draw a card, they reveal it instead. Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard. Otherwise, that player draws a card.
|
// If a player would draw a card, they reveal it instead. Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard. Otherwise, that player draws a card.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ZursWeirdingReplacementEffect()));
|
this.addAbility(new SimpleStaticAbility(new ZursWeirdingReplacementEffect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZursWeirding(final ZursWeirding card) {
|
private ZursWeirding(final ZursWeirding card) {
|
||||||
|
@ -50,7 +46,9 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
ZursWeirdingReplacementEffect() {
|
ZursWeirdingReplacementEffect() {
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Neutral);
|
super(Duration.WhileOnBattlefield, Outcome.Neutral);
|
||||||
this.staticText = "If a player would draw a card, they reveal it instead. Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard. Otherwise, that player draws a card.";
|
this.staticText = "If a player would draw a card, they reveal it instead." +
|
||||||
|
"Then any other player may pay 2 life. If a player does, " +
|
||||||
|
"put that card into its owner's graveyard. Otherwise, that player draws a card.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZursWeirdingReplacementEffect(final ZursWeirdingReplacementEffect effect) {
|
private ZursWeirdingReplacementEffect(final ZursWeirdingReplacementEffect effect) {
|
||||||
|
@ -62,28 +60,12 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
||||||
return new ZursWeirdingReplacementEffect(this);
|
return new ZursWeirdingReplacementEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
|
||||||
boolean paid = false;
|
boolean paid = false;
|
||||||
Player player = game.getPlayer(event.getTargetId());
|
Player player = game.getPlayer(event.getTargetId());
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (player == null
|
if (player == null || sourceObject == null) {
|
||||||
|| sourceObject == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Card card = player.getLibrary().getFromTop(game);
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
|
@ -101,22 +83,28 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Player otherPlayer = game.getPlayer(playerId);
|
Player otherPlayer = game.getPlayer(playerId);
|
||||||
if (otherPlayer.canPayLifeCost(source)
|
if (otherPlayer == null || !otherPlayer.canPayLifeCost(source) || otherPlayer.getLife() < 2) {
|
||||||
&& otherPlayer.getLife() >= 2) {
|
continue;
|
||||||
PayLifeCost lifeCost = new PayLifeCost(2);
|
}
|
||||||
while (otherPlayer.canRespond()
|
PayLifeCost lifeCost = new PayLifeCost(2);
|
||||||
&& !paid
|
if (otherPlayer.chooseUse(Outcome.Benefit, message, source, game)
|
||||||
&& otherPlayer.chooseUse(Outcome.Benefit, message, source, game)) {
|
&& lifeCost.pay(source, game, source, otherPlayer.getId(), true)) {
|
||||||
paid = lifeCost.pay(source, game, source, otherPlayer.getId(), false, null);
|
player.moveCards(card, Zone.GRAVEYARD, source, game);
|
||||||
}
|
return true;
|
||||||
if (paid) {
|
|
||||||
player.moveCards(card, Zone.GRAVEYARD, source, game);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This is still replacing the draw, so we still return true
|
// This is still replacing the draw, so we still return true
|
||||||
player.drawCards(1, source, game, event);
|
player.drawCards(1, source, game, event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checksEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package org.mage.test.cards.single.ice;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public class ZursWeirdingTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
private static final String weirding = "Zur's Weirding";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testYes() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, weirding);
|
||||||
|
|
||||||
|
setChoice(playerA, "Yes");
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(2, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertLife(playerA, 20 - 2);
|
||||||
|
assertGraveyardCount(playerB, 1);
|
||||||
|
assertHandCount(playerB, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNo() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, weirding);
|
||||||
|
|
||||||
|
setChoice(playerA, "No");
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(2, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
assertGraveyardCount(playerB, 0);
|
||||||
|
assertHandCount(playerB, 1);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue