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;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -12,15 +10,13 @@ import mage.cards.Card;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Quercitron
|
||||
*/
|
||||
|
@ -30,10 +26,10 @@ public final class ZursWeirding extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
|
||||
|
||||
// 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.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ZursWeirdingReplacementEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(new ZursWeirdingReplacementEffect()));
|
||||
}
|
||||
|
||||
private ZursWeirding(final ZursWeirding card) {
|
||||
|
@ -50,7 +46,9 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
ZursWeirdingReplacementEffect() {
|
||||
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) {
|
||||
|
@ -62,28 +60,12 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
|||
return new ZursWeirdingReplacementEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
Player player = game.getPlayer(event.getTargetId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (player == null
|
||||
|| sourceObject == null) {
|
||||
if (player == null || sourceObject == null) {
|
||||
return false;
|
||||
}
|
||||
Card card = player.getLibrary().getFromTop(game);
|
||||
|
@ -101,22 +83,28 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
|||
continue;
|
||||
}
|
||||
Player otherPlayer = game.getPlayer(playerId);
|
||||
if (otherPlayer.canPayLifeCost(source)
|
||||
&& otherPlayer.getLife() >= 2) {
|
||||
PayLifeCost lifeCost = new PayLifeCost(2);
|
||||
while (otherPlayer.canRespond()
|
||||
&& !paid
|
||||
&& otherPlayer.chooseUse(Outcome.Benefit, message, source, game)) {
|
||||
paid = lifeCost.pay(source, game, source, otherPlayer.getId(), false, null);
|
||||
}
|
||||
if (paid) {
|
||||
player.moveCards(card, Zone.GRAVEYARD, source, game);
|
||||
return true;
|
||||
}
|
||||
if (otherPlayer == null || !otherPlayer.canPayLifeCost(source) || otherPlayer.getLife() < 2) {
|
||||
continue;
|
||||
}
|
||||
PayLifeCost lifeCost = new PayLifeCost(2);
|
||||
if (otherPlayer.chooseUse(Outcome.Benefit, message, source, game)
|
||||
&& lifeCost.pay(source, game, source, otherPlayer.getId(), true)) {
|
||||
player.moveCards(card, Zone.GRAVEYARD, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// This is still replacing the draw, so we still return true
|
||||
player.drawCards(1, source, game, event);
|
||||
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