diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 3d6d685e4c..5b6204f1d8 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -1034,7 +1034,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { if (window instanceof DeckEditorPane) { DeckEditorPane deckEditorPane = (DeckEditorPane) window; if (deckEditorPane.getDeckEditorMode() == DeckEditorMode.LIMITED_BUILDING - || deckEditorPane.getDeckEditorMode() == DeckEditorMode.SIDEBOARDING) { + || deckEditorPane.getDeckEditorMode() == DeckEditorMode.SIDEBOARDING + || deckEditorPane.getDeckEditorMode() == DeckEditorMode.VIEW_LIMITED_DECK) { deckEditorPane.removeFrame(); } } @@ -1044,7 +1045,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) { String name; - if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) { + if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING || mode == DeckEditorMode.VIEW_LIMITED_DECK) { name = "Deck Editor - " + tableId.toString(); } else { if (deck != null) { diff --git a/Mage.Client/src/main/java/mage/client/constants/Constants.java b/Mage.Client/src/main/java/mage/client/constants/Constants.java index a71ccc5750..29456b65f6 100644 --- a/Mage.Client/src/main/java/mage/client/constants/Constants.java +++ b/Mage.Client/src/main/java/mage/client/constants/Constants.java @@ -91,7 +91,8 @@ public final class Constants { FREE_BUILDING, LIMITED_BUILDING, - SIDEBOARDING + SIDEBOARDING, + VIEW_LIMITED_DECK } public enum SortBy { diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPane.java b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPane.java index 7d547a41bc..cfc1db5812 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPane.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPane.java @@ -80,6 +80,8 @@ public class DeckEditorPane extends MagePane { public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int time) { if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) { this.setTitle("Deck Editor - " + tableId.toString()); + } else if (mode == DeckEditorMode.VIEW_LIMITED_DECK) { + this.setTitle("Deck Editor - Current Deck"); } else if (deck != null) { this.setTitle("Deck Editor - " + deck.getName()); } else { diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java index 6ac79cc17b..9ac1a9c49d 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java @@ -233,6 +233,24 @@ public class DeckEditorPanel extends javax.swing.JPanel { this.deckArea.showSideboard(true); this.txtTimeRemaining.setVisible(false); break; + case VIEW_LIMITED_DECK: + this.btnExit.setVisible(true); + this.btnAddLand.setVisible(false); + this.btnGenDeck.setVisible(false); + this.btnImport.setVisible(false); + this.btnLoad.setVisible(false); + this.btnNew.setVisible(false); + this.btnSave.setVisible(false); + this.btnSubmit.setVisible(false); + this.btnSubmitTimer.setVisible(false); + this.cardSelector.loadCards(this.bigCard); + this.cardSelector.setVisible(false); + this.deckArea.setOrientation(/*limitedBuildingOrientation = */true); + this.deckArea.showSideboard(true); + this.lblDeckName.setVisible(false); + this.txtDeckName.setVisible(false); + this.txtTimeRemaining.setVisible(false); + break; } init(); this.deckArea.setDeckEditorMode(mode); 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 8650c9d175..2e90009550 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java @@ -472,6 +472,17 @@ public class PlayAreaPanel extends javax.swing.JPanel { } }); + + popupMenu.addSeparator(); + + menuItem = new JMenuItem("View current deck"); + menuItem.setMnemonic(KeyEvent.VK_V); + popupMenu.add(menuItem); + + // View limited deck + menuItem.addActionListener(e -> { + SessionHandler.sendPlayerAction(PlayerAction.VIEW_LIMITED_DECK, gameId, null); + }); } private void addPopupMenuWatcher() { diff --git a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java index 6386622235..639cf37792 100644 --- a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java +++ b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java @@ -324,6 +324,13 @@ public class CallbackClientImpl implements CallbackClient { } break; } + case VIEW_LIMITED_DECK: { + TableClientMessage message = (TableClientMessage) callback.getData(); + DeckView deckView = message.getDeck(); + Deck deck = DeckUtil.construct(deckView); + viewLimitedDeck(deck, message.getTableId(), message.getTime()); + break; + } case CONSTRUCT: { TableClientMessage message = (TableClientMessage) callback.getData(); DeckView deckView = message.getDeck(); @@ -512,6 +519,10 @@ public class CallbackClientImpl implements CallbackClient { frame.showDeckEditor(DeckEditorMode.LIMITED_BUILDING, deck, tableId, time); } + protected void viewLimitedDeck(Deck deck, UUID tableId, int time) { + frame.showDeckEditor(DeckEditorMode.VIEW_LIMITED_DECK, deck, tableId, time); + } + private void handleException(Exception ex) { logger.fatal("Client error\n", ex); frame.showError("Error: " + ex.getMessage()); diff --git a/Mage.Common/src/main/java/mage/interfaces/callback/ClientCallbackMethod.java b/Mage.Common/src/main/java/mage/interfaces/callback/ClientCallbackMethod.java index 9e3180f3a8..9a74ad6e2a 100644 --- a/Mage.Common/src/main/java/mage/interfaces/callback/ClientCallbackMethod.java +++ b/Mage.Common/src/main/java/mage/interfaces/callback/ClientCallbackMethod.java @@ -13,6 +13,7 @@ public enum ClientCallbackMethod { START_DRAFT("startDraft"), START_TOURNAMENT("startTournament"), SIDEBOARD("sideboard"), + VIEW_LIMITED_DECK("viewLimitedDeck"), CONSTRUCT("construct"), SHOW_USERMESSAGE("showUserMessage"), WATCHGAME("watchGame"), diff --git a/Mage.Server/src/main/java/mage/server/User.java b/Mage.Server/src/main/java/mage/server/User.java index ee7e96fd71..e4853b7629 100644 --- a/Mage.Server/src/main/java/mage/server/User.java +++ b/Mage.Server/src/main/java/mage/server/User.java @@ -269,6 +269,10 @@ public class User { sideboarding.put(tableId, deck); } + public void ccViewLimitedDeck(final Deck deck, final UUID tableId, final int time, boolean limited) { + fireCallback(new ClientCallback(ClientCallbackMethod.VIEW_LIMITED_DECK, tableId, new TableClientMessage(deck, tableId, time, limited))); + } + public void ccConstruct(final Deck deck, final UUID tableId, final int time) { fireCallback(new ClientCallback(ClientCallbackMethod.CONSTRUCT, tableId, new TableClientMessage(deck, tableId, time))); } diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index 5c1e38ba58..08d4b69d67 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -545,6 +545,9 @@ public class GameController implements GameCallback { requestPermissionToSeeHandCards(userId, (UUID) data); } break; + case VIEW_LIMITED_DECK: + viewLimitedDeck(getPlayerId(userId), userId); + break; default: game.sendPlayerAction(playerAction, getPlayerId(userId), data); } @@ -601,6 +604,23 @@ public class GameController implements GameCallback { } } + private void viewLimitedDeck(UUID userIdRequester, UUID origId) { + Player viewLimitedDeckPlayer = game.getPlayer(userIdRequester); + if (viewLimitedDeckPlayer != null) { + if (viewLimitedDeckPlayer.isHuman()) { + System.out.println("Origid: " + origId + " req:" + userIdRequester); + for (MatchPlayer p : TableManager.instance.getTable(tableId).getMatch().getPlayers()) { + if (p.getPlayer().getId() == userIdRequester) { + Optional u = UserManager.instance.getUser(origId); + if (u != null && u.isPresent() && p.getDeck() != null) { + u.get().ccViewLimitedDeck(p.getDeck(), tableId, requestsOpen, true); + } + } + } + } + } + } + public void cheat(UUID userId, UUID playerId, DeckCardLists deckList) { try { Deck deck = Deck.load(deckList, false, false); diff --git a/Mage/src/main/java/mage/constants/PlayerAction.java b/Mage/src/main/java/mage/constants/PlayerAction.java index cbff2a1384..cdee7edd3a 100644 --- a/Mage/src/main/java/mage/constants/PlayerAction.java +++ b/Mage/src/main/java/mage/constants/PlayerAction.java @@ -83,5 +83,6 @@ public enum PlayerAction { CLIENT_RECONNECT, CLIENT_REPLAY_ACTION, HOLD_PRIORITY, - UNHOLD_PRIORITY + UNHOLD_PRIORITY, + VIEW_LIMITED_DECK }