From 0d83a8e09a691d79d241cf0b766ec8c5e910214f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 11 Aug 2020 15:15:08 +0200 Subject: [PATCH] * Once Upon A Time - Added test (#6954). --- Mage.Sets/src/mage/cards/o/OnceUponATime.java | 4 +- .../cards/single/eld/OnceUponATimeTest.java | 89 +++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/eld/OnceUponATimeTest.java diff --git a/Mage.Sets/src/mage/cards/o/OnceUponATime.java b/Mage.Sets/src/mage/cards/o/OnceUponATime.java index e0268d09ea..39be09ca8c 100644 --- a/Mage.Sets/src/mage/cards/o/OnceUponATime.java +++ b/Mage.Sets/src/mage/cards/o/OnceUponATime.java @@ -70,7 +70,7 @@ enum OnceUponATimeCondition implements Condition { @Override public boolean apply(Game game, Ability source) { OnceUponATimeWatcher watcher = game.getState().getWatcher(OnceUponATimeWatcher.class); - return watcher != null && watcher.getSpellsCastThisTurn(source.getControllerId()); + return watcher != null && watcher.getSpellsCastThisGame(source.getControllerId()); } } @@ -89,7 +89,7 @@ class OnceUponATimeWatcher extends Watcher { } } - public boolean getSpellsCastThisTurn(UUID playerId) { + public boolean getSpellsCastThisGame(UUID playerId) { return !castSpells.contains(playerId); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/OnceUponATimeTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/OnceUponATimeTest.java new file mode 100644 index 0000000000..ec06a1b217 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/OnceUponATimeTest.java @@ -0,0 +1,89 @@ +package org.mage.test.cards.single.eld; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class OnceUponATimeTest extends CardTestPlayerBase { + + @Test + public void test_castRegularly() { + setStrictChooseMode(true); + + addCard(Zone.LIBRARY, playerA, "Silvercoat Lion"); + addCard(Zone.LIBRARY, playerA, "Plains", 4); + skipInitShuffling(); + + // If this spell is the first spell you've cast this game, you may cast it without paying its mana cost. + // Look at the top five cards of your library. + // You may reveal a creature or land card from among them and put it into your hand. + // Put the rest on the bottom of your library in a random order. + addCard(Zone.HAND, playerA, "Once Upon a Time"); // Instant {1}{G} + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + addCard(Zone.HAND, playerA, "Forest", 1); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Forest"); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Once Upon a Time"); + + setChoice(playerA, "No"); // Cast without paying its mana cost? + + setChoice(playerA, "Yes"); // Do you wish to reveal a creature or land card and put into your hand? + setChoice(playerA, "Silvercoat Lion"); + + setStopAt(2, PhaseStep.END_TURN); + execute(); + + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, "Once Upon a Time", 1); + assertTappedCount("Forest", true, 2); + assertHandCount(playerA, "Silvercoat Lion", 1); + } + + @Test + public void test_castForFree() { + setStrictChooseMode(true); + + addCard(Zone.LIBRARY, playerA, "Silvercoat Lion"); + addCard(Zone.LIBRARY, playerA, "Plains", 4); + + addCard(Zone.LIBRARY, playerB, "Silvercoat Lion", 5); + + skipInitShuffling(); + + // If this spell is the first spell you've cast this game, you may cast it without paying its mana cost. + // Look at the top five cards of your library. + // You may reveal a creature or land card from among them and put it into your hand. + // Put the rest on the bottom of your library in a random order. + addCard(Zone.HAND, playerA, "Once Upon a Time"); // Instant {1}{G} + addCard(Zone.HAND, playerB, "Once Upon a Time"); // Instant {1}{G} + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Once Upon a Time"); + setChoice(playerA, "Yes"); // Cast without paying its mana cost? + setChoice(playerA, "Yes"); // Do you wish to reveal a creature or land card and put into your hand? + setChoice(playerA, "Silvercoat Lion"); + + castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Once Upon a Time"); + setChoice(playerB, "Yes"); // Cast without paying its mana cost? + setChoice(playerB, "Yes"); // Do you wish to reveal a creature or land card and put into your hand? + setChoice(playerB, "Silvercoat Lion"); + + setStopAt(2, PhaseStep.END_TURN); + execute(); + + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, "Once Upon a Time", 1); + assertGraveyardCount(playerB, "Once Upon a Time", 1); + + assertHandCount(playerA, "Silvercoat Lion", 1); + assertHandCount(playerB, "Silvercoat Lion", 2); + } +} \ No newline at end of file