fixed world rule with range of influence

This commit is contained in:
18ths 2020-05-30 21:52:22 +02:00
parent 3333cf3287
commit d5c46816be
2 changed files with 38 additions and 9 deletions

View file

@ -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);
}
}

View file

@ -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;