Fix bugs with dies triggers due to short living LKI reset (#12438)

* replace applyEffects() with processAction() for card usages

* update Goblin Welder and test

* add test for Historian's Wisdom

* enable other related tests

* only reset short living LKI for process action, not all apply effects

* update docs

* remove applyEffects from condition in Historian's Wisdom

* add another test case
This commit is contained in:
xenohedron 2024-06-09 18:56:19 -04:00 committed by GitHub
parent be8a52fe60
commit aeaeccb63b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 103 additions and 49 deletions

View file

@ -0,0 +1,48 @@
package org.mage.test.cards.single.neo;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class HistoriansWisdomTest extends CardTestPlayerBase {
/** 2G Aura
Enchant artifact or creature
When Historians Wisdom enters the battlefield, if enchanted permanent is a creature
with the greatest power among creatures on the battlefield, draw a card.
As long as enchanted permanent is a creature, it gets +2/+1.
*/
private static final String hw = "Historian's Wisdom";
private static final String bear = "Runeclaw Bear"; // 2/2
private static final String chimera = "Horizon Chimera"; // 3/2 Whenever you draw a card, you gain 1 life.
@Test
@Ignore // apply effects in condition is not an appropriate solution
public void testTrigger() {
addCard(Zone.BATTLEFIELD, playerA, bear);
addCard(Zone.BATTLEFIELD, playerA, chimera);
addCard(Zone.HAND, playerA, hw);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hw, bear);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, bear, 4, 3);
assertPowerToughness(playerA, chimera, 3, 2);
assertPermanentCount(playerA, hw, 1);
assertAttachedTo(playerA, hw, bear, true);
assertHandCount(playerA, 1);
assertLife(playerA, 21);
assertLife(playerB, 20);
}
}

View file

@ -62,7 +62,6 @@ public class ChromaticStarTest extends CardTestPlayerBase {
assertHandCount(playerA, 1);
}
@Ignore // short living LKI bug -- see #12385
@Test
public void test_Star_ChainMana_Auto() {
setStrictChooseMode(true);

View file

@ -3,7 +3,6 @@ package org.mage.test.cards.single.ulg;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -17,7 +16,6 @@ public class GoblinWelderTest extends CardTestPlayerBase {
private static final String relic = "Darksteel Relic";
private static final String aspirant = "Blood Aspirant";
@Ignore // TODO: related to problems with dies triggers and short living LKI, see TriggeredAbilityImpl for details
@Test
public void testSacrificeDiesTrigger() {
addCard(Zone.BATTLEFIELD, playerA, welder);
@ -29,7 +27,7 @@ public class GoblinWelderTest extends CardTestPlayerBase {
addTarget(playerA, wurmcoil);
addTarget(playerA, relic);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, true);
// must have 2 dies triggers on stack: from source and from another, but it have only from another
// must have 2 dies triggers on stack: from source and from another
setChoice(playerA, "Whenever you sacrifice a permanent"); // select from 2 triggers
checkStackSize("check triggers", 1, PhaseStep.PRECOMBAT_MAIN, playerA, 2);
@ -40,6 +38,6 @@ public class GoblinWelderTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, wurmcoil, 1);
assertPermanentCount(playerA, relic, 1);
assertCounterCount(aspirant, CounterType.P1P1, 1);
assertPermanentCount(playerA, "Wurm Token", 2);
assertPermanentCount(playerA, "Phyrexian Wurm Token", 2);
}
}

View file

@ -2,7 +2,6 @@ package org.mage.test.cards.triggers.dies;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -378,7 +377,6 @@ public class SacrificeDiesTriggerTest extends CardTestPlayerBase {
}
@Test
@Ignore // TODO: enable after shortLKI and move to battlefield will be fixed
public void test_DiesTriggerWhileMultiStepsEffect_ShortLKI() {
// see details on shortLKI problems in isInUseableZoneDiesTrigger
@ -414,4 +412,33 @@ public class SacrificeDiesTriggerTest extends CardTestPlayerBase {
// from end step trigger
assertPermanentCount(playerA, "Silvercoat Lion", 1);
}
// bug #9688
@Test
public void testIndustrialAdvancement() {
skipInitShuffling();
addCard(Zone.BATTLEFIELD, playerA, "Industrial Advancement");
// At the beginning of your end step, you may sacrifice a creature. If you do, look at the top X cards of your
// library, where X is that creatures mana value. You may put a creature card from among them onto the
// battlefield. Put the rest on the bottom of your library in a random order.
addCard(Zone.BATTLEFIELD, playerA, "Guardian Automaton"); // 3/3 gain 3 life when it dies
addCard(Zone.LIBRARY, playerA, "Lone Missionary"); // etb gain 4 life
addCard(Zone.LIBRARY, playerA, "Horned Turtle");
addCard(Zone.LIBRARY, playerA, "Maritime Guard");
addCard(Zone.LIBRARY, playerA, "Kraken Hatchling");
setChoice(playerA, "Guardian Automaton"); // sacrifice on end step
setChoice(playerA, "Lone Missionary"); // put onto battlefield
setChoice(playerA, "When {this} dies"); // choose trigger order
setStrictChooseMode(true);
setStopAt(2, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, "Lone Missionary", 1);
assertGraveyardCount(playerA, "Guardian Automaton", 1);
assertLife(playerA, 27);
}
}