mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Added new option for mana payment handling of mana already in the mana pool. Reworked the battlefield context menu a bit.
This commit is contained in:
parent
8066fe911c
commit
907ec7abb0
11 changed files with 263 additions and 139 deletions
|
@ -134,6 +134,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
// mana auto payment
|
// mana auto payment
|
||||||
public static final String KEY_GAME_MANA_AUTOPAYMENT = "gameManaAutopayment";
|
public static final String KEY_GAME_MANA_AUTOPAYMENT = "gameManaAutopayment";
|
||||||
|
public static final String KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE = "gameManaAutopaymentOnlyOne";
|
||||||
|
|
||||||
// Size of frame to check if divider locations should be used
|
// Size of frame to check if divider locations should be used
|
||||||
public static final String KEY_MAGE_PANEL_LAST_SIZE = "gamepanelLastSize";
|
public static final String KEY_MAGE_PANEL_LAST_SIZE = "gamepanelLastSize";
|
||||||
|
|
|
@ -91,6 +91,7 @@ import mage.client.dialog.PickNumberDialog;
|
||||||
import mage.client.dialog.PickPileDialog;
|
import mage.client.dialog.PickPileDialog;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT;
|
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT;
|
||||||
|
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE;
|
||||||
import mage.client.dialog.ShowCardsDialog;
|
import mage.client.dialog.ShowCardsDialog;
|
||||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||||
import mage.client.plugins.adapters.MageActionCallback;
|
import mage.client.plugins.adapters.MageActionCallback;
|
||||||
|
@ -459,7 +460,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
public synchronized void init(GameView game) {
|
public synchronized void init(GameView game) {
|
||||||
addPlayers(game);
|
addPlayers(game);
|
||||||
// default menu states
|
// default menu states
|
||||||
setMenuStates(PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"));
|
setMenuStates(
|
||||||
|
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||||
|
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"));
|
||||||
|
|
||||||
updateGame(game);
|
updateGame(game);
|
||||||
}
|
}
|
||||||
|
@ -734,10 +737,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
/**
|
/**
|
||||||
* Set the same state for menu selections to all player areas.
|
* Set the same state for menu selections to all player areas.
|
||||||
* @param manaPoolAutomatic
|
* @param manaPoolAutomatic
|
||||||
|
* @param manaPoolAutomaticRestricted
|
||||||
*/
|
*/
|
||||||
public void setMenuStates(boolean manaPoolAutomatic) {
|
public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) {
|
||||||
for(PlayAreaPanel playAreaPanel: players.values()) {
|
for(PlayAreaPanel playAreaPanel: players.values()) {
|
||||||
playAreaPanel.setMenuStates(manaPoolAutomatic);
|
playAreaPanel.setMenuStates(manaPoolAutomatic, manaPoolAutomaticRestricted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ import mage.client.cards.BigCard;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS;
|
import static mage.client.dialog.PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT;
|
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT;
|
||||||
|
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
import mage.view.PlayerView;
|
import mage.view.PlayerView;
|
||||||
|
|
||||||
|
@ -72,7 +73,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
private final GamePanel gamePanel;
|
private final GamePanel gamePanel;
|
||||||
private final PlayAreaPanelOptions options;
|
private final PlayAreaPanelOptions options;
|
||||||
|
|
||||||
private JCheckBoxMenuItem manaPoolMenuItem;
|
private JCheckBoxMenuItem manaPoolMenuItem1;
|
||||||
|
private JCheckBoxMenuItem manaPoolMenuItem2;
|
||||||
private JCheckBoxMenuItem allowViewHandCardsMenuItem;
|
private JCheckBoxMenuItem allowViewHandCardsMenuItem;
|
||||||
|
|
||||||
public static final int PANEL_HEIGHT = 242;
|
public static final int PANEL_HEIGHT = 242;
|
||||||
|
@ -139,99 +141,135 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
JMenuItem menuItem;
|
JMenuItem menuItem;
|
||||||
|
|
||||||
menuItem = new JMenuItem("F2 - Confirm");
|
ActionListener skipListener = new ActionListener() {
|
||||||
popupMenu.add(menuItem);
|
|
||||||
|
|
||||||
// Confirm (F2)
|
|
||||||
menuItem.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (gamePanel.getFeedbackPanel() != null) {
|
switch (e.getActionCommand()) {
|
||||||
gamePanel.getFeedbackPanel().pressOKYesOrDone();
|
case "F2": {
|
||||||
|
if (gamePanel.getFeedbackPanel() != null) {
|
||||||
|
gamePanel.getFeedbackPanel().pressOKYesOrDone();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "F3": {
|
||||||
|
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "F4": {
|
||||||
|
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "F5": {
|
||||||
|
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "F7": {
|
||||||
|
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "F9": {
|
||||||
|
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("<html><b>F2</b> - Confirm current request");
|
||||||
menuItem = new JMenuItem("F3 - Cancel previous F4/F9 skip action");
|
menuItem.setActionCommand("F2");
|
||||||
|
menuItem.setMnemonic(KeyEvent.VK_O);
|
||||||
popupMenu.add(menuItem);
|
popupMenu.add(menuItem);
|
||||||
|
menuItem.addActionListener(skipListener);
|
||||||
|
|
||||||
// Cancel (F3)
|
menuItem = new JMenuItem("<html><b>F3</b> - Cancel active skip action");
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.setActionCommand("F3");
|
||||||
@Override
|
menuItem.setMnemonic(KeyEvent.VK_N);
|
||||||
public void actionPerformed(ActionEvent e) {
|
popupMenu.add(menuItem);
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
menuItem.addActionListener(skipListener);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
JMenu skipMenu = new JMenu("Skip");
|
||||||
|
skipMenu.setMnemonic(KeyEvent.VK_S);
|
||||||
|
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>.";
|
||||||
|
menuItem = new JMenuItem("<html><b>F4</b> - Phases until next turn");
|
||||||
|
menuItem.setActionCommand("F4");
|
||||||
|
menuItem.setToolTipText(tooltipText);
|
||||||
|
menuItem.setMnemonic(KeyEvent.VK_T);
|
||||||
|
skipMenu.add(menuItem);
|
||||||
|
menuItem.addActionListener(skipListener);
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("<html><b>F5</b> - Phases until next end step");
|
||||||
|
menuItem.setActionCommand("F5");
|
||||||
|
menuItem.setToolTipText(tooltipText);
|
||||||
|
menuItem.setMnemonic(KeyEvent.VK_E);
|
||||||
|
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");
|
||||||
|
menuItem.setMnemonic(KeyEvent.VK_M);
|
||||||
|
skipMenu.add(menuItem);
|
||||||
|
menuItem.addActionListener(skipListener);
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("<html><b>F9</b> - Everything until your own next turn");
|
||||||
|
menuItem.setActionCommand("F9");
|
||||||
|
menuItem.setToolTipText(tooltipText);
|
||||||
|
menuItem.setMnemonic(KeyEvent.VK_N);
|
||||||
|
skipMenu.add(menuItem);
|
||||||
|
menuItem.addActionListener(skipListener);
|
||||||
|
|
||||||
popupMenu.addSeparator();
|
popupMenu.addSeparator();
|
||||||
|
|
||||||
menuItem = new JMenuItem("F4 - Skip phases until next turn (stop on stack/attack/block)");
|
JMenu manaPoolMenu = new JMenu("Mana payment");
|
||||||
popupMenu.add(menuItem);
|
manaPoolMenu.setMnemonic(KeyEvent.VK_M);
|
||||||
|
popupMenu.add(manaPoolMenu);
|
||||||
// Skip to next turn (F4)
|
|
||||||
menuItem.addActionListener(new ActionListener() {
|
manaPoolMenuItem1 = new JCheckBoxMenuItem("Automatically", true);
|
||||||
@Override
|
manaPoolMenuItem1.setMnemonic(KeyEvent.VK_A);
|
||||||
public void actionPerformed(ActionEvent e) {
|
manaPoolMenuItem1.setToolTipText("<html>If not active, produced mana goes only to the mana pool<br>"
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
+ "and you have to click the type of mana you want to use <br>"
|
||||||
}
|
+ "in the player mana pool panel for payment.");
|
||||||
});
|
manaPoolMenu.add(manaPoolMenuItem1);
|
||||||
|
|
||||||
menuItem = new JMenuItem("F5 - Skip phases until next end step (stop on stack/attack/block)");
|
|
||||||
popupMenu.add(menuItem);
|
|
||||||
|
|
||||||
// Skip to next end step of turn (F5)
|
|
||||||
menuItem.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
menuItem = new JMenuItem("F7 - Skip phases until begin of next main phase (stop on stack/attack/block)");
|
|
||||||
popupMenu.add(menuItem);
|
|
||||||
|
|
||||||
// Skip to next main phase (F7)
|
|
||||||
menuItem.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menuItem = new JMenuItem("F9 - Skip everything until own next turn (stop on attack/block)");
|
|
||||||
popupMenu.add(menuItem);
|
|
||||||
|
|
||||||
// Skip to next own turn (F9)
|
|
||||||
menuItem.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
popupMenu.addSeparator();
|
|
||||||
|
|
||||||
manaPoolMenuItem = new JCheckBoxMenuItem("Use mana from pool automatically", true);
|
|
||||||
manaPoolMenuItem.setMnemonic(KeyEvent.VK_M);
|
|
||||||
manaPoolMenuItem.setToolTipText("If not active, you have to click the type of mana you want to pay in the player panel.");
|
|
||||||
popupMenu.add(manaPoolMenuItem);
|
|
||||||
|
|
||||||
// Auto pay mana from mana pool
|
// Auto pay mana from mana pool
|
||||||
manaPoolMenuItem.addActionListener(new ActionListener() {
|
manaPoolMenuItem1.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
|
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true": "false");
|
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true": "false");
|
||||||
gamePanel.setMenuStates(manaPoolAutomatic);
|
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState());
|
||||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
manaPoolMenuItem2 = new JCheckBoxMenuItem("No automatic usage for mana already in the pool", true);
|
||||||
|
manaPoolMenuItem2.setMnemonic(KeyEvent.VK_N);
|
||||||
|
manaPoolMenuItem2.setToolTipText("<html>Mana that is already in the mana pool as you start casting a spell or activating an ability<br>"
|
||||||
|
+ " needs to be payed manually. So you use the mana in the pool only by clicking on the related<br>"
|
||||||
|
+ " mana symbols of mana pool area.");
|
||||||
|
manaPoolMenu.add(manaPoolMenuItem2);
|
||||||
|
|
||||||
|
// Auto pay mana from mana pool
|
||||||
|
manaPoolMenuItem2.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||||
|
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true": "false");
|
||||||
|
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted);
|
||||||
|
gamePanel.getSession().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON: PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JMenu automaticConfirmsMenu = new JMenu("Automatic confirms");
|
||||||
|
automaticConfirmsMenu.setMnemonic(KeyEvent.VK_U);
|
||||||
|
popupMenu.add(automaticConfirmsMenu);
|
||||||
|
|
||||||
menuItem = new JMenuItem("Replacement effects - reset auto select");
|
menuItem = new JMenuItem("Replacement effects - reset auto select");
|
||||||
menuItem.setMnemonic(KeyEvent.VK_R);
|
menuItem.setMnemonic(KeyEvent.VK_R);
|
||||||
menuItem.setToolTipText("Reset all effects that were added to the list of auto select replacement effects this game.");
|
menuItem.setToolTipText("Reset all effects that were added to the list of auto select replacement effects this game.");
|
||||||
popupMenu.add(menuItem);
|
automaticConfirmsMenu.add(menuItem);
|
||||||
// Reset the replacement effcts that were auto selected for the game
|
// Reset the replacement effcts that were auto selected for the game
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -240,11 +278,14 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
popupMenu.addSeparator();
|
JMenu handCardsMenu = new JMenu("Cards on hand");
|
||||||
|
handCardsMenu.setMnemonic(KeyEvent.VK_H);
|
||||||
|
popupMenu.add(handCardsMenu);
|
||||||
|
|
||||||
if (!options.playerItself) {
|
if (!options.playerItself) {
|
||||||
menuItem = new JMenuItem("Request permission to see hand cards");
|
menuItem = new JMenuItem("Request permission to see the hand cards");
|
||||||
popupMenu.add(menuItem);
|
menuItem.setMnemonic(KeyEvent.VK_P);
|
||||||
|
handCardsMenu.add(menuItem);
|
||||||
|
|
||||||
// Request to see hand cards
|
// Request to see hand cards
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
@ -254,10 +295,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
allowViewHandCardsMenuItem = new JCheckBoxMenuItem("Allow requests to show your hand cards", allowRequestToShowHandCards);
|
allowViewHandCardsMenuItem = new JCheckBoxMenuItem("Allow requests to show from other users", allowRequestToShowHandCards);
|
||||||
allowViewHandCardsMenuItem.setMnemonic(KeyEvent.VK_A);
|
allowViewHandCardsMenuItem.setMnemonic(KeyEvent.VK_A);
|
||||||
allowViewHandCardsMenuItem.setToolTipText("If activated watchers or other players can request to see your hand cards. If you grant this to a user, it's valid for the complete match.");
|
allowViewHandCardsMenuItem.setToolTipText("If activated watchers or other players can request to see your hand cards. If you grant this to a user, it's valid for the complete match.");
|
||||||
popupMenu.add(allowViewHandCardsMenuItem);
|
handCardsMenu.add(allowViewHandCardsMenuItem);
|
||||||
|
|
||||||
// Requests allowed
|
// Requests allowed
|
||||||
allowViewHandCardsMenuItem.addActionListener(new ActionListener() {
|
allowViewHandCardsMenuItem.addActionListener(new ActionListener() {
|
||||||
|
@ -270,9 +311,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
menuItem = new JMenuItem("Revoke all permission(s) to see your hand cards");
|
menuItem = new JMenuItem("Revoke all permission(s) to see your hand cards");
|
||||||
menuItem.setMnemonic(KeyEvent.VK_P);
|
menuItem.setMnemonic(KeyEvent.VK_R);
|
||||||
menuItem.setToolTipText("Revoke already granted permission for all spectators to see your hand cards.");
|
menuItem.setToolTipText("Revoke already granted permission for all spectators to see your hand cards.");
|
||||||
popupMenu.add(menuItem);
|
handCardsMenu.add(menuItem);
|
||||||
|
|
||||||
// revoke permissions to see hand cards
|
// revoke permissions to see hand cards
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
@ -282,8 +323,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
popupMenu.addSeparator();
|
|
||||||
|
|
||||||
if (options.rollbackTurnsAllowed) {
|
if (options.rollbackTurnsAllowed) {
|
||||||
ActionListener rollBackActionListener = new ActionListener() {
|
ActionListener rollBackActionListener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -298,78 +338,73 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
rollbackMainItem.setToolTipText("The game will be rolled back to the start of the requested turn if all players agree.");
|
rollbackMainItem.setToolTipText("The game will be rolled back to the start of the requested turn if all players agree.");
|
||||||
popupMenu.add(rollbackMainItem);
|
popupMenu.add(rollbackMainItem);
|
||||||
|
|
||||||
menuItem = new JMenuItem("to the start of the current turn");
|
menuItem = new JMenuItem("To the start of the current turn");
|
||||||
menuItem.setMnemonic(KeyEvent.VK_C);
|
menuItem.setMnemonic(KeyEvent.VK_C);
|
||||||
menuItem.setActionCommand("0");
|
menuItem.setActionCommand("0");
|
||||||
menuItem.addActionListener(rollBackActionListener);
|
menuItem.addActionListener(rollBackActionListener);
|
||||||
rollbackMainItem.add(menuItem);
|
rollbackMainItem.add(menuItem);
|
||||||
|
|
||||||
menuItem = new JMenuItem("to the start of the previous turn");
|
menuItem = new JMenuItem("To the start of the previous turn");
|
||||||
menuItem.setMnemonic(KeyEvent.VK_P);
|
menuItem.setMnemonic(KeyEvent.VK_P);
|
||||||
menuItem.setActionCommand("1");
|
menuItem.setActionCommand("1");
|
||||||
menuItem.addActionListener(rollBackActionListener);
|
menuItem.addActionListener(rollBackActionListener);
|
||||||
rollbackMainItem.add(menuItem);
|
rollbackMainItem.add(menuItem);
|
||||||
|
|
||||||
menuItem = new JMenuItem("the current turn and the 2 turns before");
|
menuItem = new JMenuItem("The current turn and the 2 turns before");
|
||||||
menuItem.setMnemonic(KeyEvent.VK_2);
|
menuItem.setMnemonic(KeyEvent.VK_2);
|
||||||
menuItem.setActionCommand("2");
|
menuItem.setActionCommand("2");
|
||||||
menuItem.addActionListener(rollBackActionListener);
|
menuItem.addActionListener(rollBackActionListener);
|
||||||
rollbackMainItem.add(menuItem);
|
rollbackMainItem.add(menuItem);
|
||||||
|
|
||||||
menuItem = new JMenuItem("the current turn and the 3 turns before");
|
menuItem = new JMenuItem("The current turn and the 3 turns before");
|
||||||
menuItem.setMnemonic(KeyEvent.VK_3);
|
menuItem.setMnemonic(KeyEvent.VK_3);
|
||||||
menuItem.setActionCommand("3");
|
menuItem.setActionCommand("3");
|
||||||
menuItem.addActionListener(rollBackActionListener);
|
menuItem.addActionListener(rollBackActionListener);
|
||||||
rollbackMainItem.add(menuItem);
|
rollbackMainItem.add(menuItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
popupMenu.addSeparator();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
menuItem = new JMenuItem("Revoke all permission(s) to see your hand cards");
|
|
||||||
menuItem.setMnemonic(KeyEvent.VK_P);
|
|
||||||
menuItem.setToolTipText("Revoke already granted permission for all spectators to see your hand cards.");
|
|
||||||
popupMenu.add(menuItem);
|
|
||||||
|
|
||||||
// revoke permissions to see hand cards
|
JMenu concedeMenu = new JMenu("Concede");
|
||||||
menuItem.addActionListener(new ActionListener() {
|
concedeMenu.setMnemonic(KeyEvent.VK_C);
|
||||||
|
popupMenu.add(concedeMenu);
|
||||||
|
|
||||||
|
ActionListener concedeListener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
|
switch (e.getActionCommand()) {
|
||||||
}
|
case "Game": {
|
||||||
});
|
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the game?", "Confirm concede game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
|
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
|
||||||
popupMenu.addSeparator();
|
}
|
||||||
|
}
|
||||||
menuItem = new JMenuItem("Concede game");
|
case "Match": {
|
||||||
popupMenu.add(menuItem);
|
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the complete match?", "Confirm concede match", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
|
MageFrame.getSession().quitMatch(gameId);
|
||||||
// Concede
|
}
|
||||||
menuItem.addActionListener(new ActionListener() {
|
}
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the game?", "Confirm concede game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
|
||||||
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
popupMenu.addSeparator();
|
// Concede Game
|
||||||
|
menuItem = new JMenuItem("Game");
|
||||||
menuItem = new JMenuItem("Concede complete match");
|
menuItem.setMnemonic(KeyEvent.VK_G);
|
||||||
popupMenu.add(menuItem);
|
menuItem.setActionCommand("Game");
|
||||||
|
menuItem.setToolTipText("Concedes only the current game and after that the next game of the match is started if there is another game needed.");
|
||||||
// Quit match
|
concedeMenu.add(menuItem);
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(concedeListener);
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
// Concede Match
|
||||||
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the complete match?", "Confirm concede match", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
menuItem = new JMenuItem("Match");
|
||||||
MageFrame.getSession().quitMatch(gameId);
|
menuItem.setMnemonic(KeyEvent.VK_M);
|
||||||
}
|
menuItem.setActionCommand("Match");
|
||||||
}
|
menuItem.setToolTipText("Concedes the complete match. So if you're in a tournament you finish the current tournament round.");
|
||||||
});
|
concedeMenu.add(menuItem);
|
||||||
|
menuItem.addActionListener(concedeListener);
|
||||||
|
|
||||||
|
|
||||||
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent Me) {
|
public void mouseReleased(MouseEvent Me) {
|
||||||
|
@ -531,8 +566,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
this.playingMode = playingMode;
|
this.playingMode = playingMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMenuStates(boolean manaPoolAutomatic) {
|
public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) {
|
||||||
manaPoolMenuItem.setSelected(manaPoolAutomatic);
|
manaPoolMenuItem1.setSelected(manaPoolAutomatic);
|
||||||
|
manaPoolMenuItem2.setSelected(manaPoolAutomaticRestricted);
|
||||||
}
|
}
|
||||||
|
|
||||||
private mage.client.game.BattlefieldPanel battlefieldPanel;
|
private mage.client.game.BattlefieldPanel battlefieldPanel;
|
||||||
|
|
|
@ -78,6 +78,7 @@ public interface GamePlay {
|
||||||
*
|
*
|
||||||
* @param passPriorityAction
|
* @param passPriorityAction
|
||||||
* @param gameId
|
* @param gameId
|
||||||
|
* @param Data
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean sendPlayerAction(PlayerAction passPriorityAction, UUID gameId, Object Data);
|
boolean sendPlayerAction(PlayerAction passPriorityAction, UUID gameId, Object Data);
|
||||||
|
|
|
@ -537,10 +537,16 @@ public class GameController implements GameCallback {
|
||||||
game.concede(getPlayerId(userId));
|
game.concede(getPlayerId(userId));
|
||||||
break;
|
break;
|
||||||
case MANA_AUTO_PAYMENT_OFF:
|
case MANA_AUTO_PAYMENT_OFF:
|
||||||
game.setManaPoolMode(getPlayerId(userId), false);
|
game.setManaPaymentMode(getPlayerId(userId), false);
|
||||||
break;
|
break;
|
||||||
case MANA_AUTO_PAYMENT_ON:
|
case MANA_AUTO_PAYMENT_ON:
|
||||||
game.setManaPoolMode(getPlayerId(userId), true);
|
game.setManaPaymentMode(getPlayerId(userId), true);
|
||||||
|
break;
|
||||||
|
case MANA_AUTO_PAYMENT_RESTRICTED_OFF:
|
||||||
|
game.setManaPaymentModeRestricted(getPlayerId(userId), false);
|
||||||
|
break;
|
||||||
|
case MANA_AUTO_PAYMENT_RESTRICTED_ON:
|
||||||
|
game.setManaPaymentModeRestricted(getPlayerId(userId), true);
|
||||||
break;
|
break;
|
||||||
case ADD_PERMISSION_TO_SEE_HAND_CARDS:
|
case ADD_PERMISSION_TO_SEE_HAND_CARDS:
|
||||||
if (data instanceof UUID) {
|
if (data instanceof UUID) {
|
||||||
|
|
|
@ -44,6 +44,8 @@ public enum PlayerAction {
|
||||||
CONCEDE,
|
CONCEDE,
|
||||||
MANA_AUTO_PAYMENT_ON,
|
MANA_AUTO_PAYMENT_ON,
|
||||||
MANA_AUTO_PAYMENT_OFF,
|
MANA_AUTO_PAYMENT_OFF,
|
||||||
|
MANA_AUTO_PAYMENT_RESTRICTED_ON,
|
||||||
|
MANA_AUTO_PAYMENT_RESTRICTED_OFF,
|
||||||
RESET_AUTO_SELECT_REPLACEMENT_EFFECTS,
|
RESET_AUTO_SELECT_REPLACEMENT_EFFECTS,
|
||||||
REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS,
|
REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS,
|
||||||
REQUEST_PERMISSION_TO_SEE_HAND_CARDS,
|
REQUEST_PERMISSION_TO_SEE_HAND_CARDS,
|
||||||
|
|
|
@ -224,7 +224,8 @@ public interface Game extends MageItem, Serializable {
|
||||||
void timerTimeout(UUID playerId);
|
void timerTimeout(UUID playerId);
|
||||||
void idleTimeout(UUID playerId);
|
void idleTimeout(UUID playerId);
|
||||||
void concede(UUID playerId);
|
void concede(UUID playerId);
|
||||||
void setManaPoolMode(UUID playerId, boolean autoPayment);
|
void setManaPaymentMode(UUID playerId, boolean autoPayment);
|
||||||
|
void setManaPaymentModeRestricted(UUID playerId, boolean autoPaymentRestricted);
|
||||||
void undo(UUID playerId);
|
void undo(UUID playerId);
|
||||||
void emptyManaPools();
|
void emptyManaPools();
|
||||||
void addEffect(ContinuousEffect continuousEffect, Ability source);
|
void addEffect(ContinuousEffect continuousEffect, Ability source);
|
||||||
|
|
|
@ -1124,12 +1124,20 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setManaPoolMode(UUID playerId, boolean autoPayment) {
|
public synchronized void setManaPaymentMode(UUID playerId, boolean autoPayment) {
|
||||||
Player player = state.getPlayer(playerId);
|
Player player = state.getPlayer(playerId);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.getManaPool().setAutoPayment(autoPayment);
|
player.getManaPool().setAutoPayment(autoPayment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void setManaPaymentModeRestricted(UUID playerId, boolean autoPaymentRestricted) {
|
||||||
|
Player player = state.getPlayer(playerId);
|
||||||
|
if (player != null) {
|
||||||
|
player.getManaPool().setAutoPaymentRestricted(autoPaymentRestricted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playPriority(UUID activePlayerId, boolean resuming) {
|
public void playPriority(UUID activePlayerId, boolean resuming) {
|
||||||
|
|
|
@ -61,6 +61,7 @@ public class ManaPool implements Serializable {
|
||||||
private final List<ManaPoolItem> manaItems = new ArrayList<>();
|
private final List<ManaPoolItem> manaItems = new ArrayList<>();
|
||||||
|
|
||||||
private boolean autoPayment; // auto payment from mana pool: true - mode is active
|
private boolean autoPayment; // auto payment from mana pool: true - mode is active
|
||||||
|
private boolean autoPaymentRestricted; // auto payment from mana pool: true - if auto Payment is on, it will only pay if one kind of mana is in the pool
|
||||||
private ManaType unlockedManaType; // type of mana that was selected to pay manually
|
private ManaType unlockedManaType; // type of mana that was selected to pay manually
|
||||||
|
|
||||||
private final Set<ManaType> doNotEmptyManaTypes = new HashSet<>();
|
private final Set<ManaType> doNotEmptyManaTypes = new HashSet<>();
|
||||||
|
@ -68,6 +69,7 @@ public class ManaPool implements Serializable {
|
||||||
public ManaPool(UUID playerId) {
|
public ManaPool(UUID playerId) {
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
autoPayment = true;
|
autoPayment = true;
|
||||||
|
autoPaymentRestricted = true;
|
||||||
unlockedManaType = null;
|
unlockedManaType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +79,7 @@ public class ManaPool implements Serializable {
|
||||||
manaItems.add(item.copy());
|
manaItems.add(item.copy());
|
||||||
}
|
}
|
||||||
this.autoPayment = pool.autoPayment;
|
this.autoPayment = pool.autoPayment;
|
||||||
|
this.autoPaymentRestricted = pool.autoPaymentRestricted;
|
||||||
this.unlockedManaType = pool.unlockedManaType;
|
this.unlockedManaType = pool.unlockedManaType;
|
||||||
this.doNotEmptyManaTypes.addAll(pool.doNotEmptyManaTypes);
|
this.doNotEmptyManaTypes.addAll(pool.doNotEmptyManaTypes);
|
||||||
}
|
}
|
||||||
|
@ -101,11 +104,25 @@ public class ManaPool implements Serializable {
|
||||||
return get(ManaType.BLACK);
|
return get(ManaType.BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param manaType the mana type that should be paid
|
||||||
|
* @param ability
|
||||||
|
* @param filter
|
||||||
|
* @param game
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean pay(ManaType manaType, Ability ability, Filter filter, Game game) {
|
public boolean pay(ManaType manaType, Ability ability, Filter filter, Game game) {
|
||||||
if (!autoPayment && !manaType.equals(unlockedManaType)) {
|
if (!autoPayment && !manaType.equals(unlockedManaType)) {
|
||||||
// if manual payment and the needed mana type was not unlocked, nothing will be paid
|
// if manual payment and the needed mana type was not unlocked, nothing will be paid
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (autoPayment && autoPaymentRestricted && !wasManaAddedBeyondStock() && !manaType.equals(unlockedManaType)) {
|
||||||
|
// if automatic restricted payment and there is laready mana in the pool
|
||||||
|
// and the needed mana type was not unlocked, nothing will be paid
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (getConditional(manaType, ability, filter, game) > 0) {
|
if (getConditional(manaType, ability, filter, game) > 0) {
|
||||||
removeConditional(manaType, ability, game);
|
removeConditional(manaType, ability, game);
|
||||||
lockManaType(); // pay only one mana if mana payment is set to manually
|
lockManaType(); // pay only one mana if mana payment is set to manually
|
||||||
|
@ -118,6 +135,10 @@ public class ManaPool implements Serializable {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!manaType.equals(unlockedManaType) && autoPayment && autoPaymentRestricted && mana.count() == mana.getStock()) {
|
||||||
|
// no mana added beyond the stock so don't auto pay this
|
||||||
|
continue;
|
||||||
|
}
|
||||||
boolean spendAnyMana = spendAnyMana(ability, game);
|
boolean spendAnyMana = spendAnyMana(ability, game);
|
||||||
if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
|
if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
|
||||||
GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag());
|
GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag());
|
||||||
|
@ -128,6 +149,9 @@ public class ManaPool implements Serializable {
|
||||||
} else {
|
} else {
|
||||||
mana.remove(manaType);
|
mana.remove(manaType);
|
||||||
}
|
}
|
||||||
|
if (mana.count() == 0) { // so no items with count 0 stay in list
|
||||||
|
manaItems.remove(mana);
|
||||||
|
}
|
||||||
lockManaType(); // pay only one mana if mana payment is set to manually
|
lockManaType(); // pay only one mana if mana payment is set to manually
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -416,6 +440,14 @@ public class ManaPool implements Serializable {
|
||||||
this.autoPayment = autoPayment;
|
this.autoPayment = autoPayment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAutoPaymentRestricted(boolean autoPaymentRestricted) {
|
||||||
|
this.autoPaymentRestricted = autoPaymentRestricted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAutoPaymentRestricted() {
|
||||||
|
return autoPaymentRestricted;
|
||||||
|
}
|
||||||
|
|
||||||
public ManaType getUnlockedManaType() {
|
public ManaType getUnlockedManaType() {
|
||||||
return unlockedManaType;
|
return unlockedManaType;
|
||||||
}
|
}
|
||||||
|
@ -428,4 +460,18 @@ public class ManaPool implements Serializable {
|
||||||
this.unlockedManaType = null;
|
this.unlockedManaType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStock() {
|
||||||
|
for (ManaPoolItem mana : manaItems) {
|
||||||
|
mana.setStock(mana.count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean wasManaAddedBeyondStock() {
|
||||||
|
for (ManaPoolItem mana : manaItems) {
|
||||||
|
if (mana.getStock() < mana.count()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class ManaPoolItem implements Serializable {
|
||||||
private UUID originalId; // originalId of the mana producing ability
|
private UUID originalId; // originalId of the mana producing ability
|
||||||
private boolean flag = false;
|
private boolean flag = false;
|
||||||
private Duration duration;
|
private Duration duration;
|
||||||
|
private int stock; // amount the item had at the start of casting something
|
||||||
|
|
||||||
public ManaPoolItem() {}
|
public ManaPoolItem() {}
|
||||||
|
|
||||||
|
@ -91,6 +92,7 @@ public class ManaPoolItem implements Serializable {
|
||||||
this.originalId = item.originalId;
|
this.originalId = item.originalId;
|
||||||
this.flag = item.flag;
|
this.flag = item.flag;
|
||||||
this.duration = item.duration;
|
this.duration = item.duration;
|
||||||
|
this.stock = item.stock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManaPoolItem copy() {
|
public ManaPoolItem copy() {
|
||||||
|
@ -207,8 +209,9 @@ public class ManaPoolItem implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAny() {
|
public void removeAny() {
|
||||||
|
int oldCount = count();
|
||||||
if (black > 0) {
|
if (black > 0) {
|
||||||
black--;
|
black--;
|
||||||
} else if (blue > 0) {
|
} else if (blue > 0) {
|
||||||
blue--;
|
blue--;
|
||||||
} else if (green > 0) {
|
} else if (green > 0) {
|
||||||
|
@ -219,10 +222,14 @@ public class ManaPoolItem implements Serializable {
|
||||||
white--;
|
white--;
|
||||||
} else if (colorless > 0) {
|
} else if (colorless > 0) {
|
||||||
colorless--;
|
colorless--;
|
||||||
}
|
}
|
||||||
|
if (stock == oldCount && oldCount > count()) {
|
||||||
|
stock--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(ManaType manaType) {
|
public void remove(ManaType manaType) {
|
||||||
|
int oldCount = count();
|
||||||
switch(manaType) {
|
switch(manaType) {
|
||||||
case BLACK:
|
case BLACK:
|
||||||
if (black > 0) {
|
if (black > 0) {
|
||||||
|
@ -255,6 +262,9 @@ public class ManaPoolItem implements Serializable {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (stock == oldCount && oldCount > count()) {
|
||||||
|
stock--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear(ManaType manaType) {
|
public void clear(ManaType manaType) {
|
||||||
|
@ -310,5 +320,13 @@ public class ManaPoolItem implements Serializable {
|
||||||
public void setDuration(Duration duration) {
|
public void setDuration(Duration duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(int stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1085,6 +1085,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean activateAbility(ActivatedAbility ability, Game game) {
|
public boolean activateAbility(ActivatedAbility ability, Game game) {
|
||||||
|
getManaPool().setStock(); // needed for the "mana already in the pool has to be used manually" option
|
||||||
boolean result;
|
boolean result;
|
||||||
if (ability instanceof PassAbility) {
|
if (ability instanceof PassAbility) {
|
||||||
pass(game);
|
pass(game);
|
||||||
|
|
Loading…
Reference in a new issue