From cdec4fe2805f4b7af1da90024a0609cc09e81cb0 Mon Sep 17 00:00:00 2001
From: Oleg Agafonov <jaydi85@gmail.com>
Date: Thu, 28 Dec 2017 02:24:37 +0400
Subject: [PATCH] Tests: added error proof tests on "can't see new echanted
 land ability if it was added on same step" (Naga Vitalist)

---
 .../test/cards/mana/NagaVitalistTest.java     | 125 ++++++++++++++++--
 1 file changed, 114 insertions(+), 11 deletions(-)

diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/mana/NagaVitalistTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/mana/NagaVitalistTest.java
index 9709cb0359..f19d888195 100644
--- a/Mage.Tests/src/test/java/org/mage/test/cards/mana/NagaVitalistTest.java
+++ b/Mage.Tests/src/test/java/org/mage/test/cards/mana/NagaVitalistTest.java
@@ -1,15 +1,21 @@
 package org.mage.test.cards.mana;
 
+import mage.constants.Duration;
 import mage.constants.ManaType;
 import mage.constants.PhaseStep;
 import mage.constants.Zone;
+import mage.game.permanent.Permanent;
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.mage.test.serverside.base.CardTestPlayerBase;
+import org.mage.test.utils.ManaOptionsTestUtils;
+
+import static org.mage.test.utils.ManaOptionsTestUtils.manaOptionsContain;
 
 /**
  *
- * @author escplan9
+ * @author escplan9, JayDi85
  */
 public class NagaVitalistTest extends CardTestPlayerBase {
 
@@ -21,21 +27,116 @@ public class NagaVitalistTest extends CardTestPlayerBase {
     private final String nagaVitalist = "Naga Vitalist";
 
     /*
-     Reported bug (issue #3315)
-    Naga Vitalist could not produce any color mana with a Gift of Paradise enchanted on a forest. All lands on board were forests.
-     */
-    @Test
-    public void nagaVitalist_InteractionGiftOfParadise() {
-
-        /*
         Gift of Paradise 2G
         Enchantment - Aura
         Enchant - Land
         When Gift of Paradise enters the battlefield, you gain 3 life.
         Enchanted land has "T: Add two mana of any one color to your mana pool."
-         */
-        String giftParadise = "Gift of Paradise";
+    */
+    private final String giftParadise = "Gift of Paradise";
 
+    @Test
+    public void nagaVitalist_GiftOfParadiseCanAnyColor() {
+        addCard(Zone.BATTLEFIELD, playerA, "Upwelling");
+        addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
+        addCard(Zone.HAND, playerA, giftParadise);
+        addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
+
+        // manual mana cost, cause auto cost can get swamp to pay
+        activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
+        activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
+        activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
+        castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, giftParadise, "Swamp");
+
+        setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
+        execute();
+
+        Assert.assertTrue("playerA must cast {Any}{Any}", manaOptionsContain(playerA.getManaAvailable(currentGame), "{Any}{Any}"));
+    }
+
+    public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(int giftCastTurn, int nagaManaTapTurn, String nagaManaTapColor){
+        // test errors on enchanted ability do not apply for "any mana search" on different steps
+
+        addCard(Zone.BATTLEFIELD, playerA, "Upwelling");
+        addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
+        addCard(Zone.HAND, playerA, giftParadise);
+        addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
+        addCard(Zone.BATTLEFIELD, playerA, nagaVitalist, 1);
+
+
+        // cast and enchant swamp land to any color
+        activateManaAbility(giftCastTurn, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
+        activateManaAbility(giftCastTurn, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
+        activateManaAbility(giftCastTurn, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}");
+        castSpell(giftCastTurn, PhaseStep.PRECOMBAT_MAIN, playerA, giftParadise, "Swamp");
+
+        // activate red mana (by any from enchanted land)
+        activateManaAbility(nagaManaTapTurn, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add to your mana pool one mana of any");
+        setChoice(playerA, nagaManaTapColor);
+
+        setStopAt(nagaManaTapTurn, PhaseStep.PRECOMBAT_MAIN);
+        execute();
+    }
+
+    @Test
+    @Ignore // TODO: need to fix - on naga mana tap swamp do not have added ability "add 2 any mana" (but it have after step complete)
+    public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_SameStep1() {
+        nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(1, 1, "Red");
+
+
+        //logger.info(playerA.getManaPool().getMana().toString());
+        //logger.info(playerA.getManaAvailable(currentGame).toString());
+        //for(Permanent perm: currentGame.getBattlefield().getAllActivePermanents(playerA.getId())){
+        //    logger.info(perm.getIdName() + ": " + perm.getAbilities().toString());
+        //}
+
+        assertTapped("Forest", true);
+        assertTapped(giftParadise, false);
+        assertTapped("Swamp", false);
+        assertTapped(nagaVitalist, true);
+        Assert.assertEquals(1, playerA.getManaPool().get(ManaType.RED));
+    }
+
+    @Test
+    public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_DiffStep1() {
+        nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(1, 2, "Red");
+
+        assertTapped("Forest", true);
+        assertTapped(giftParadise, false);
+        assertTapped("Swamp", false);
+        assertTapped(nagaVitalist, true);
+        Assert.assertEquals(1, playerA.getManaPool().get(ManaType.RED));
+    }
+
+    @Test
+    @Ignore // TODO: need to fix - on naga mana tap swamp do not have added ability "add 2 any mana" (but it have after step complete)
+    public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_SameStep3() {
+        nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(3, 3, "Red");
+
+        assertTapped("Forest", true);
+        assertTapped(giftParadise, false);
+        assertTapped("Swamp", false);
+        assertTapped(nagaVitalist, true);
+        Assert.assertEquals(1, playerA.getManaPool().get(ManaType.RED));
+    }
+
+    @Test
+    public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_DiffStep2() {
+        nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(3, 4, "Red");
+
+        assertTapped("Forest", true);
+        assertTapped(giftParadise, false);
+        assertTapped("Swamp", false);
+        assertTapped(nagaVitalist, true);
+        Assert.assertEquals(1, playerA.getManaPool().get(ManaType.RED));
+    }
+
+    /*
+     Reported bug (issue #3315)
+    Naga Vitalist could not produce any color mana with a Gift of Paradise enchanted on a forest. All lands on board were forests.
+     */
+    @Test
+    public void nagaVitalist_InteractionGiftOfParadise() {
         addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
         addCard(Zone.BATTLEFIELD, playerA, nagaVitalist);
         addCard(Zone.BATTLEFIELD, playerA, "Upwelling"); // mana pools do not empty at the end of phases or turns
@@ -43,7 +144,7 @@ public class NagaVitalistTest extends CardTestPlayerBase {
 
         castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, giftParadise, "Forest");
 
-        activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add to your mana pool one mana of any type that a land you control could produce");
+        activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add to your mana pool one mana of any");
         setChoice(playerA, "Red");
 
         setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
@@ -51,6 +152,8 @@ public class NagaVitalistTest extends CardTestPlayerBase {
 
         assertLife(playerA, 23); // gift of paradise ETB
         assertTapped(nagaVitalist, true);
+        assertTapped(giftParadise, false);
+        assertTapped("Forest", false);
         Assert.assertEquals("one red mana has to be in the mana pool", 1, playerA.getManaPool().get(ManaType.RED));
     }
 }