Skip to content

Commit

Permalink
Open the way - fix maximum X costs
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Feb 11, 2025
1 parent 37cb2e3 commit a5f6752
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Mage.Sets/src/mage/cards/o/OpenTheWay.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public OpenTheWayEffect copy() {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
if (player == null || xValue < 1) {
int playerCount = game.getPlayers().size();
if (player == null || xValue < 1 || xValue > playerCount) {
return false;
}
Cards toReveal = new CardsImpl();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.mage.test.cards.cost.variable;

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

public class OpenTheWayTest extends CardTestPlayerBase {

@Test
public void testCardWithValidValue(){
addCard(Zone.BATTLEFIELD, playerA, "Forest", 10);
addCard(Zone.HAND, playerA, "Open the Way");
playerA.getLibrary().clear();
addCard(Zone.LIBRARY, playerA, "Forest", 10);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Open the Way");
setChoice(playerA, "X=2");

setStrictChooseMode(true);

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

assertPermanentCount(playerA, "Forest", 12);

}

@Test
public void testCardWithInvalidVAlue(){
addCard(Zone.BATTLEFIELD, playerA, "Forest", 10);
addCard(Zone.HAND, playerA, "Open the Way");
playerA.getLibrary().clear();
addCard(Zone.LIBRARY, playerA, "Forest", 10);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Open the Way");
setChoice(playerA, "X=5");

setStrictChooseMode(true);

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

assertPermanentCount(playerA, "Forest", 10);

}
}

0 comments on commit a5f6752

Please sign in to comment.