Some rework to end turn logic and removing of stack objects (related to #2977).

This commit is contained in:
LevelX2 2017-04-02 15:18:50 +02:00
parent 2446abcc98
commit 097a8ce0dd
9 changed files with 110 additions and 104 deletions

View file

@ -55,6 +55,9 @@ public class EndTurnEffectTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Sphinx's Tutelage");
// Each player shuffles his or her hand and graveyard into his or her library, then draws seven cards. If it's your turn, end the turn.
// (Exile all spells and abilities on the stack, including this card.
// Discard down to your maximum hand size. Damage wears off, and
// "this turn" and "until end of turn" effects end.)
addCard(Zone.HAND, playerA, "Day's Undoing"); //Sorcery {2}{U}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Day's Undoing");
@ -67,8 +70,42 @@ public class EndTurnEffectTest extends CardTestPlayerBase {
assertHandCount(playerA, 7);
assertHandCount(playerB, 7);
assertGraveyardCount(playerB, 0); // because the trigegrs of Sphinx's Tutelage cease to exist
assertGraveyardCount(playerB, 0); // because the triggers of Sphinx's Tutelage cease to exist
}
@Test
public void testSpellSplitCard() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 6);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
// End the turn.
// (Exile all spells and abilities on the stack, including this card.
// Discard down to your maximum hand size. Damage wears off, and
// "this turn" and "until end of turn" effects end.)
addCard(Zone.HAND, playerA, "Time Stop"); //Instant {4}{U}{U}
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
// Fire
// Fire deals 2 damage divided as you choose among one or two target creatures and/or players.
// Ice
// Tap target permanent. Draw a card.
addCard(Zone.HAND, playerB, "Fire // Ice"); // Instant {1}{R} // {1}{U}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Ice", "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Time Stop", NO_TARGET, "Ice");
setStopAt(2, PhaseStep.UPKEEP);
execute();
assertHandCount(playerB, "Fire // Ice", 0);
assertExileCount(playerA, "Time Stop", 1);
assertExileCount(playerB, "Fire // Ice", 1);
assertTapped("Silvercoat Lion", false);
assertHandCount(playerA, 0);
assertHandCount(playerB, 0);
}
}

View file

@ -29,7 +29,6 @@ package org.mage.test.cards.triggers;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.Filter;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -313,14 +312,14 @@ public class EntersTheBattlefieldTriggerTest extends CardTestPlayerBase {
/*
* playerA's Carnivorous Plant will get -1/-1 from Noxious Ghoul -> 3/4
* playerB's Carnivorous Plant will get -1/-1 from Noxious Ghoul -> 3/4
*/
*/
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Clone");
setChoice(playerA, "Noxious Ghoul");
/*
* playerA's Carnivorous Plant will get -1/-1 from Clone -> 2/3
* playerB's Carnivorous Plant will get -1/-1 from Clone -> 2/3
*/
*/
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ego Erasure", "targetPlayer=PlayerA", "Whenever");
/*
* playerA' Noxious Ghoul will get -2/0 -> 1/3
@ -329,7 +328,7 @@ public class EntersTheBattlefieldTriggerTest extends CardTestPlayerBase {
* playerA' Noxious Ghoul will get -1/-1 from itself -> -1/1
* playerA's Carnivorous Plant will get -1/-1 from Noxious Ghoul -> -1/2
* playerB's Carnivorous Plant will get -1/-1 from Noxious Ghoul -> 1/2
*/
*/
setStopAt(1, PhaseStep.END_TURN);
execute();
@ -342,72 +341,22 @@ public class EntersTheBattlefieldTriggerTest extends CardTestPlayerBase {
assertPowerToughness(playerB, "Carnivorous Plant", 1, 2);
assertPowerToughness(playerA, "Carnivorous Plant", -1, 2);
}
@Test
public void testHearthcageGiant() {
// {6}{R}{R} Creature Giant Warrior
//When Hearthcage Giant enters the battlefield, put two 3/1 red Elemental Shaman creature tokens onto the battlefield.
//Sacrifice an Elemental: Target Giant creature gets +3/+1 until end of turn.
addCard(Zone.HAND,playerA,"Hearthcage Giant");
addCard(Zone.HAND, playerA, "Hearthcage Giant");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 8);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hearthcage Giant");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Hearthcage Giant", 1);
assertPermanentCount(playerA, "Elemental Shaman", 2);
assertPowerToughness(playerA, "Elemental Shaman", 3, 1);
}
/*
Reported bug: HAngarback interaciton with Hardened Scales and Metallic Mimic on board is incorrect.
*/
@Test
public void hangarBackHardenedScalesMetallicMimicTest() {
/*
Hangarback Walker {X}{X}
Artifact Creature Construct 0/0
Hangarback Walker enters the battlefield with X +1/+1 counters on it.
When Hangarback Walker dies, create a 1/1 colorless Thopter artifact creature token with flying for each +1/+1 counter on Hangarback Walker.
{1}, {T}: Put a +1/+1 counter on Hangarback Walker.
*/
String hWalker = "Hangarback Walker";
/*
Hardened Scales {G}
Enchantment
If one or more +1/+1 counters would be placed on a creature you control, that many plus one +1/+1 counters are placed on it instead.
*/
String hScales = "Hardened Scales";
/*
Metallic Mimic {2}
Artifact Creature Shapeshifter 2/1
As Metallic Mimic enters the battlefield, choose a creature type.
Metallic Mimic is the chosen type in addition to its other types.
Each other creature you control of the chosen type enters the battlefield with an additional +1/+1 counter on it.
*/
String mMimic = "Metallic Mimic";
addCard(Zone.BATTLEFIELD, playerA, hScales);
addCard(Zone.HAND, playerA, mMimic);
addCard(Zone.HAND, playerA, hWalker);
addCard(Zone.BATTLEFIELD, playerA, "Wastes", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, mMimic);
setChoice(playerA, "Construct");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hWalker);
setChoice(playerA, "X=1");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, mMimic, 1);
assertPermanentCount(playerA, hWalker, 1);
assertCounterCount(playerA, hWalker, CounterType.P1P1, 3);
assertPowerToughness(playerA, hWalker, 3, 3);
}
}

View file

@ -70,4 +70,44 @@ public class EndStepTriggerTest extends CardTestPlayerBase {
assertCounterCount("Bloodchief Ascension", CounterType.QUEST, 2);
}
/**
* Hey, I don't know how to submit bugs but in a game I played today I
* sacrificed Child of Alara by casting Bound at the end step of my previous
* opponent's turn, then chose Child as one of the cards to return to my
* hand. My graveyard was empty so that was the only card I chose. Child
* returned to my hand but it did NOT trigger for some reason. Nothing was
* destroyed
*/
@Test
public void testSacrificeChildOfAlara() {
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); //Creature
// Trample
// When Child of Alara dies, destroy all nonland permanents. They can't be regenerated.
addCard(Zone.BATTLEFIELD, playerB, "Icy Manipulator", 1); //Creature
addCard(Zone.BATTLEFIELD, playerB, "Child of Alara", 1); //Creature
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerB, "Forest", 4);
// Bound
// Sacrifice a creature. Return up to X cards from your graveyard to your hand, where X is the number of colors that creature was. Exile this card.
// Determined
// Other spells you control can't be countered by spells or abilities this turn.
// Draw a card.
addCard(Zone.HAND, playerB, "Bound // Determined"); // Instant {3}{B}{G} // {G}{U}
castSpell(1, PhaseStep.END_TURN, playerB, "Bound");
addTarget(playerB, "Child of Alara");
setChoice(playerB, "Child of Alara");
setStopAt(2, PhaseStep.PRECOMBAT_MAIN);
execute();
assertExileCount(playerB, "Bound // Determined", 1);
assertHandCount(playerB, "Child of Alara", 1);
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
assertGraveyardCount(playerB, "Icy Manipulator", 1);
}
}