Update effects and abilities which involve tapping permanents for mana (#7679)

Abilities which use trigger from or replace tapping for mana now save the permanent in case it leaves the battlefield.
fixes #7671, fixes #7770
* Merge fix and additional comments, Winter's Night fixed

Co-authored-by: Oleg Agafonov <jaydi85@gmail.com>
This commit is contained in:
Evan Kranzler 2021-07-21 21:09:07 -04:00 committed by GitHub
parent 81193148e9
commit 214b688fdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 884 additions and 1149 deletions

View file

@ -8,6 +8,7 @@ import mage.counters.CounterType;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.assertDuplicatedManaOptions;
import static org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions;
@ -58,7 +59,7 @@ public class ManaReflectionTest extends CardTestPlayerBase {
assertManaPool(playerA, ManaType.GREEN, 2);
}
@Test
public void ManaReflectionWithGoblinClearcutterTest() {
// If you tap a permanent for mana, it produces twice as much of that mana instead.
@ -66,10 +67,10 @@ public class ManaReflectionTest extends CardTestPlayerBase {
// {T}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G}.
addCard(Zone.BATTLEFIELD, playerA, "Goblin Clearcutter");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
@ -79,5 +80,20 @@ public class ManaReflectionTest extends CardTestPlayerBase {
assertManaOptions("{R}{R}{G}{G}{G}{G}{G}{G}", manaOptions);
assertManaOptions("{G}{G}{G}{G}{G}{G}{G}{G}", manaOptions);
}
@Test
public void ManaReflectionWithHavenwoodBattlegroundTest() {
// If you tap a permanent for mana, it produces twice as much of that mana instead.
addCard(Zone.BATTLEFIELD, playerA, "Mana Reflection");
// {T}, Sacrifice Havenwood Battleground: Add {G}{G}.
addCard(Zone.BATTLEFIELD, playerA, "Havenwood Battleground");
addCard(Zone.BATTLEFIELD, playerA, "Upwelling"); // Prevent mana from emptying before we can check it
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Sacrifice");
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertManaPool(playerA, ManaType.GREEN, 4);
}
}

View file

@ -0,0 +1,35 @@
package org.mage.test.cards.single.iko;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author TheElk801
*/
public class KinnanBonderProdigyTest extends CardTestPlayerBase {
private static final String kinnan = "Kinnan, Bonder Prodigy";
private static final String egg = "Golden Egg";
private static final String hovermyr = "Hovermyr";
@Test
public void testSacrificedPermanent() {
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, kinnan);
addCard(Zone.BATTLEFIELD, playerA, egg);
addCard(Zone.HAND, playerA, hovermyr);
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1},");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hovermyr);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, hovermyr, 1);
assertPermanentCount(playerA, egg, 0);
assertGraveyardCount(playerA, egg, 1);
}
}

View file

@ -10,6 +10,22 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
*/
public class StormCauldronTest extends CardTestPlayerBase {
@Test
public void testRegular() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerA, "Storm Cauldron", 1);
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertHandCount(playerA, "Mountain", 1);
assertPermanentCount(playerA, "Mountain", 0);
}
/**
* With Storm Cauldron in play (owned by opponent), I sacced Crystal Vein
* for 2 mana... except it got returned to my hand, which shouldn't happen.