mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Add support for F6
Skips everything until next turn, except for declare attackers and blockers. F11 and F9 are a better design, but F6 is provided for compatibility with established conventions. There is currently no GUI button for it.
This commit is contained in:
parent
748fcd9a16
commit
62d5d45a45
7 changed files with 75 additions and 8 deletions
|
@ -43,6 +43,7 @@ import java.awt.event.ComponentAdapter;
|
|||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
@ -61,6 +62,7 @@ import javax.imageio.ImageIO;
|
|||
import javax.swing.AbstractButton;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.InputMap;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JComponent;
|
||||
|
@ -75,6 +77,7 @@ import javax.swing.JPanel;
|
|||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.JToolBar.Separator;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
@ -242,6 +245,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
try {
|
||||
UIManager.put("desktop", new Color(0, 0, 0, 0));
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
// stop JSplitPane from eating F6 and F8 or any other function keys
|
||||
{
|
||||
Object value = UIManager.get("SplitPane.ancestorInputMap");
|
||||
|
||||
if(value instanceof InputMap) {
|
||||
InputMap map = (InputMap)value;
|
||||
for(int vk = KeyEvent.VK_F2; vk <= KeyEvent.VK_F12; ++vk) {
|
||||
map.remove(KeyStroke.getKeyStroke(vk, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUISizeHelper.calculateGUISizes();
|
||||
// UIManager.put("Table.rowHeight", GUISizeHelper.tableRowHeight);
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -1431,6 +1431,15 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
ks = KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0);
|
||||
this.getInputMap(c).put(ks, "F6_PRESS");
|
||||
this.getActionMap().put("F6_PRESS", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
btnEndTurnSkipStackActionPerformed(actionEvent);
|
||||
}
|
||||
});
|
||||
|
||||
btnSkipToNextMain.setContentAreaFilled(false);
|
||||
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||
btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipMainButtonImage()));
|
||||
|
@ -2023,6 +2032,12 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
updateSkipButtons(false, true, false, false, false, false);
|
||||
}
|
||||
|
||||
private void btnEndTurnSkipStackActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
|
||||
AudioManager.playOnSkipButton();
|
||||
updateSkipButtons(true, false, false, false, true, false);
|
||||
}
|
||||
|
||||
private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||
AudioManager.playOnSkipButton();
|
||||
|
|
|
@ -178,6 +178,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||
break;
|
||||
}
|
||||
case "F6": {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
|
||||
break;
|
||||
}
|
||||
case "F7": {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||
break;
|
||||
|
@ -211,6 +215,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
popupMenu.add(skipMenu);
|
||||
|
||||
String tooltipText = "<html>This skip actions stops if something goes to <br><b>stack</b> and if <b>attackers</b> or <b>blocker</b> have to be <b>declared</b>.";
|
||||
String everythingTooltipText = "<html>This skip actions stops if <b>attackers</b> or <b>blocker</b> have to be <b>declared</b>, but not if something goes to the <b>stack</b>.";
|
||||
menuItem = new JMenuItem("<html><b>F4</b> - Phases until next turn");
|
||||
menuItem.setActionCommand("F4");
|
||||
menuItem.setToolTipText(tooltipText);
|
||||
|
@ -225,6 +230,13 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
skipMenu.add(menuItem);
|
||||
menuItem.addActionListener(skipListener);
|
||||
|
||||
menuItem = new JMenuItem("<html><b>F6</b> - Everything until the next turn");
|
||||
menuItem.setActionCommand("F6");
|
||||
menuItem.setToolTipText(everythingTooltipText);
|
||||
menuItem.setMnemonic(KeyEvent.VK_U);
|
||||
skipMenu.add(menuItem);
|
||||
menuItem.addActionListener(skipListener);
|
||||
|
||||
menuItem = new JMenuItem("<html><b>F7</b> - Phases until begin of next main phase");
|
||||
menuItem.setToolTipText(tooltipText);
|
||||
menuItem.setActionCommand("F7");
|
||||
|
@ -234,14 +246,14 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
|
||||
menuItem = new JMenuItem("<html><b>F9</b> - Everything until your own next turn");
|
||||
menuItem.setActionCommand("F9");
|
||||
menuItem.setToolTipText(tooltipText);
|
||||
menuItem.setToolTipText(everythingTooltipText);
|
||||
menuItem.setMnemonic(KeyEvent.VK_V);
|
||||
skipMenu.add(menuItem);
|
||||
menuItem.addActionListener(skipListener);
|
||||
|
||||
menuItem = new JMenuItem("<html><b>F11</b> - Everything until end step prior to your own next turn");
|
||||
menuItem.setActionCommand("F11");
|
||||
menuItem.setToolTipText(tooltipText);
|
||||
menuItem.setToolTipText(everythingTooltipText);
|
||||
menuItem.setMnemonic(KeyEvent.VK_P);
|
||||
skipMenu.add(menuItem);
|
||||
menuItem.addActionListener(skipListener);
|
||||
|
|
|
@ -391,6 +391,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
.append("<br/><b>F2</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button")
|
||||
.append("<br/><b>F4</b> - Skip current turn but stop on declare attackers/blockers and something on the stack")
|
||||
.append("<br/><b>F5</b> - Skip to next end step but stop on declare attackers/blockers and something on the stack")
|
||||
.append("<br/><b>F6</b> - Skip current turn but stop on declare attackers/blockers")
|
||||
.append("<br/><b>F7</b> - Skip to next main phase but stop on declare attackers/blockers and something on the stack")
|
||||
.append("<br/><b>F9</b> - Skip everything until your next turn")
|
||||
.append("<br/><b>F11</b> - Skip everything until the end step just prior to your turn")
|
||||
|
|
|
@ -577,7 +577,8 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (passedAllTurns) {
|
||||
|
||||
if (passedAllTurns || passedTurnSkipStack) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -600,7 +601,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (game.getStack().isEmpty()) {
|
||||
passedUntilStackResolved = false;
|
||||
boolean dontCheckPassStep = false;
|
||||
if (passedTurn) {
|
||||
if (passedTurn || passedTurnSkipStack) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -887,7 +888,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
filter.add(new ControllerIdPredicate(attackingPlayerId));
|
||||
while (!abort) {
|
||||
if (passedAllTurns || passedUntilEndStepBeforeMyTurn
|
||||
|| (!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedUntilEndOfTurn || passedUntilNextMain))) {
|
||||
|| (!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedTurnSkipStack || passedUntilEndOfTurn || passedUntilNextMain))) {
|
||||
return;
|
||||
}
|
||||
Map<String, Serializable> options = new HashMap<>();
|
||||
|
|
|
@ -38,6 +38,7 @@ public enum PlayerAction {
|
|||
PASS_PRIORITY_UNTIL_TURN_END_STEP,
|
||||
PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE,
|
||||
PASS_PRIORITY_UNTIL_NEXT_TURN,
|
||||
PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK,
|
||||
PASS_PRIORITY_UNTIL_STACK_RESOLVED,
|
||||
PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN,
|
||||
PASS_PRIORITY_CANCEL_ALL_ACTIONS,
|
||||
|
|
|
@ -169,11 +169,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// priority control
|
||||
protected boolean passed; // player passed priority
|
||||
protected boolean passedTurn; // F4
|
||||
protected boolean passedTurnSkipStack; // F6
|
||||
protected boolean passedUntilEndOfTurn; // F5
|
||||
protected boolean passedUntilNextMain; // F6
|
||||
protected boolean passedUntilStackResolved; // F8
|
||||
protected boolean passedUntilNextMain; // F7
|
||||
protected boolean passedUntilStackResolved; // F10
|
||||
protected boolean passedUntilEndStepBeforeMyTurn; // F11
|
||||
protected Date dateLastAddedToStack; // F8
|
||||
protected Date dateLastAddedToStack; // F10
|
||||
protected boolean skippedAtLeastOnce; // used to track if passed started in specific phase
|
||||
/**
|
||||
* This indicates that player passed all turns until his own turn starts
|
||||
|
@ -319,6 +320,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.passed = player.passed;
|
||||
|
||||
this.passedTurn = player.passedTurn;
|
||||
this.passedTurnSkipStack = player.passedTurnSkipStack;
|
||||
this.passedUntilEndOfTurn = player.passedUntilEndOfTurn;
|
||||
this.passedUntilNextMain = player.passedUntilNextMain;
|
||||
this.skippedAtLeastOnce = player.skippedAtLeastOnce;
|
||||
|
@ -447,6 +449,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.playersUnderYourControl.clear();
|
||||
this.passed = false;
|
||||
this.passedTurn = false;
|
||||
this.passedTurnSkipStack = false;
|
||||
this.passedUntilEndOfTurn = false;
|
||||
this.passedUntilNextMain = false;
|
||||
this.skippedAtLeastOnce = false;
|
||||
|
@ -611,6 +614,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
@Override
|
||||
public void endOfTurn(Game game) {
|
||||
this.passedTurn = false;
|
||||
this.passedTurnSkipStack = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1957,6 +1961,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
public void resetPlayerPassedActions() {
|
||||
this.passed = false;
|
||||
this.passedTurn = false;
|
||||
this.passedTurnSkipStack = false;
|
||||
this.passedUntilEndOfTurn = false;
|
||||
this.passedUntilNextMain = false;
|
||||
this.passedUntilStackResolved = false;
|
||||
|
@ -2005,6 +2010,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
passedUntilNextMain = false;
|
||||
passedUntilEndOfTurn = false;
|
||||
passedTurn = false;
|
||||
passedTurnSkipStack = false;
|
||||
passedAllTurns = true;
|
||||
passedUntilStackResolved = false;
|
||||
passedUntilEndStepBeforeMyTurn = false;
|
||||
|
@ -2013,6 +2019,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
case PASS_PRIORITY_UNTIL_TURN_END_STEP: // F5
|
||||
passedUntilNextMain = false;
|
||||
passedTurn = false;
|
||||
passedTurnSkipStack = false;
|
||||
passedAllTurns = false;
|
||||
passedUntilEndOfTurn = true;
|
||||
passedUntilStackResolved = false;
|
||||
|
@ -2027,11 +2034,23 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
passedUntilStackResolved = false;
|
||||
passedUntilEndStepBeforeMyTurn = false;
|
||||
passedTurn = true;
|
||||
passedTurnSkipStack = false;
|
||||
this.skip();
|
||||
break;
|
||||
case PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK: // F6
|
||||
passedUntilNextMain = false;
|
||||
passedAllTurns = false;
|
||||
passedUntilEndOfTurn = false;
|
||||
passedUntilStackResolved = false;
|
||||
passedUntilEndStepBeforeMyTurn = false;
|
||||
passedTurn = false;
|
||||
passedTurnSkipStack = true;
|
||||
this.skip();
|
||||
break;
|
||||
case PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE: //F7
|
||||
passedAllTurns = false;
|
||||
passedTurn = false;
|
||||
passedTurnSkipStack = false;
|
||||
passedUntilEndOfTurn = false;
|
||||
passedUntilNextMain = true;
|
||||
passedUntilStackResolved = false;
|
||||
|
@ -2042,6 +2061,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
case PASS_PRIORITY_UNTIL_STACK_RESOLVED: //F8
|
||||
passedAllTurns = false;
|
||||
passedTurn = false;
|
||||
passedTurnSkipStack = false;
|
||||
passedUntilEndOfTurn = false;
|
||||
passedUntilNextMain = false;
|
||||
passedUntilStackResolved = true;
|
||||
|
@ -2052,6 +2072,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
case PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN: //F11
|
||||
passedAllTurns = false;
|
||||
passedTurn = false;
|
||||
passedTurnSkipStack = false;
|
||||
passedUntilEndOfTurn = false;
|
||||
passedUntilNextMain = false;
|
||||
passedUntilStackResolved = false;
|
||||
|
@ -2061,6 +2082,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
case PASS_PRIORITY_CANCEL_ALL_ACTIONS:
|
||||
passedAllTurns = false;
|
||||
passedTurn = false;
|
||||
passedTurnSkipStack = false;
|
||||
passedUntilEndOfTurn = false;
|
||||
passedUntilNextMain = false;
|
||||
passedUntilStackResolved = false;
|
||||
|
|
Loading…
Reference in a new issue