From 8cef411c70d4d9fb10765809df11304a8a200058 Mon Sep 17 00:00:00 2001 From: xenohedron Date: Fri, 19 Jan 2024 18:32:01 -0500 Subject: [PATCH] fix LoseLifeControllerAttachedEffect (#11680) add test for Pooling Venom --- .../cards/single/fut/PoolingVenomTest.java | 63 +++++++++++++++++++ .../LoseLifeControllerAttachedEffect.java | 5 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/fut/PoolingVenomTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/fut/PoolingVenomTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/fut/PoolingVenomTest.java new file mode 100644 index 00000000000..dcb55b5fb54 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/fut/PoolingVenomTest.java @@ -0,0 +1,63 @@ +package org.mage.test.cards.single.fut; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author xenohedron + */ +public class PoolingVenomTest extends CardTestPlayerBase { + + private static final String venom = "Pooling Venom"; + // Whenever enchanted land becomes tapped, its controller loses 2 life. + + private static final String island = "Island"; + private static final String swamp = "Swamp"; + private static final String addU = "{T}: Add {U}"; + private static final String addB = "{T}: Add {B}"; + + @Test + public void testOppsLand() { + addCard(Zone.BATTLEFIELD, playerB, island); + addCard(Zone.BATTLEFIELD, playerA, swamp, 2); + addCard(Zone.HAND, playerA, venom); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, venom, island); + + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerB, addU); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, venom, 1); + assertTapped(island, true); + assertLife(playerA, 20); + assertLife(playerB, 18); + + } + + @Test + public void testOwnLand() { + addCard(Zone.BATTLEFIELD, playerA, island); + addCard(Zone.BATTLEFIELD, playerA, swamp, 2); + addCard(Zone.HAND, playerA, venom); + + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, addB); + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, addB); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, venom, island); + + activateManaAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, addU); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, venom, 1); + assertTapped(island, true); + assertLife(playerA, 18); + assertLife(playerB, 20); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeControllerAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeControllerAttachedEffect.java index 21c7fbca1bb..6d21f5b43e9 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeControllerAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeControllerAttachedEffect.java @@ -44,7 +44,10 @@ public class LoseLifeControllerAttachedEffect extends OneShotEffect { Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(), Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter()); if (attachedTo == null) { - return false; + attachedTo = game.getPermanent(attachment.getAttachedTo()); + if (attachedTo == null) { + return false; + } } Player player = game.getPlayer(attachedTo.getControllerId()); if (player == null) {