diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/rules/WorldEnchantmentsRuleTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/rules/WorldEnchantmentsRuleTest.java index 0d8fa4034a..6a5258b212 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/rules/WorldEnchantmentsRuleTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/rules/WorldEnchantmentsRuleTest.java @@ -4,14 +4,14 @@ package org.mage.test.cards.rules; import mage.constants.PhaseStep; import mage.constants.Zone; import org.junit.Test; -import org.mage.test.serverside.base.CardTestPlayerBase; +import org.mage.test.serverside.base.CardTestMultiPlayerBase; /** * * @author LevelX2 */ -public class WorldEnchantmentsRuleTest extends CardTestPlayerBase { +public class WorldEnchantmentsRuleTest extends CardTestMultiPlayerBase { /** * 704.5m If two or more permanents have the supertype world, all except the one that has had @@ -21,24 +21,47 @@ public class WorldEnchantmentsRuleTest extends CardTestPlayerBase { * */ @Test - public void TestTwoWorldEnchantsments() { + public void TestTwoWorldEnchantments() { addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1); addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); addCard(Zone.HAND, playerA, "Nether Void", 1); addCard(Zone.HAND, playerA, "Silvercoat Lion", 1); - addCard(Zone.BATTLEFIELD, playerB, "Swamp", 7); - addCard(Zone.HAND, playerB, "Nether Void", 1); + addCard(Zone.BATTLEFIELD, playerD, "Swamp", 7); + addCard(Zone.HAND, playerD, "Nether Void", 1); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Nether Void"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion"); // just needed to get different craete time to second Nether Void - castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Nether Void"); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerD, "Nether Void"); setStopAt(2, PhaseStep.END_TURN); execute(); + assertAllCommandsUsed(); assertPermanentCount(playerA, "Nether Void", 0); - assertPermanentCount(playerB, "Nether Void", 1); + assertPermanentCount(playerD, "Nether Void", 1); + } + + // 801.12 The "world rule" applies to a permanent only if other world permanents are within its controller's range of influence. + @Test + public void TestTwoWorldEnchantmentsNotInRangeOfInfluence() { + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); + addCard(Zone.HAND, playerA, "Nether Void", 1); + addCard(Zone.HAND, playerA, "Silvercoat Lion", 1); + + addCard(Zone.BATTLEFIELD, playerC, "Swamp", 7); + addCard(Zone.HAND, playerC, "Nether Void", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Nether Void"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion"); // just needed to get different craete time to second Nether Void + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerC, "Nether Void"); + + setStopAt(3, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Nether Void", 1); + assertPermanentCount(playerC, "Nether Void", 1); } - } \ No newline at end of file diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 612783bf0a..bed1000a87 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -2235,13 +2235,19 @@ public abstract class GameImpl implements Game, Serializable { newestPermanent = null; } } + + PlayerList newestPermanentControllerRange = state.getPlayersInRange(newestPermanent.getControllerId(), this); + + // 801.12 The "world rule" applies to a permanent only if other world permanents are within its controller's range of influence. for (Permanent permanent : worldEnchantment) { - if (!Objects.equals(newestPermanent, permanent)) { + if (newestPermanentControllerRange.contains(permanent.getControllerId()) + && !Objects.equals(newestPermanent, permanent)) { movePermanentToGraveyardWithInfo(permanent); somethingHappened = true; } } } + //TODO: implement the rest return somethingHappened;