Skip to content

Commit

Permalink
NowhereToRun - fixed hexproof effect
Browse files Browse the repository at this point in the history
  • Loading branch information
markort147 committed Jan 9, 2025
1 parent f4a13cc commit c7208c6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/cards/n/NowhereToRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId,
if (affectedControllerId.equals(source.getControllerId())) {
Permanent creature = game.getPermanent(sourceId);
return creature != null
&& creature.isCreature(game)
&& game.getOpponents(source.getControllerId()).contains(creature.getControllerId());
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;

Expand Down Expand Up @@ -51,4 +52,55 @@ public void testWardOnOwnCreatures() {
assertPermanentCount(playerA, "Waterfall Aerialist", 1);
assertGraveyardCount(playerB, "Swords to Plowshares", 1);
}

// Prevent hexproof on opponent's creatures
@Test
public void testHexproofOnCreatures() {

addCard(Zone.BATTLEFIELD, playerB, "Gladecover Scout", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, "Nowhere to Run", 1);
addCard(Zone.HAND, playerA, "Go for the Throat", 1);

setStrictChooseMode(true);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Go for the Throat");
addTarget(playerA, "Gladecover Scout");

setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();

assertPermanentCount(playerB, "Gladecover Scout", 0);
}

// Does not prevent hexproof on non-creature permanents
@Test
public void testHexproofOnOtherPermanents() {

addCard(Zone.BATTLEFIELD, playerB, "Valgavoth's Lair", 1);
setChoice(playerB, "Red");

addCard(Zone.BATTLEFIELD, playerA, "Nowhere to Run", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
addCard(Zone.HAND, playerA, "Stone Rain", 1);

setStrictChooseMode(true);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Stone Rain");
addTarget(playerA, "Valgavoth's Lair");

setStopAt(1, PhaseStep.BEGIN_COMBAT);

try {
execute();
} catch (Throwable e) {
if (!e.getMessage().contains("Targets list was setup by addTarget with [Valgavoth's Lair], but not used")) {
Assert.fail("must throw error about bad targets, but got:\n" + e.getMessage());
}
return;
}
Assert.fail("must throw exception on execute");
}

}

0 comments on commit c7208c6

Please sign in to comment.