forked from External/mage
* Added possibility to allow other players to see hand cards of player.
This commit is contained in:
parent
d0e1107a3e
commit
7e145d2cfd
33 changed files with 1093 additions and 190 deletions
|
|
@ -299,7 +299,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}//GEN-LAST:event_btnSpecialActionPerformed
|
||||
|
||||
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.sendPlayerAction(PlayerAction.UNDO, gameId);
|
||||
session.sendPlayerAction(PlayerAction.UNDO, gameId, null);
|
||||
}
|
||||
|
||||
public void setHelperPanel(HelperPanel helper) {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
private boolean initialized = false;
|
||||
private int lastUpdatedTurn;
|
||||
private boolean menuNameSet = false;
|
||||
|
||||
private boolean handCardsOfOpponentAvailable = false;
|
||||
|
||||
private Map<String, Card> loadedCards = new HashMap<>();
|
||||
|
||||
|
|
@ -388,17 +388,18 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.feedbackPanel.init(gameId);
|
||||
this.feedbackPanel.clear();
|
||||
|
||||
|
||||
this.btnConcede.setVisible(false);
|
||||
this.btnStopWatching.setVisible(true);
|
||||
this.btnSwitchHands.setVisible(false);
|
||||
this.chosenHandKey = "";
|
||||
this.btnCancelSkip.setVisible(false);
|
||||
|
||||
this.btnSkipToNextTurn.setVisible(false);
|
||||
this.btnSkipToEndTurn.setVisible(false);
|
||||
this.btnSkipToNextMain.setVisible(false);
|
||||
this.btnSkipStack.setVisible(false);
|
||||
this.btnSkipToYourTurn.setVisible(false);
|
||||
|
||||
this.btnSkipToYourTurn.setVisible(false);
|
||||
|
||||
this.pnlReplay.setVisible(false);
|
||||
this.gameChatPanel.clear();
|
||||
|
|
@ -530,45 +531,59 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public synchronized void updateGame(GameView game, Map<String, Serializable> options) {
|
||||
if (playerId == null || game.getHand() == null) {
|
||||
if (playerId == null && game.getWatchedHands() == null) {
|
||||
this.handContainer.setVisible(false);
|
||||
} else {
|
||||
this.handContainer.setVisible(true);
|
||||
handCards.clear();
|
||||
handCards.put(YOUR_HAND, game.getHand());
|
||||
|
||||
// Mark playable
|
||||
if (game.getCanPlayInHand() != null) {
|
||||
for (CardView card : handCards.get(YOUR_HAND).values()) {
|
||||
if (game.getCanPlayInHand().contains(card.getId())) {
|
||||
card.setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get opponents hand cards if available
|
||||
if (game.getOpponentHands() != null) {
|
||||
for (Map.Entry<String, SimpleCardsView> hand: game.getOpponentHands().entrySet()) {
|
||||
if (game.getWatchedHands() != null) {
|
||||
for (Map.Entry<String, SimpleCardsView> hand: game.getWatchedHands().entrySet()) {
|
||||
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(hand.getValue(), loadedCards));
|
||||
}
|
||||
}
|
||||
|
||||
if (!handCards.containsKey(chosenHandKey)) {
|
||||
chosenHandKey = YOUR_HAND;
|
||||
if (playerId != null) {
|
||||
handCards.put(YOUR_HAND, game.getHand());
|
||||
// Mark playable
|
||||
if (game.getCanPlayInHand() != null) {
|
||||
for (CardView card : handCards.get(YOUR_HAND).values()) {
|
||||
if (game.getCanPlayInHand().contains(card.getId())) {
|
||||
card.setPlayable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get opponents hand cards if available (only possible for players)
|
||||
if (game.getOpponentHands() != null) {
|
||||
for (Map.Entry<String, SimpleCardsView> hand: game.getOpponentHands().entrySet()) {
|
||||
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(hand.getValue(), loadedCards));
|
||||
}
|
||||
}
|
||||
if (!handCards.containsKey(chosenHandKey)) {
|
||||
chosenHandKey = YOUR_HAND;
|
||||
}
|
||||
} else if (chosenHandKey.isEmpty() && handCards.size() > 0) {
|
||||
chosenHandKey = handCards.keySet().iterator().next();
|
||||
}
|
||||
if (chosenHandKey != null && handCards.containsKey(chosenHandKey)) {
|
||||
handContainer.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
|
||||
}
|
||||
handContainer.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
|
||||
|
||||
hideAll();
|
||||
|
||||
// set visible only if we have any other hand visible than ours
|
||||
boolean previous = btnSwitchHands.isVisible();
|
||||
boolean visible = handCards.size() > 1;
|
||||
if (previous != visible) {
|
||||
btnSwitchHands.setVisible(visible);
|
||||
if (visible) {
|
||||
JOptionPane.showMessageDialog(null, "You control other player's turn. \nUse \"Switch Hand\" button to switch between cards in different hands.");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "You lost control on other player's turn.");
|
||||
|
||||
if (playerId != null) {
|
||||
// set visible only if we have any other hand visible than ours
|
||||
btnSwitchHands.setVisible(handCards.size() > 1);
|
||||
boolean change = (handCardsOfOpponentAvailable != (game.getOpponentHands() != null));
|
||||
if (change) {
|
||||
handCardsOfOpponentAvailable = !handCardsOfOpponentAvailable;
|
||||
if (handCardsOfOpponentAvailable) {
|
||||
JOptionPane.showMessageDialog(null, "You control other player's turn. \nUse \"Switch Hand\" button to switch between cards in different hands.");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "You lost control on other player's turn.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btnSwitchHands.setVisible(!handCards.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1280,7 +1295,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
btnStopWatching.setBorder(new EmptyBorder(0,0,0,0));
|
||||
btnStopWatching.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getStopWatchButtonImage()));
|
||||
btnStopWatching.setFocusable(false);
|
||||
btnSwitchHands.setToolTipText("Stop watching this game.");
|
||||
btnStopWatching.setToolTipText("Stop watching this game.");
|
||||
btnStopWatching.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent evt) {
|
||||
|
|
@ -1620,42 +1635,42 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
private void btnConcedeActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (modalQuestion("Are you sure you want to concede?", "Confirm concede") == JOptionPane.YES_OPTION) {
|
||||
session.sendPlayerAction(PlayerAction.CONCEDE, gameId);
|
||||
session.sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
||||
AudioManager.playOnSkipButton();
|
||||
updateSkipButtons(true, false, false, false, false);
|
||||
}
|
||||
|
||||
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||
AudioManager.playOnSkipButton();
|
||||
updateSkipButtons(false, true, false, false, false);
|
||||
}
|
||||
|
||||
private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||
AudioManager.playOnSkipButton();
|
||||
updateSkipButtons(false, false, true, false, false);
|
||||
}
|
||||
|
||||
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
||||
AudioManager.playOnSkipButton();
|
||||
updateSkipButtons(false, false, false, true, false);
|
||||
}
|
||||
|
||||
private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
|
||||
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);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||
AudioManager.playOnSkipButtonCancel();
|
||||
updateSkipButtons(false, false, false, false, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
private UUID gameId;
|
||||
private boolean smallMode = false;
|
||||
private boolean playingMode = true;
|
||||
private GamePanel gamePanel;
|
||||
private final GamePanel gamePanel;
|
||||
private final boolean playerItself;
|
||||
|
||||
private JCheckBoxMenuItem manaPoolMenuItem;
|
||||
|
||||
|
|
@ -72,23 +73,27 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
public static final int PANEL_HEIGHT_SMALL = 190;
|
||||
|
||||
/** Creates new form PlayAreaPanel
|
||||
* @param isPlayer */
|
||||
public PlayAreaPanel(boolean isPlayer) {
|
||||
* @param player
|
||||
* @param bigCard
|
||||
* @param gameId
|
||||
* @param isPlayer true if the client is a player / false if the client is a watcher
|
||||
* @param playerItself true if it's the area of the player itself
|
||||
* @param priorityTime
|
||||
* @param gamePanel */
|
||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean playerItself, int priorityTime, boolean isPlayer, GamePanel gamePanel) {
|
||||
//this(isPlayer);
|
||||
this.playerItself = playerItself;
|
||||
initComponents();
|
||||
setOpaque(false);
|
||||
battlefieldPanel.setOpaque(false);
|
||||
|
||||
|
||||
popupMenu = new JPopupMenu();
|
||||
if (isPlayer) {
|
||||
addPopupMenuPlayer();
|
||||
addPopupMenuPlayer(player.getUserData().allowRequestShowHandCards());
|
||||
} else {
|
||||
addPopupMenuWatcher();
|
||||
}
|
||||
this.add(popupMenu);
|
||||
}
|
||||
|
||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me, int priorityTime, boolean isPlayer, GamePanel gamePanel) {
|
||||
this(isPlayer);
|
||||
this.gamePanel = gamePanel;
|
||||
init(player, bigCard, gameId, priorityTime);
|
||||
update(player);
|
||||
|
|
@ -125,7 +130,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
|
||||
}
|
||||
|
||||
private void addPopupMenuPlayer() {
|
||||
private void addPopupMenuPlayer(boolean allowRequestToShowHandCards) {
|
||||
|
||||
JMenuItem menuItem;
|
||||
|
||||
|
|
@ -150,7 +155,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId);
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -163,7 +168,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId);
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -174,7 +179,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId);
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -185,7 +190,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId);
|
||||
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)");
|
||||
|
|
@ -195,7 +200,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId);
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -212,7 +217,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
public void actionPerformed(ActionEvent e) {
|
||||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
gamePanel.setMenuStates(manaPoolAutomatic);
|
||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId);
|
||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -225,12 +230,53 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId);
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
popupMenu.addSeparator();
|
||||
|
||||
if (!playerItself) {
|
||||
menuItem = new JMenuItem("Request permission to see hand cards");
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Request to see hand cards
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
menuItem = new JCheckBoxMenuItem("Allow requests to show your hand cards", allowRequestToShowHandCards);
|
||||
menuItem.setMnemonic(KeyEvent.VK_A);
|
||||
menuItem.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(menuItem);
|
||||
|
||||
// Requests allowed
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean requestsAllowed = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
gamePanel.getSession().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON: PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
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
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
popupMenu.addSeparator();
|
||||
|
||||
menuItem = new JMenuItem("Concede game");
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
|
|
@ -239,7 +285,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
@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);
|
||||
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -297,6 +343,18 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
menuItem = new JMenuItem("Request permission to see hand cards");
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Request to see hand cards
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
||||
}
|
||||
});
|
||||
|
||||
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent Me) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue