* Fixed a bug that by countering a copied spell (e.g. by copied Memory Lapse), the copy could be removed from stack instead the originally countered spell (fixes #6823).

This commit is contained in:
LevelX2 2020-07-13 11:23:36 +02:00
parent 983019251e
commit c6c1b0ed3a
2 changed files with 10 additions and 2 deletions

View file

@ -65,7 +65,6 @@ public class CounterspellTest extends CardTestPlayerBase {
* the same card ID (6b5), which seems likely to cause issues.
*/
@Test
@Ignore
public void testCopyCounterToCounter() {
// Lightning Bolt deals 3 damage to any target.
addCard(Zone.HAND, playerA, "Lightning Bolt");
@ -78,7 +77,7 @@ public class CounterspellTest extends CardTestPlayerBase {
// Counter target spell. If that spell is countered this way, put it on top of its owner's library instead of into that player's graveyard.
addCard(Zone.HAND, playerB, "Memory Lapse"); // Instant {1}{U}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerA);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Memory Lapse", "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Twincast", "Memory Lapse");

View file

@ -1066,6 +1066,15 @@ public abstract class PlayerImpl implements Player, Serializable {
private boolean moveObjectToLibrary(UUID objectId, UUID sourceId, Game game, boolean toTop, boolean withName) {
MageObject mageObject = game.getObject(objectId);
if (mageObject instanceof Spell && mageObject.isCopy()) {
// Spell copies are not moved as cards, so here the no copy spell has to be selected to move
// (but because copy and original have the same objectId the wrong sepell can be selected from stack).
// So let's check if the original spell is on the stack and has to be selected. // TODO: Better handling so each spell could be selected by a unique id
Spell spellNoCopy = game.getStack().getSpell(sourceId, false);
if (spellNoCopy != null) {
mageObject = spellNoCopy;
}
}
if (mageObject != null) {
Zone fromZone = game.getState().getZone(objectId);
if ((mageObject instanceof Permanent)) {