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 e0a4826f2c..e69f613cb9 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -367,6 +367,7 @@ public final class GamePanel extends javax.swing.JPanel { this.btnSkipToNextTurn.setVisible(true); this.btnSkipToEndTurn.setVisible(true); this.btnSkipToNextMain.setVisible(true); + this.btnSkipStack.setVisible(true); this.btnSkipToYourTurn.setVisible(true); this.pnlReplay.setVisible(false); @@ -395,6 +396,7 @@ public final class GamePanel extends javax.swing.JPanel { this.btnSkipToNextTurn.setVisible(false); this.btnSkipToEndTurn.setVisible(false); this.btnSkipToNextMain.setVisible(false); + this.btnSkipStack.setVisible(false); this.btnSkipToYourTurn.setVisible(false); @@ -605,7 +607,7 @@ 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()); + updateSkipButtons(player.isPassedTurn(), player.isPassedUntilEndOfTurn(), player.isPassedUntilNextMain(), player.isPassedAllTurns(), player.isPassedUntilStackResolved()); } } else { logger.warn("Couldn't find player."); @@ -664,7 +666,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) { + private void updateSkipButtons(boolean turn, boolean endOfTurn, boolean nextMain, boolean allTurns, boolean stack) { if (turn) { //F4 btnSkipToNextTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE)); } else { @@ -680,6 +682,11 @@ public final class GamePanel extends javax.swing.JPanel { } else { btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE,BORDER_SIZE)); } + if (stack) { // F8 + btnSkipStack.setBorder(new LineBorder(Color.red, BORDER_SIZE)); + } else { + btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE,BORDER_SIZE)); + } if (allTurns) { // F9 btnSkipToYourTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE)); } else { @@ -937,6 +944,7 @@ public final class GamePanel extends javax.swing.JPanel { btnSkipToNextTurn = new javax.swing.JButton(); // F4 btnSkipToEndTurn = new javax.swing.JButton(); // F5 btnSkipToNextMain = new javax.swing.JButton(); // F7 + btnSkipStack = new javax.swing.JButton(); // F8 btnSkipToYourTurn = new javax.swing.JButton(); // F9 btnConcede = new javax.swing.JButton(); @@ -1139,7 +1147,30 @@ public final class GamePanel extends javax.swing.JPanel { btnPassPriorityUntilNextYourTurnActionPerformed(actionEvent); } }); - + + btnSkipStack.setContentAreaFilled(false); + btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE)); + btnSkipStack.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipStackButtonImage())); + btnSkipStack.setToolTipText("Skip until stack is resolved (F10)."); + btnSkipStack.setFocusable(false); + btnSkipStack.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent evt) { + if (evt.getButton() == MouseEvent.BUTTON1) { + btnPassPriorityUntilStackResolvedActionPerformed(null); + } + } + }); + + ks = KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0); + this.getInputMap(c).put(ks, "F10_PRESS"); + this.getActionMap().put("F10_PRESS", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + btnPassPriorityUntilStackResolvedActionPerformed(actionEvent); + } + }); + btnConcede.setContentAreaFilled(false); btnConcede.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE)); btnConcede.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getConcedeButtonImage())); @@ -1336,6 +1367,7 @@ public final class GamePanel extends javax.swing.JPanel { .addComponent(btnSkipToEndTurn) .addComponent(btnSkipToNextMain) .addComponent(btnSkipToYourTurn) + .addComponent(btnSkipStack) ) .addGroup(gl_pnlShortCuts.createSequentialGroup() .addComponent(btnSwitchHands) @@ -1367,6 +1399,7 @@ public final class GamePanel extends javax.swing.JPanel { .addComponent(btnSkipToEndTurn) .addComponent(btnSkipToNextMain) .addComponent(btnSkipToYourTurn) + .addComponent(btnSkipStack) ) .addGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(btnSwitchHands) @@ -1523,6 +1556,9 @@ public final class GamePanel extends javax.swing.JPanel { for (MouseListener ml :this.btnSkipToYourTurn.getMouseListeners()) { this.btnSkipToYourTurn.removeMouseListener(ml); } + for (MouseListener ml :this.btnSkipStack.getMouseListeners()) { + this.btnSkipStack.removeMouseListener(ml); + } for (MouseListener ml :this.btnSkipToEndTurn.getMouseListeners()) { this.btnSkipToEndTurn.removeMouseListener(ml); } @@ -1591,31 +1627,37 @@ 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); AudioManager.playOnSkipButton(); - updateSkipButtons(true, false, false, false); + updateSkipButtons(true, false, false, false, false); } private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId); AudioManager.playOnSkipButton(); - updateSkipButtons(false, true, false, false); + updateSkipButtons(false, true, false, false, false); } private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId); AudioManager.playOnSkipButton(); - updateSkipButtons(false, false, true, false); + updateSkipButtons(false, false, true, false, false); } private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId); AudioManager.playOnSkipButton(); - updateSkipButtons(false, false, false, true); + updateSkipButtons(false, false, false, true, false); + } + + private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) { + session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId); + AudioManager.playOnSkipButton(); + updateSkipButtons(false, false, false, false, true); } private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId); AudioManager.playOnSkipButtonCancel(); - updateSkipButtons(false, false, false, false); + updateSkipButtons(false, false, false, false, false); } private void mouseClickPhaseBar(MouseEvent evt) { @@ -1728,6 +1770,7 @@ public final class GamePanel extends javax.swing.JPanel { private javax.swing.JButton btnSkipToNextTurn; // F4 private javax.swing.JButton btnSkipToEndTurn; // F5 private javax.swing.JButton btnSkipToNextMain; // F7 + private javax.swing.JButton btnSkipStack; // F8 private javax.swing.JButton btnSkipToYourTurn; // F9 private javax.swing.JButton btnConcede; 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 a7254e7771..52138aa996 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 @@ -37,6 +37,7 @@ public interface ImageManager { Image getSkipNextTurnButtonImage(); Image getSkipEndTurnButtonImage(); Image getSkipMainButtonImage(); + Image getSkipStackButtonImage(); 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 3d30f575da..4ec5ac433d 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 @@ -293,6 +293,14 @@ public class ImageManagerImpl implements ImageManager { return imageSkipToMainButton; } + @Override + public Image getSkipStackButtonImage() { + if (imageSkipStackButton == null) { + imageSkipStackButton = getBufferedImageFromResource("/buttons/skip_stack.png"); + } + return imageSkipStackButton; + } + @Override public Image getSkipYourNextTurnButtonImage() { if (imageSkipYourNextTurnButton == null) { @@ -388,6 +396,7 @@ public class ImageManagerImpl implements ImageManager { private static BufferedImage imageSkipNextTurnButton; private static BufferedImage imageSkipToEndTurnButton; private static BufferedImage imageSkipToMainButton; + private static BufferedImage imageSkipStackButton; private static BufferedImage imageSkipYourNextTurnButton; private static Map<String, Image> phasesImages; diff --git a/Mage.Client/src/main/resources/buttons/skip_stack.png b/Mage.Client/src/main/resources/buttons/skip_stack.png new file mode 100644 index 0000000000..40597cfb64 Binary files /dev/null and b/Mage.Client/src/main/resources/buttons/skip_stack.png differ diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index ea56766257..e98091a010 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -71,6 +71,7 @@ public class PlayerView implements Serializable { private final boolean passedTurn; // F4 private final boolean passedUntilEndOfTurn; // F5 private final boolean passedUntilNextMain; // F6 + private final boolean passedUntilStackResolved; // F8 private final boolean passedAllTurns; // F9 public PlayerView(Player player, GameState state, Game game, UUID createdForPlayerId) { @@ -140,6 +141,7 @@ public class PlayerView implements Serializable { this.passedUntilEndOfTurn = player.getPassedUntilEndOfTurn(); this.passedUntilNextMain = player.getPassedUntilNextMain(); this.passedAllTurns = player.getPassedAllTurns(); + this.passedUntilStackResolved = player.getPassedUntilStackResolved(); } private boolean showInBattlefield(Permanent permanent, GameState state) { @@ -255,4 +257,7 @@ public class PlayerView implements Serializable { return passedAllTurns; } + public boolean isPassedUntilStackResolved() { + return passedUntilStackResolved; + } } 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 b7ed748b06..6cbdf379e4 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 @@ -466,6 +466,7 @@ public class HumanPlayer extends PlayerImpl { return false; } if (game.getStack().isEmpty()) { + passedUntilStackResolved = false; boolean dontCheckPassStep = false; if (passedTurn) { pass(game); @@ -509,6 +510,14 @@ public class HumanPlayer extends PlayerImpl { pass(game); return false; } + } else if (passedUntilStackResolved) { + if (dateLastAddedToStack == game.getStack().getDateLastAdded()) { + dateLastAddedToStack = game.getStack().getDateLastAdded(); + pass(game); + return false; + } else { + passedUntilStackResolved = false; + } } updateGameStatePriority("priority", game); game.firePriorityEvent(playerId);