mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
spjspj - Add in 'View Current Deck' option.
This commit is contained in:
parent
56ce1abb44
commit
6ab4a94bd7
10 changed files with 73 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -91,7 +91,8 @@ public final class Constants {
|
|||
|
||||
FREE_BUILDING,
|
||||
LIMITED_BUILDING,
|
||||
SIDEBOARDING
|
||||
SIDEBOARDING,
|
||||
VIEW_LIMITED_DECK
|
||||
}
|
||||
|
||||
public enum SortBy {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.btnSave.setVisible(true);
|
||||
this.btnAddLand.setVisible(false);
|
||||
this.btnGenDeck.setVisible(false);
|
||||
this.btnImport.setVisible(false);
|
||||
this.btnLoad.setVisible(false);
|
||||
this.btnNew.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);
|
||||
|
|
|
@ -472,6 +472,17 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
popupMenu.addSeparator();
|
||||
|
||||
menuItem = new JMenuItem("<html>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() {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -546,6 +546,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);
|
||||
}
|
||||
|
@ -602,6 +605,22 @@ public class GameController implements GameCallback {
|
|||
}
|
||||
}
|
||||
|
||||
private void viewLimitedDeck(UUID userIdRequester, UUID origId) {
|
||||
Player viewLimitedDeckPlayer = game.getPlayer(userIdRequester);
|
||||
if (viewLimitedDeckPlayer != null) {
|
||||
if (viewLimitedDeckPlayer.isHuman()) {
|
||||
for (MatchPlayer p : TableManager.instance.getTable(tableId).getMatch().getPlayers()) {
|
||||
if (p.getPlayer().getId() == userIdRequester) {
|
||||
Optional<User> 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);
|
||||
|
|
|
@ -83,5 +83,6 @@ public enum PlayerAction {
|
|||
CLIENT_RECONNECT,
|
||||
CLIENT_REPLAY_ACTION,
|
||||
HOLD_PRIORITY,
|
||||
UNHOLD_PRIORITY
|
||||
UNHOLD_PRIORITY,
|
||||
VIEW_LIMITED_DECK
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue