fix short living lki bug for Chromatic Star (#12331)

This commit is contained in:
Susucre 2024-05-30 21:07:48 +02:00 committed by GitHub
parent 3097681b8e
commit 6f4fbeffe3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 73 additions and 1 deletions

View file

@ -2,12 +2,14 @@ package org.mage.test.cards.single.dmu;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.players.Player;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author TheElk801
* @author TheElk801, Susucr
*/
public class SerraParagonTest extends CardTestPlayerBase {
@ -93,4 +95,62 @@ public class SerraParagonTest extends CardTestPlayerBase {
}
}
}
/**
* bug: Chromatic Star was not triggering the gained trigger.
*/
@Test
public void testChromaticStar() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, paragon);
addCard(Zone.GRAVEYARD, playerA, "Chromatic Star");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chromatic Star", true);
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {W}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}, {T}, Sacrifice");
setChoice(playerA, "Red"); // mana added with Star
setChoice(playerA, "When this permanent is put into a graveyard from the battlefield, exile it and you gain 2 life."); // stack triggers
// Last trigger is: "When {this} is put into a graveyard from the battlefield, draw a card." from Chromatic Star
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
assertLife(playerA, 20 + 2);
assertExileCount(playerA, "Chromatic Star", 1);
}
private static void checkEnergyCount(String message, Player player, int expected) {
Assert.assertEquals(message, expected, player.getCountersCount(CounterType.ENERGY));
}
@Test
public void testAetherworksMarvel() {
setStrictChooseMode(true);
// Whenever a permanent you control is put into a graveyard from the battlefield, you get {E}
addCard(Zone.BATTLEFIELD, playerA, "Aetherworks Marvel");
addCard(Zone.BATTLEFIELD, playerA, paragon);
addCard(Zone.GRAVEYARD, playerA, "Chromatic Star");
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
addCard(Zone.HAND, playerA, "Creeping Corrosion"); // Destroy all artifacts
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chromatic Star", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Creeping Corrosion", true);
setChoice(playerA, "When this permanent is put into a graveyard from the battlefield, exile it and you gain 2 life."); // stack triggers
setChoice(playerA, "Whenever a permanent you control is put into a graveyard from the battlefield, you get {E}", 2); // stack triggers
// Last trigger is: "When {this} is put into a graveyard from the battlefield, draw a card." from Chromatic Star
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
runCode("energy counter is 2", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> checkEnergyCount(info, player, 2));
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
assertExileCount(playerA, "Chromatic Star", 1);
assertGraveyardCount(playerA, 2);
assertLife(playerA, 20 + 2);
}
}

View file

@ -1,6 +1,7 @@
package mage.abilities.common;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
@ -63,4 +64,9 @@ public class PutIntoGraveFromBattlefieldAllTriggeredAbility extends TriggeredAbi
public PutIntoGraveFromBattlefieldAllTriggeredAbility copy() {
return new PutIntoGraveFromBattlefieldAllTriggeredAbility(this);
}
@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}

View file

@ -1,5 +1,6 @@
package mage.abilities.common;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
@ -55,4 +56,9 @@ public class PutIntoGraveFromBattlefieldSourceTriggeredAbility extends Triggered
this.getEffects().setValue("permanentWasCreature", permanent.isCreature(game));
return true;
}
@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}