From 2e72503b8cb13fef1894d40268fb7452cdee6251 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 5 Jun 2018 18:12:31 +0200 Subject: [PATCH] * Fix of condtitional mana effect (not completed yet). --- .../test/cards/mana/RiverOfTearsTest.java | 61 +++++++++++++++++++ .../decorator/ConditionalManaEffect.java | 13 +++- 2 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/mana/RiverOfTearsTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/mana/RiverOfTearsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/mana/RiverOfTearsTest.java new file mode 100644 index 0000000000..19330618f2 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/mana/RiverOfTearsTest.java @@ -0,0 +1,61 @@ +package org.mage.test.cards.mana; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class RiverOfTearsTest extends CardTestPlayerBase { + + /** + * River of Tears doesn't produce black mana any time. Gatherer says: + * + * 17/11/2017 The turn you play River of Tears, it will produce Black when + * tapped for mana. + * + * 17/11/2017 River of Tears produces Black only after you’ve played a land, + * not after you’ve put a land onto the battlefield (such as with Evolving + * Wilds). + */ + @Test + public void testBlackAfterPlayed() { + // {T}: Add {U}. If you played a land this turn, add {B} instead. + addCard(Zone.HAND, playerA, "River of Tears", 1); // Land + + addCard(Zone.HAND, playerA, "Nightshade Stinger", 1); // Creature {B} + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "River of Tears"); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Nightshade Stinger"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "River of Tears", 1); + assertTapped("River of Tears", true); + assertPermanentCount(playerA, "Nightshade Stinger", 1); + } + + @Test + public void testBlueInSecondTurn() { + // {T}: Add {U}. If you played a land this turn, add {B} instead. + addCard(Zone.HAND, playerA, "River of Tears", 1); // Land + + addCard(Zone.HAND, playerA, "Aven Envoy", 1); // Creature {B} + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "River of Tears"); + + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Aven Envoy"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "River of Tears", 1); + assertTapped("River of Tears", true); + assertPermanentCount(playerA, "Aven Envoy", 1); + } +} diff --git a/Mage/src/main/java/mage/abilities/decorator/ConditionalManaEffect.java b/Mage/src/main/java/mage/abilities/decorator/ConditionalManaEffect.java index bc4c67000c..baa1e13375 100644 --- a/Mage/src/main/java/mage/abilities/decorator/ConditionalManaEffect.java +++ b/Mage/src/main/java/mage/abilities/decorator/ConditionalManaEffect.java @@ -1,4 +1,3 @@ - package mage.abilities.decorator; import mage.Mana; @@ -47,7 +46,11 @@ public class ConditionalManaEffect extends ManaEffect { if (controller == null) { return false; } - controller.getManaPool().addMana(getMana(game, source), game, source); + Mana mana = getMana(game, source); + controller.getManaPool().addMana(mana, game, source); + if (produceMana(true, game, source).getAny() > 0) { + checkToFirePossibleEvents(mana, game, source); + } return true; } @@ -56,6 +59,11 @@ public class ConditionalManaEffect extends ManaEffect { return new ConditionalManaEffect(this); } + @Override + public Mana getMana(Game game, Ability source) { + return produceMana(false, game, source); + } + @Override public Mana produceMana(boolean netMana, Game game, Ability source) { Mana mana = new Mana(); @@ -75,7 +83,6 @@ public class ConditionalManaEffect extends ManaEffect { mana.setAny(0); mana.add(choice.getMana(amount)); } - checkToFirePossibleEvents(mana, game, source); } return mana; }