From f7d785e4068fe8d7f11160ad66fe3e73b0edb957 Mon Sep 17 00:00:00 2001 From: John Hitchings Date: Tue, 19 Mar 2019 23:32:18 -0700 Subject: [PATCH] Add rules comments and handle mulliganing to less than 0 cards for London. --- .../mage/game/mulligan/LondonMulligan.java | 22 ++++++++++++++++++- .../java/mage/game/mulligan/Mulligan.java | 19 +++++++++++++++- .../mage/game/mulligan/VancouverMulligan.java | 7 +++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Mage/src/main/java/mage/game/mulligan/LondonMulligan.java b/Mage/src/main/java/mage/game/mulligan/LondonMulligan.java index b63304b4ab..0ced5be723 100644 --- a/Mage/src/main/java/mage/game/mulligan/LondonMulligan.java +++ b/Mage/src/main/java/mage/game/mulligan/LondonMulligan.java @@ -22,6 +22,22 @@ public class LondonMulligan extends Mulligan { @Override public void executeMulliganPhase(Game game, int startingHandSize) { + /* + * 103.4. Each player draws a number of cards equal to their starting hand size, which is normally + * seven. (Some effects can modify a player’s starting hand size.) A player who is dissatisfied with + * their initial hand may take a mulligan. First, the starting player declares whether they will + * take a mulligan. Then each other player in turn order does the same. Once each player has made a + * declaration, all players who decided to take mulligans do so at the same time. To take a mulligan, + * a player shuffles the cards in their hand back into their library, draws a new hand of cards equal + * to their starting hand size, then puts a number of those cards onto the bottom of their library in + * any order equal to the number of times that player has taken a mulligan. Once a player chooses not + * to take a mulligan, the remaining cards become the player’s opening hand, and that player may not + * take any further mulligans. This process is then repeated until no player takes a mulligan. A + * player can’t take a number of mulligans greater their starting hand size. + * + * https://magic.wizards.com/en/articles/archive/competitive-gaming/mythic-championship-ii-format-and-london-test-2019-02-21 + */ + for (UUID playerId : game.getState().getPlayerList(game.getStartingPlayerId())) { startingHandSizes.put(playerId, startingHandSize); } @@ -40,7 +56,6 @@ public class LondonMulligan extends Mulligan { player.chooseTarget(Outcome.Neutral, cards, target, null, game); player.putCardsOnBottomOfLibrary(new CardsImpl(target.getTargets()), game, null, true); cards.removeAll(target.getTargets()); - System.out.println(cardsToDiscard); } } } @@ -62,6 +77,11 @@ public class LondonMulligan extends Mulligan { return startingHandSizes.get(playerId) - deduction; } + @Override + public boolean canTakeMulligan(Game game, Player player) { + return super.canTakeMulligan(game, player) && startingHandSizes.get(player.getId()) > 0; + } + @Override public void mulligan(Game game, UUID playerId) { Player player = game.getPlayer(playerId); diff --git a/Mage/src/main/java/mage/game/mulligan/Mulligan.java b/Mage/src/main/java/mage/game/mulligan/Mulligan.java index c12b6b0e7a..43abf6c284 100644 --- a/Mage/src/main/java/mage/game/mulligan/Mulligan.java +++ b/Mage/src/main/java/mage/game/mulligan/Mulligan.java @@ -16,6 +16,19 @@ public abstract class Mulligan { } public void executeMulliganPhase(Game game, int startingHandSize) { + /* + * 103.4. Each player draws a number of cards equal to their starting hand size, + * which is normally seven. (Some effects can modify a player’s starting hand size.) + * A player who is dissatisfied with their initial hand may take a mulligan. First + * the starting player declares whether they will take a mulligan. Then each other + * player in turn order does the same. Once each player has made a declaration, all + * players who decided to take mulligans do so at the same time. To take a mulligan, + * a player shuffles their hand back into their library, then draws a new hand of one + * fewer cards than they had before. If a player kept their hand of cards, those cards + * become the player’s opening hand, and that player may not take any further mulligans. + * This process is then repeated until no player takes a mulligan. (Note that if a + * player’s hand size reaches zero cards, that player must keep that hand.) + */ List keepPlayers = new ArrayList<>(); List mulliganPlayers = new ArrayList<>(); do { @@ -25,7 +38,7 @@ public abstract class Mulligan { Player player = game.getPlayer(playerId); boolean keep = true; while (true) { - if (player.getHand().isEmpty()) { + if (!canTakeMulligan(game, player)) { break; } GameEvent event = new GameEvent(GameEvent.EventType.CAN_TAKE_MULLIGAN, null, null, playerId); @@ -63,6 +76,10 @@ public abstract class Mulligan { public abstract Mulligan copy(); + public boolean canTakeMulligan(Game game, Player player) { + return !player.getHand().isEmpty(); + } + public int getFreeMulligans() { return freeMulligans; } diff --git a/Mage/src/main/java/mage/game/mulligan/VancouverMulligan.java b/Mage/src/main/java/mage/game/mulligan/VancouverMulligan.java index 0474a4df5f..9a131224d9 100644 --- a/Mage/src/main/java/mage/game/mulligan/VancouverMulligan.java +++ b/Mage/src/main/java/mage/game/mulligan/VancouverMulligan.java @@ -14,7 +14,12 @@ public class VancouverMulligan extends ParisMulligan { @Override public void executeMulliganPhase(Game game, int startingHandSize) { super.executeMulliganPhase(game, startingHandSize); - // new scry rule + /* + * 103.4 (scry rule) - After all players have kept an opening hand, each player in + * turn order whose hand contains fewer cards than that player’s starting hand size + * may look at the top card of their library. If a player does, that player may put + * that card on the bottom of their library. + */ for (UUID playerId : game.getState().getPlayerList(game.getStartingPlayerId())) { Player player = game.getPlayer(playerId); if (player != null && player.getHand().size() < startingHandSize) {