From 3dfe9de05fc0a1b7682cf481ee2b8aa79fe6a3a0 Mon Sep 17 00:00:00 2001 From: spjspj Date: Sun, 27 Mar 2016 00:07:23 +1100 Subject: [PATCH] spjspj - Add the 'Skip to End Step of Previous Player' button to the GamePanel and associated changes --- .../main/java/mage/client/game/GamePanel.java | 71 ++++++++++++++---- .../java/mage/client/game/PlayAreaPanel.java | 13 +++- .../mage/plugins/card/utils/ImageManager.java | 1 + .../card/utils/impl/ImageManagerImpl.java | 9 +++ .../src/main/resources/buttons/blank.png | Bin 0 -> 8378 bytes .../buttons/skip_to_previous_end.png | Bin 0 -> 2351 bytes Mage.Common/src/mage/view/PlayerView.java | 6 ++ .../src/mage/player/human/HumanPlayer.java | 18 ++++- .../java/org/mage/test/player/TestPlayer.java | 8 +- .../java/org/mage/test/stub/PlayerStub.java | 6 ++ .../java/mage/constants/PlayerAction.java | 1 + Mage/src/main/java/mage/players/Player.java | 2 + .../main/java/mage/players/PlayerImpl.java | 25 ++++++ 13 files changed, 143 insertions(+), 17 deletions(-) create mode 100644 Mage.Client/src/main/resources/buttons/blank.png create mode 100644 Mage.Client/src/main/resources/buttons/skip_to_previous_end.png diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index 3fd791d392..d062ed5d76 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -396,8 +396,8 @@ public final class GamePanel extends javax.swing.JPanel { jSplitPane2.setDividerSize(GUISizeHelper.dividerBarSize); stackObjects.setCardDimension(GUISizeHelper.handCardDimension); int newStackWidth = jPanel3.getWidth() * GUISizeHelper.stackWidth / 100; - if (newStackWidth < 360) { - newStackWidth = 360; + if (newStackWidth < 410) { + newStackWidth = 410; } Dimension newDimension = new Dimension(jPanel3.getWidth() - newStackWidth, GUISizeHelper.handCardDimension.height + GUISizeHelper.scrollBarSize); handContainer.setPreferredSize(newDimension); @@ -508,6 +508,7 @@ public final class GamePanel extends javax.swing.JPanel { this.btnSkipToNextMain.setVisible(true); this.btnSkipStack.setVisible(true); this.btnSkipToYourTurn.setVisible(true); + this.btnSkipToEndStepBeforeYourTurn.setVisible(true); this.pnlReplay.setVisible(false); @@ -541,6 +542,7 @@ public final class GamePanel extends javax.swing.JPanel { this.btnSkipToNextMain.setVisible(false); this.btnSkipStack.setVisible(false); this.btnSkipToYourTurn.setVisible(false); + this.btnSkipToEndStepBeforeYourTurn.setVisible(false); this.pnlReplay.setVisible(false); this.gameChatPanel.clear(); @@ -774,7 +776,8 @@ public final class GamePanel extends javax.swing.JPanel { } players.get(player.getPlayerId()).update(player); if (player.getPlayerId().equals(playerId)) { - updateSkipButtons(player.isPassedTurn(), player.isPassedUntilEndOfTurn(), player.isPassedUntilNextMain(), player.isPassedAllTurns(), player.isPassedUntilStackResolved()); + updateSkipButtons(player.isPassedTurn(), player.isPassedUntilEndOfTurn(), player.isPassedUntilNextMain(), player.isPassedAllTurns(), player.isPassedUntilStackResolved(), + player.isPassedUntilEndStepBeforeMyTurn()); } // update open or remove closed graveyard windows graveyards.put(player.getName(), player.getGraveyard()); @@ -850,7 +853,7 @@ public final class GamePanel extends javax.swing.JPanel { static final int BORDER_SIZE = 2; - private void updateSkipButtons(boolean turn, boolean endOfTurn, boolean nextMain, boolean allTurns, boolean stack) { + private void updateSkipButtons(boolean turn, boolean endOfTurn, boolean nextMain, boolean allTurns, boolean stack, boolean endStepBeforeYourStep) { if (turn) { //F4 btnSkipToNextTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE)); } else { @@ -877,6 +880,12 @@ public final class GamePanel extends javax.swing.JPanel { btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)); } + if (endStepBeforeYourStep) { // F11 + btnSkipToEndStepBeforeYourTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE)); + } else { + btnSkipToEndStepBeforeYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)); + } + } /** @@ -1274,6 +1283,7 @@ public final class GamePanel extends javax.swing.JPanel { btnSkipToNextMain = new javax.swing.JButton(); // F7 btnSkipStack = new javax.swing.JButton(); // F8 btnSkipToYourTurn = new javax.swing.JButton(); // F9 + btnSkipToEndStepBeforeYourTurn = new javax.swing.JButton(); // F11 btnConcede = new javax.swing.JButton(); btnSwitchHands = new javax.swing.JButton(); @@ -1302,7 +1312,7 @@ public final class GamePanel extends javax.swing.JPanel { handCards = new HashMap<>(); pnlShortCuts.setOpaque(false); - pnlShortCuts.setPreferredSize(new Dimension(400, 72)); + pnlShortCuts.setPreferredSize(new Dimension(410, 72)); stackObjects = new mage.client.cards.Cards(); @@ -1473,6 +1483,29 @@ public final class GamePanel extends javax.swing.JPanel { } }); + btnSkipToEndStepBeforeYourTurn.setContentAreaFilled(false); + btnSkipToEndStepBeforeYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)); + btnSkipToEndStepBeforeYourTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipEndStepBeforeYourTurnButtonImage())); + btnSkipToEndStepBeforeYourTurn.setToolTipText("Skip to the end step before your turn (F11) - adjust using preferences."); + btnSkipToEndStepBeforeYourTurn.setFocusable(false); + btnSkipToEndStepBeforeYourTurn.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent evt) { + if (evt.getButton() == MouseEvent.BUTTON1) { + btnSkipToEndStepBeforeYourTurnActionPerformed(null); + } + } + }); + + KeyStroke ks11 = KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0); + this.getInputMap(c).put(ks11, "F11_PRESS"); + this.getActionMap().put("F11_PRESS", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + btnSkipToEndStepBeforeYourTurnActionPerformed(actionEvent); + } + }); + btnSkipStack.setContentAreaFilled(false); btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)); btnSkipStack.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipStackButtonImage())); @@ -1695,6 +1728,7 @@ public final class GamePanel extends javax.swing.JPanel { .addComponent(btnSkipToNextMain) .addComponent(btnSkipToYourTurn) .addComponent(btnSkipStack) + .addComponent(btnSkipToEndStepBeforeYourTurn) ) .addGroup(gl_pnlShortCuts.createSequentialGroup() .addComponent(txtSpellsCast) @@ -1727,6 +1761,7 @@ public final class GamePanel extends javax.swing.JPanel { .addComponent(btnSkipToNextMain) .addComponent(btnSkipToYourTurn) .addComponent(btnSkipStack) + .addComponent(btnSkipToEndStepBeforeYourTurn) ) .addGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(txtSpellsCast) @@ -1799,8 +1834,8 @@ public final class GamePanel extends javax.swing.JPanel { .addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ) .addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING) - .addComponent(pnlShortCuts, 360, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) - .addComponent(stackObjects, 360, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) + .addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) + .addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) ) ) .addGap(0) @@ -1886,6 +1921,9 @@ public final class GamePanel extends javax.swing.JPanel { for (MouseListener ml : this.btnSkipStack.getMouseListeners()) { this.btnSkipStack.removeMouseListener(ml); } + for (MouseListener ml : this.btnSkipToEndStepBeforeYourTurn.getMouseListeners()) { + this.btnSkipToEndStepBeforeYourTurn.removeMouseListener(ml); + } for (MouseListener ml : this.btnSkipToEndTurn.getMouseListeners()) { this.btnSkipToEndTurn.removeMouseListener(ml); } @@ -1956,37 +1994,43 @@ public final class GamePanel extends javax.swing.JPanel { private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null); AudioManager.playOnSkipButton(); - updateSkipButtons(true, false, false, false, false); + updateSkipButtons(true, false, false, false, false, false); } private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null); AudioManager.playOnSkipButton(); - updateSkipButtons(false, true, false, false, false); + updateSkipButtons(false, true, false, false, false, false); } private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null); AudioManager.playOnSkipButton(); - updateSkipButtons(false, false, true, false, false); + updateSkipButtons(false, false, true, false, false, false); } private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null); AudioManager.playOnSkipButton(); - updateSkipButtons(false, false, false, true, false); + updateSkipButtons(false, false, false, true, false, false); } private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null); AudioManager.playOnSkipButton(); - updateSkipButtons(false, false, false, false, true); + updateSkipButtons(false, false, false, false, true, false); + } + + private void btnSkipToEndStepBeforeYourTurnActionPerformed(java.awt.event.ActionEvent evt) { + session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null); + AudioManager.playOnSkipButton(); + updateSkipButtons(false, false, false, false, false, true); } private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null); AudioManager.playOnSkipButtonCancel(); - updateSkipButtons(false, false, false, false, false); + updateSkipButtons(false, false, false, false, false, false); } private void mouseClickPhaseBar(MouseEvent evt) { @@ -2205,6 +2249,7 @@ public final class GamePanel extends javax.swing.JPanel { private javax.swing.JButton btnSkipToNextMain; // F7 private javax.swing.JButton btnSkipStack; // F8 private javax.swing.JButton btnSkipToYourTurn; // F9 + private javax.swing.JButton btnSkipToEndStepBeforeYourTurn; // F11 private javax.swing.JButton btnConcede; private javax.swing.JButton btnSwitchHands; diff --git a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java index 20fe42c381..0f1c215e28 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java @@ -184,6 +184,10 @@ public class PlayAreaPanel extends javax.swing.JPanel { gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null); break; } + case "F11": { + gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null); + break; + } } } }; @@ -229,7 +233,14 @@ public class PlayAreaPanel extends javax.swing.JPanel { menuItem = new JMenuItem("F9 - Everything until your own next turn"); menuItem.setActionCommand("F9"); menuItem.setToolTipText(tooltipText); - menuItem.setMnemonic(KeyEvent.VK_N); + menuItem.setMnemonic(KeyEvent.VK_V); + skipMenu.add(menuItem); + menuItem.addActionListener(skipListener); + + menuItem = new JMenuItem("F11 - Everything until end step prior to your own next turn"); + menuItem.setActionCommand("F11"); + menuItem.setToolTipText(tooltipText); + menuItem.setMnemonic(KeyEvent.VK_P); skipMenu.add(menuItem); menuItem.addActionListener(skipListener); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/utils/ImageManager.java b/Mage.Client/src/main/java/org/mage/plugins/card/utils/ImageManager.java index 63f2dcf900..d198e8ae04 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/utils/ImageManager.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/utils/ImageManager.java @@ -41,6 +41,7 @@ public interface ImageManager { Image getSkipEndTurnButtonImage(); Image getSkipMainButtonImage(); Image getSkipStackButtonImage(); + Image getSkipEndStepBeforeYourTurnButtonImage(); Image getSkipYourNextTurnButtonImage(); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java b/Mage.Client/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java index 9209be5d87..d82ceeb37d 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java @@ -328,6 +328,14 @@ public class ImageManagerImpl implements ImageManager { return imageSkipStackButton; } + @Override + public Image getSkipEndStepBeforeYourTurnButtonImage() { + if (imageSkipUntilEndStepBeforeYourTurnButton == null) { + imageSkipUntilEndStepBeforeYourTurnButton = getBufferedImageFromResource("/buttons/skip_to_previous_end.png"); + } + return imageSkipUntilEndStepBeforeYourTurnButton; + } + @Override public Image getSkipYourNextTurnButtonImage() { if (imageSkipYourNextTurnButton == null) { @@ -427,6 +435,7 @@ public class ImageManagerImpl implements ImageManager { private static BufferedImage imageSkipToEndTurnButton; private static BufferedImage imageSkipToMainButton; private static BufferedImage imageSkipStackButton; + private static BufferedImage imageSkipUntilEndStepBeforeYourTurnButton; private static BufferedImage imageSkipYourNextTurnButton; private static Map phasesImages; diff --git a/Mage.Client/src/main/resources/buttons/blank.png b/Mage.Client/src/main/resources/buttons/blank.png new file mode 100644 index 0000000000000000000000000000000000000000..3dcfd353236bc59642c052f2812751951767e704 GIT binary patch literal 8378 zcmd^FYitx%6h1q%vorhbZnoRUZcCd6VUY?EiWZ56N=a!1qM{~PQ644|ei#!?G{*Qt z{lgC;(ST6`BBm14fbsQ1g%YZzl}A7nXbHBKmUby!yN_<$ea(8#w0F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S_-P!OfabX zjAGJLC{Y?ch|pj8u8s~4y?2lun>Mx`Ke+2<{B2c0tx*@$hA)c36hup&E4^Ux%zG9T z-!fx{oRynPVzL`ak`M$CM#<$+({v05gIsQHqp_}z>i6Fd9C&lb;r8<<%L(;-9;JM6 zxTlHU|O$JY8K{b3;R@q3%o1 z;rI6+ZEvYRNTB0mpb_};YRcmMA4VV%7zd;xNG>GnH3&*Ff@mE@&tpNfP&b;tm0)qMPh(eQfUn!*=>H)M{{a%! VeI9z&ZWjOm002ovPDHLkV1hfGc{Tt5 literal 0 HcmV?d00001 diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index ee63045b38..6e370a8028 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -83,6 +83,7 @@ public class PlayerView implements Serializable { private final boolean passedUntilNextMain; // F6 private final boolean passedUntilStackResolved; // F8 private final boolean passedAllTurns; // F9 + private final boolean passedUntilEndStepBeforeMyTurn; // F11 public PlayerView(Player player, GameState state, Game game, UUID createdForPlayerId, UUID watcherUserId) { this.playerId = player.getId(); @@ -167,6 +168,7 @@ public class PlayerView implements Serializable { this.passedUntilNextMain = player.getPassedUntilNextMain(); this.passedAllTurns = player.getPassedAllTurns(); this.passedUntilStackResolved = player.getPassedUntilStackResolved(); + this.passedUntilEndStepBeforeMyTurn = player.getPassedUntilEndStepBeforeMyTurn(); } private boolean showInBattlefield(Permanent permanent, GameState state) { @@ -303,4 +305,8 @@ public class PlayerView implements Serializable { public boolean isPassedUntilStackResolved() { return passedUntilStackResolved; } + + public boolean isPassedUntilEndStepBeforeMyTurn() { + return passedUntilEndStepBeforeMyTurn; + } } diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 95fa8274e3..e8ebf4ce6d 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -91,6 +91,7 @@ import mage.game.permanent.Permanent; import mage.game.tournament.Tournament; import mage.players.Player; import mage.players.PlayerImpl; +import mage.players.PlayerList; import mage.target.Target; import mage.target.TargetAmount; import mage.target.TargetCard; @@ -589,6 +590,21 @@ public class HumanPlayer extends PlayerImpl { return false; } } + if (passedUntilEndStepBeforeMyTurn) { + + if (!game.getTurn().getStepType().equals(PhaseStep.END_TURN)) { + if (passWithManaPoolCheck(game)) { + return false; + } + } else { + PlayerList playerList = game.getState().getPlayerList(playerId); + if (!playerList.getPrevious().equals(game.getActivePlayerId())) { + if (passWithManaPoolCheck(game)) { + return false; + } + } + } + } if (game.getStack().isEmpty()) { passedUntilStackResolved = false; boolean dontCheckPassStep = false; @@ -878,7 +894,7 @@ public class HumanPlayer extends PlayerImpl { FilterCreatureForCombat filter = filterCreatureForCombat.copy(); filter.add(new ControllerIdPredicate(attackingPlayerId)); while (!abort) { - if (passedAllTurns + if (passedAllTurns || passedUntilEndStepBeforeMyTurn || (!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedUntilEndOfTurn || passedUntilNextMain))) { return; } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 0f00d30abd..be5d9f0eb0 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -117,7 +117,6 @@ public class TestPlayer implements Player { private int maxCallsWithoutAction = 100; private int foundNoAction = 0; private boolean AIPlayer; - private final List actions = new ArrayList<>(); private final List choices = new ArrayList<>(); private final List targets = new ArrayList<>(); @@ -1928,7 +1927,12 @@ public class TestPlayer implements Player { public boolean getPassedUntilStackResolved() { return computerPlayer.getPassedUntilStackResolved(); } - + + @Override + public boolean getPassedUntilEndStepBeforeMyTurn() { + return computerPlayer.getPassedUntilEndStepBeforeMyTurn(); + } + @Override public void revokePermissionToSeeHandCards() { computerPlayer.revokePermissionToSeeHandCards(); diff --git a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java index 86d39bd888..7635562a5c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java +++ b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java @@ -348,10 +348,16 @@ public class PlayerStub implements Player { return false; } + @Override public boolean getPassedAllTurns() { return false; } + + @Override + public boolean getPassedUntilEndStepBeforeMyTurn() { + return false; + } @Override public AbilityType getJustActivatedType() { diff --git a/Mage/src/main/java/mage/constants/PlayerAction.java b/Mage/src/main/java/mage/constants/PlayerAction.java index baee51e5f1..5568ac2f55 100644 --- a/Mage/src/main/java/mage/constants/PlayerAction.java +++ b/Mage/src/main/java/mage/constants/PlayerAction.java @@ -39,6 +39,7 @@ public enum PlayerAction { PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, PASS_PRIORITY_UNTIL_NEXT_TURN, PASS_PRIORITY_UNTIL_STACK_RESOLVED, + PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, PASS_PRIORITY_CANCEL_ALL_ACTIONS, TRIGGER_AUTO_ORDER_ABILITY_FIRST, TRIGGER_AUTO_ORDER_NAME_FIRST, diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index d5f34cb80d..f22e112c06 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -193,6 +193,8 @@ public interface Player extends MageItem, Copyable { boolean getPassedUntilStackResolved(); + boolean getPassedUntilEndStepBeforeMyTurn(); + boolean getPassedAllTurns(); AbilityType getJustActivatedType(); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 1b8dfeb870..d2b86ab37a 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -178,6 +178,7 @@ public abstract class PlayerImpl implements Player, Serializable { protected boolean passedUntilEndOfTurn; // F5 protected boolean passedUntilNextMain; // F6 protected boolean passedUntilStackResolved; // F8 + protected boolean passedUntilEndStepBeforeMyTurn; // F11 protected Date dateLastAddedToStack; // F8 protected boolean skippedAtLeastOnce; // used to track if passed started in specific phase /** @@ -327,6 +328,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.passedUntilNextMain = player.passedUntilNextMain; this.skippedAtLeastOnce = player.skippedAtLeastOnce; this.passedUntilStackResolved = player.passedUntilStackResolved; + this.passedUntilEndStepBeforeMyTurn = player.passedUntilEndStepBeforeMyTurn; this.dateLastAddedToStack = player.dateLastAddedToStack; this.passedAllTurns = player.passedAllTurns; this.justActivatedType = player.justActivatedType; @@ -454,6 +456,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.passedUntilNextMain = false; this.skippedAtLeastOnce = false; this.passedUntilStackResolved = false; + this.passedUntilEndStepBeforeMyTurn = false; this.passedAllTurns = false; this.justActivatedType = null; this.canGainLife = true; @@ -1945,6 +1948,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.passedUntilEndOfTurn = false; this.passedUntilNextMain = false; this.passedUntilStackResolved = false; + this.passedUntilEndStepBeforeMyTurn = false; this.dateLastAddedToStack = null; this.skippedAtLeastOnce = false; this.passedAllTurns = false; @@ -1991,6 +1995,7 @@ public abstract class PlayerImpl implements Player, Serializable { passedTurn = false; passedAllTurns = true; passedUntilStackResolved = false; + passedUntilEndStepBeforeMyTurn = false; this.skip(); break; case PASS_PRIORITY_UNTIL_TURN_END_STEP: // F5 @@ -1999,6 +2004,7 @@ public abstract class PlayerImpl implements Player, Serializable { passedAllTurns = false; passedUntilEndOfTurn = true; passedUntilStackResolved = false; + passedUntilEndStepBeforeMyTurn = false; skippedAtLeastOnce = !PhaseStep.END_TURN.equals(game.getTurn().getStepType()); this.skip(); break; @@ -2007,6 +2013,7 @@ public abstract class PlayerImpl implements Player, Serializable { passedAllTurns = false; passedUntilEndOfTurn = false; passedUntilStackResolved = false; + passedUntilEndStepBeforeMyTurn = false; passedTurn = true; this.skip(); break; @@ -2016,6 +2023,7 @@ public abstract class PlayerImpl implements Player, Serializable { passedUntilEndOfTurn = false; passedUntilNextMain = true; passedUntilStackResolved = false; + passedUntilEndStepBeforeMyTurn = false; skippedAtLeastOnce = !(game.getTurn().getStepType().equals(PhaseStep.POSTCOMBAT_MAIN) || game.getTurn().getStepType().equals(PhaseStep.PRECOMBAT_MAIN)); this.skip(); break; @@ -2025,15 +2033,26 @@ public abstract class PlayerImpl implements Player, Serializable { passedUntilEndOfTurn = false; passedUntilNextMain = false; passedUntilStackResolved = true; + passedUntilEndStepBeforeMyTurn = false; dateLastAddedToStack = game.getStack().getDateLastAdded(); this.skip(); break; + case PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN: //F11 + passedAllTurns = false; + passedTurn = false; + passedUntilEndOfTurn = false; + passedUntilNextMain = false; + passedUntilStackResolved = false; + passedUntilEndStepBeforeMyTurn = true; + this.skip(); + break; case PASS_PRIORITY_CANCEL_ALL_ACTIONS: passedAllTurns = false; passedTurn = false; passedUntilEndOfTurn = false; passedUntilNextMain = false; passedUntilStackResolved = false; + passedUntilEndStepBeforeMyTurn = false; break; case PERMISSION_REQUESTS_ALLOWED_OFF: userData.setAllowRequestShowHandCards(false); @@ -2965,6 +2984,7 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public void becomesActivePlayer() { this.passedAllTurns = false; + this.passedUntilEndStepBeforeMyTurn = false; this.turns++; } @@ -3462,6 +3482,11 @@ public abstract class PlayerImpl implements Player, Serializable { return passedUntilStackResolved; } + @Override + public boolean getPassedUntilEndStepBeforeMyTurn() { + return passedUntilEndStepBeforeMyTurn; + } + @Override public AbilityType getJustActivatedType() { return justActivatedType;