Skip to content

Commit 701bd68

Browse files
committed
tests: added test for LKI from copied spell (related to Swan Song fix from #12883)
1 parent afde449 commit 701bd68

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

Mage.Tests/src/test/java/org/mage/test/cards/copy/CopySpellTest.java

+53-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.util.UUID;
2323

2424
/**
25-
* @author LevelX2
25+
* @author LevelX2, JayDi85
2626
*/
2727
public class CopySpellTest extends CardTestPlayerBase {
2828

@@ -905,4 +905,56 @@ private void cardsMustHaveSameZoneAndZCC(Card originalCard, Card copiedCard, Str
905905
Assert.fail(infoPrefix + " - " + "cards must have same zone and zcc: " + zcc1 + " - " + zone1 + " != " + zcc2 + " - " + zone2);
906906
}
907907
}
908+
909+
/**
910+
* Bug: If Swan Song is used to counter a copied spell, no tokens are created #12883
911+
*/
912+
@Test
913+
public void test_LKI() {
914+
// Counter target enchantment, instant, or sorcery spell.
915+
// Its controller creates a 2/2 blue Bird creature token with flying.
916+
addCard(Zone.HAND, playerA, "Swan Song", 1); // {U}
917+
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
918+
//
919+
// Until end of turn, whenever a player casts an instant or sorcery spell, that player copies it and
920+
// may choose new targets for the copy.
921+
addCard(Zone.HAND, playerA, "Bonus Round", 1); // {1}{R}{R}
922+
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
923+
//
924+
addCard(Zone.HAND, playerA, "Lightning Bolt", 1); // {R}
925+
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
926+
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears", 1);
927+
addCard(Zone.BATTLEFIELD, playerB, "Augmenting Automaton", 1);
928+
929+
checkPermanentCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, playerA, "Bird Token", 0);
930+
checkPermanentCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, playerB, "Grizzly Bears", 1);
931+
checkPermanentCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, playerB, "Augmenting Automaton", 1);
932+
933+
// prepare copy effect
934+
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}", 3);
935+
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bonus Round");
936+
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
937+
938+
// cast and duplicate bolt
939+
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt");
940+
addTarget(playerA, "Grizzly Bears"); // original target
941+
setChoice(playerA, true); // use new target
942+
addTarget(playerA, "Augmenting Automaton"); // copy target
943+
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, true); // resolve copy trigger
944+
checkStackObject("on copy", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", 2);
945+
946+
// counter copy and save Augmenting Automaton
947+
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {U}", 1);
948+
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Swan Song", "Lightning Bolt[only copy]", "Lightning Bolt", StackClause.WHILE_COPY_ON_STACK);
949+
setChoice(playerA, false); // no change target for duplicated counter spell (non-relevant here)
950+
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
951+
952+
checkPermanentCount("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, playerA, "Bird Token", 1);
953+
checkPermanentCount("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, playerB, "Grizzly Bears", 0);
954+
checkPermanentCount("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, playerB, "Augmenting Automaton", 1);
955+
956+
setStrictChooseMode(true);
957+
setStopAt(1, PhaseStep.END_COMBAT);
958+
execute();
959+
}
908960
}

Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ private void printAliases(Game game, TestPlayer player) {
12911291
private void printStack(Game game) {
12921292
System.out.println("Stack objects: " + game.getStack().size());
12931293
game.getStack().forEach(stack -> {
1294-
System.out.println(stack.getStackAbility().toString());
1294+
System.out.println(stack.getStackAbility().toString() + (stack.isCopy() ? " [copy]" : ""));
12951295
});
12961296
}
12971297

Mage/src/main/java/mage/game/stack/SpellStack.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public boolean counter(UUID objectId, Ability source, Game game, PutCards putCar
8383
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, source, stackObject.getControllerId()))) {
8484
// spells are removed from stack by the card movement
8585
if (!(stackObject instanceof Spell)
86-
|| stackObject.isCopy()) { // ensure that copies of stackobjects have their history recorded ie: Swan Song
86+
|| stackObject.isCopy()) { // !ensure that copies of stackobjects have their history recorded ie: Swan Song
8787
this.remove(stackObject, game);
8888
game.rememberLKI(Zone.STACK, stackObject);
8989
}

0 commit comments

Comments
 (0)