mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
server, refactor: added client side info about current table and parent table (tourney's sub-tables with matches);
This commit is contained in:
parent
bd7aaa34ee
commit
7916af0e52
21 changed files with 315 additions and 161 deletions
|
|
@ -72,9 +72,8 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.SocketException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
|
@ -757,19 +756,16 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
/**
|
||||
* Shows a game for a player of the game
|
||||
*
|
||||
* @param gameId
|
||||
* @param playerId
|
||||
*/
|
||||
public void showGame(UUID gameId, UUID playerId) {
|
||||
public void showGame(UUID currentTableId, UUID parentTableId, UUID gameId, UUID playerId) {
|
||||
GamePane gamePane = new GamePane();
|
||||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.showGame(gameId, playerId);
|
||||
gamePane.showGame(currentTableId, parentTableId, gameId, playerId);
|
||||
setActive(gamePane);
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId) {
|
||||
public void watchGame(UUID currentTableId, UUID parentTableId, UUID gameId) {
|
||||
for (Component component : desktopPane.getComponents()) {
|
||||
if (component instanceof GamePane
|
||||
&& ((GamePane) component).getGameId().equals(gameId)) {
|
||||
|
|
@ -780,7 +776,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
GamePane gamePane = new GamePane();
|
||||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.watchGame(gameId);
|
||||
gamePane.watchGame(currentTableId, parentTableId, gameId);
|
||||
setActive(gamePane);
|
||||
}
|
||||
|
||||
|
|
@ -792,11 +788,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
setActive(gamePane);
|
||||
}
|
||||
|
||||
public void showDraft(UUID draftId) {
|
||||
public void showDraft(UUID tableId, UUID draftId) {
|
||||
DraftPane draftPane = new DraftPane();
|
||||
desktopPane.add(draftPane, JLayeredPane.DEFAULT_LAYER);
|
||||
draftPane.setVisible(true);
|
||||
draftPane.showDraft(draftId);
|
||||
draftPane.showDraft(tableId, draftId);
|
||||
setActive(draftPane);
|
||||
}
|
||||
|
||||
|
|
@ -810,7 +806,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}
|
||||
}
|
||||
|
||||
public void showTournament(UUID tournamentId) {
|
||||
public void showTournament(UUID tableId, UUID tournamentId) {
|
||||
// existing tourney
|
||||
TournamentPane tournamentPane = null;
|
||||
for (Component component : desktopPane.getComponents()) {
|
||||
|
|
@ -825,7 +821,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
tournamentPane = new TournamentPane();
|
||||
desktopPane.add(tournamentPane, JLayeredPane.DEFAULT_LAYER);
|
||||
tournamentPane.setVisible(true);
|
||||
tournamentPane.showTournament(tournamentId);
|
||||
tournamentPane.showTournament(tableId, tournamentId);
|
||||
}
|
||||
|
||||
// if user connects on startup then there are possible multiple tables open, so keep only actual
|
||||
|
|
@ -1109,23 +1105,23 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 838, Short.MAX_VALUE)
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 838, Short.MAX_VALUE)
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2, 2, 2)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2, 2, 2)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnDeckEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeckEditorActionPerformed
|
||||
showDeckEditor(DeckEditorMode.FREE_BUILDING, null, null, 0);
|
||||
showDeckEditor(DeckEditorMode.FREE_BUILDING, null, null, null, 0);
|
||||
}//GEN-LAST:event_btnDeckEditorActionPerformed
|
||||
|
||||
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
||||
|
|
@ -1340,9 +1336,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
return name;
|
||||
}
|
||||
|
||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int visibleTimer) {
|
||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID currentTableId, UUID parentTableId, int visibleTimer) {
|
||||
// create or open new editor
|
||||
String name = prepareDeckEditorName(mode, deck, tableId);
|
||||
String name = prepareDeckEditorName(mode, deck, currentTableId);
|
||||
|
||||
// already exists
|
||||
Component[] windows = desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
|
||||
|
|
@ -1357,7 +1353,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
DeckEditorPane deckEditor = new DeckEditorPane();
|
||||
desktopPane.add(deckEditor, JLayeredPane.DEFAULT_LAYER);
|
||||
deckEditor.setVisible(false);
|
||||
deckEditor.show(mode, deck, name, tableId, visibleTimer);
|
||||
deckEditor.show(mode, deck, name, currentTableId, parentTableId, visibleTimer);
|
||||
setActive(deckEditor);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@ import java.util.UUID;
|
|||
/**
|
||||
* GUI: deck editor, used all around the app
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public class DeckEditorPane extends MagePane {
|
||||
|
||||
private UUID tableId = null;
|
||||
private UUID currentTableId = null;
|
||||
private UUID parentTableId = null;
|
||||
|
||||
public DeckEditorPane() {
|
||||
boolean initialized = false;
|
||||
|
|
@ -45,22 +46,28 @@ public class DeckEditorPane extends MagePane {
|
|||
deckEditorPanel1.changeGUISize();
|
||||
}
|
||||
|
||||
public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int visibleTimer) {
|
||||
this.tableId = tableId;
|
||||
public void show(DeckEditorMode mode, Deck deck, String name, UUID currentTableId, UUID parentTableId, int visibleTimer) {
|
||||
this.currentTableId = currentTableId;
|
||||
this.parentTableId = parentTableId;
|
||||
this.setTitle(name);
|
||||
this.deckEditorPanel1.showDeckEditor(mode, deck, tableId, visibleTimer);
|
||||
this.deckEditorPanel1.showDeckEditor(mode, deck, currentTableId, parentTableId, visibleTimer);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActiveTable() {
|
||||
return this.tableId != null;
|
||||
return this.currentTableId != null;
|
||||
}
|
||||
|
||||
public DeckEditorMode getDeckEditorMode() {
|
||||
return this.deckEditorPanel1.getDeckEditorMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSortTableId() {
|
||||
return parentTableId != null ? parentTableId : currentTableId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
private final Map<UUID, Card> temporaryCards = new HashMap<>(); // Cards dragged out of one part of the view into another
|
||||
private final String LAST_DECK_FOLDER = "lastDeckFolder";
|
||||
private Deck deck = new Deck();
|
||||
private UUID tableId;
|
||||
private UUID currentTableId;
|
||||
private UUID parentTableId;
|
||||
private DeckEditorMode mode;
|
||||
private int timeout;
|
||||
private javax.swing.Timer countdown;
|
||||
|
|
@ -202,11 +203,12 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
this.deckArea.changeGUISize();
|
||||
}
|
||||
|
||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int visibleTimer) {
|
||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID currentTableId, UUID parentTableId, int visibleTimer) {
|
||||
if (deck != null) {
|
||||
this.deck = deck;
|
||||
}
|
||||
this.tableId = tableId;
|
||||
this.currentTableId = currentTableId;
|
||||
this.parentTableId = parentTableId;
|
||||
this.mode = mode;
|
||||
this.btnAddLand.setVisible(false);
|
||||
|
||||
|
|
@ -243,7 +245,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
if (timeout != 0) {
|
||||
countdown.start();
|
||||
if (updateDeckTask == null || updateDeckTask.isDone()) {
|
||||
updateDeckTask = new UpdateDeckTask(SessionHandler.getSession(), tableId, deck);
|
||||
updateDeckTask = new UpdateDeckTask(SessionHandler.getSession(), currentTableId, deck);
|
||||
updateDeckTask.execute();
|
||||
}
|
||||
}
|
||||
|
|
@ -1488,7 +1490,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
updateDeckTask.cancel(true);
|
||||
}
|
||||
|
||||
if (SessionHandler.submitDeck(mode, tableId, deck.prepareCardsOnlyDeck())) {
|
||||
if (SessionHandler.submitDeck(mode, currentTableId, deck.prepareCardsOnlyDeck())) {
|
||||
removeDeckEditor();
|
||||
}
|
||||
}//GEN-LAST:event_btnSubmitActionPerformed
|
||||
|
|
@ -1507,7 +1509,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
updateDeckTask.cancel(true);
|
||||
}
|
||||
|
||||
if (SessionHandler.submitDeck(mode, tableId, deck.prepareCardsOnlyDeck())) {
|
||||
if (SessionHandler.submitDeck(mode, currentTableId, deck.prepareCardsOnlyDeck())) {
|
||||
SwingUtilities.invokeLater(this::removeDeckEditor);
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Collection viewer pane.
|
||||
* GUI: card viewer pane.
|
||||
* Contains background and components container.
|
||||
*
|
||||
* @author nantuko
|
||||
|
|
@ -19,7 +20,7 @@ public class CollectionViewerPane extends MagePane {
|
|||
|
||||
public CollectionViewerPane() {
|
||||
boolean initialized = false;
|
||||
this.setTitle("Collection Viewer");
|
||||
this.setTitle("Card Viewer");
|
||||
if (Plugins.instance.isThemePluginLoaded()) {
|
||||
Map<String, JComponent> uiComponents = new HashMap<>();
|
||||
JComponent container = Plugins.instance.updateTablePanel(uiComponents);
|
||||
|
|
@ -65,5 +66,10 @@ public class CollectionViewerPane extends MagePane {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSortTableId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private CollectionViewerPanel collectionViewerPanel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import mage.client.plugins.impl.Plugins;
|
|||
*/
|
||||
public class DraftPane extends MagePane {
|
||||
|
||||
UUID tableId = null;
|
||||
UUID draftId = null;
|
||||
|
||||
public DraftPane() {
|
||||
|
|
@ -42,7 +43,8 @@ public class DraftPane extends MagePane {
|
|||
draftPanel1.changeGUISize();
|
||||
}
|
||||
|
||||
public void showDraft(UUID draftId) {
|
||||
public void showDraft(UUID tableId, UUID draftId) {
|
||||
this.tableId = tableId;
|
||||
this.draftId = draftId;
|
||||
this.setTitle("Draft - " + draftId);
|
||||
this.draftPanel1.showDraft(draftId);
|
||||
|
|
@ -58,6 +60,11 @@ public class DraftPane extends MagePane {
|
|||
this.removeFrame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSortTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import mage.client.MagePane;
|
|||
/**
|
||||
* Game GUI: game frame (game panel with scrolls)
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public class GamePane extends MagePane {
|
||||
|
||||
|
|
@ -25,10 +25,12 @@ public class GamePane extends MagePane {
|
|||
|
||||
}
|
||||
|
||||
public void showGame(UUID gameId, UUID playerId) {
|
||||
public void showGame(UUID currentTableId, UUID parentTableId, UUID gameId, UUID playerId) {
|
||||
this.setTitle("Game " + gameId);
|
||||
this.currentTableId = currentTableId;
|
||||
this.parentTableId = parentTableId;
|
||||
this.gameId = gameId;
|
||||
gamePanel.showGame(gameId, playerId, this);
|
||||
gamePanel.showGame(currentTableId, parentTableId, gameId, playerId, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -53,14 +55,18 @@ public class GamePane extends MagePane {
|
|||
this.removeFrame();
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId) {
|
||||
public void watchGame(UUID currentTableId, UUID parentTableId, UUID gameId) {
|
||||
this.setTitle("Watching " + gameId);
|
||||
this.currentTableId = currentTableId;
|
||||
this.parentTableId = parentTableId;
|
||||
this.gameId = gameId;
|
||||
gamePanel.watchGame(gameId, this);
|
||||
gamePanel.watchGame(currentTableId, parentTableId, gameId, this);
|
||||
}
|
||||
|
||||
public void replayGame(UUID gameId) {
|
||||
this.setTitle("Replaying " + gameId);
|
||||
this.currentTableId = null;
|
||||
this.parentTableId = null;
|
||||
this.gameId = gameId;
|
||||
gamePanel.replayGame(gameId);
|
||||
}
|
||||
|
|
@ -108,7 +114,14 @@ public class GamePane extends MagePane {
|
|||
gamePanel.handleEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSortTableId() {
|
||||
return parentTableId != null ? parentTableId : currentTableId;
|
||||
}
|
||||
|
||||
private mage.client.game.GamePanel gamePanel;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private UUID currentTableId;
|
||||
private UUID parentTableId;
|
||||
private UUID gameId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
private final ArrayList<PickPileDialog> pickPile = new ArrayList<>();
|
||||
private final Map<String, CardHintsHelperDialog> cardHintsWindows = new LinkedHashMap<>();
|
||||
|
||||
private UUID currentTableId;
|
||||
private UUID parentTableId;
|
||||
private UUID gameId;
|
||||
private UUID playerId; // playerId of the player
|
||||
GamePane gamePane;
|
||||
|
|
@ -693,7 +695,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
DialogManager.getManager(gameId).setBounds(0, 0, rect.width, rect.height);
|
||||
}
|
||||
|
||||
public synchronized void showGame(UUID gameId, UUID playerId, GamePane gamePane) {
|
||||
public synchronized void showGame(UUID currentTableId, UUID parentTableId, UUID gameId, UUID playerId, GamePane gamePane) {
|
||||
this.currentTableId = currentTableId;
|
||||
this.parentTableId = parentTableId;
|
||||
this.gameId = gameId;
|
||||
this.gamePane = gamePane;
|
||||
this.playerId = playerId;
|
||||
|
|
@ -734,7 +738,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void watchGame(UUID gameId, GamePane gamePane) {
|
||||
public synchronized void watchGame(UUID currentTableId, UUID parentTableId, UUID gameId, GamePane gamePane) {
|
||||
this.currentTableId = currentTableId;
|
||||
this.parentTableId = parentTableId;
|
||||
this.gameId = gameId;
|
||||
this.gamePane = gamePane;
|
||||
this.playerId = null;
|
||||
|
|
@ -769,6 +775,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public synchronized void replayGame(UUID gameId) {
|
||||
this.currentTableId = null;
|
||||
this.parentTableId = null;
|
||||
this.gameId = gameId;
|
||||
this.playerId = null;
|
||||
MageFrame.addGame(gameId, this);
|
||||
|
|
@ -3136,6 +3144,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||
|
||||
// replay without table - just single game
|
||||
private final UUID gameId;
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ReplayTask.class);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
case START_GAME: {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
GameManager.instance.setCurrentPlayerUUID(message.getPlayerId());
|
||||
gameStarted(callback.getMessageId(), message.getGameId(), message.getPlayerId());
|
||||
gameStarted(callback.getMessageId(), message.getCurrentTableId(), message.getParentTableId(), message.getGameId(), message.getPlayerId());
|
||||
|
||||
// reconnect fix with miss data, part 2 of 2
|
||||
// START_GAME event can come after GAME_INIT or any other, so must force update with first info
|
||||
|
|
@ -137,7 +137,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
|
||||
case START_TOURNAMENT: {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
tournamentStarted(callback.getMessageId(), message.getGameId(), message.getPlayerId());
|
||||
tournamentStarted(callback.getMessageId(), callback.getObjectId(), message.getCurrentTableId(), message.getPlayerId());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -147,12 +147,14 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
|
||||
case SHOW_TOURNAMENT: {
|
||||
showTournament(callback.getObjectId());
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
showTournament(message.getCurrentTableId(), callback.getObjectId());
|
||||
break;
|
||||
}
|
||||
|
||||
case WATCHGAME: {
|
||||
watchGame(callback.getObjectId());
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
watchGame(message.getCurrentTableId(), message.getParentTableId(), callback.getObjectId());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +216,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
|
||||
case JOINED_TABLE: {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
||||
joinedTable(message.getRoomId(), message.getCurrentTableId(), message.getFlag());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -431,9 +433,9 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
DeckView deckView = message.getDeck();
|
||||
Deck deck = DeckUtil.construct(deckView);
|
||||
if (message.getFlag()) {
|
||||
construct_sideboard(deck, message.getTableId(), message.getTime());
|
||||
construct_sideboard(deck, message.getCurrentTableId(), message.getParentTableId(), message.getTime());
|
||||
} else {
|
||||
sideboard(deck, message.getTableId(), message.getTime());
|
||||
sideboard(deck, message.getCurrentTableId(), message.getParentTableId(), message.getTime());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -442,7 +444,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
DeckView deckView = message.getDeck();
|
||||
Deck deck = DeckUtil.construct(deckView);
|
||||
viewLimitedDeck(deck, message.getTableId(), message.getTime());
|
||||
viewLimitedDeck(deck, message.getCurrentTableId(), message.getParentTableId(), message.getTime());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -456,13 +458,13 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
DeckView deckView = message.getDeck();
|
||||
Deck deck = DeckUtil.construct(deckView);
|
||||
construct(deck, message.getTableId(), message.getTime());
|
||||
construct(deck, message.getCurrentTableId(), message.getParentTableId(), message.getTime());
|
||||
break;
|
||||
}
|
||||
|
||||
case START_DRAFT: {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
draftStarted(callback.getMessageId(), message.getGameId(), message.getPlayerId());
|
||||
draftStarted(callback.getMessageId(), message.getCurrentTableId(), callback.getObjectId(), message.getPlayerId());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -606,10 +608,10 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
}
|
||||
|
||||
protected void gameStarted(final int messageId, final UUID gameId, final UUID playerId) {
|
||||
protected void gameStarted(final int messageId, final UUID currentTableId, final UUID parentTableId, final UUID gameId, final UUID playerId) {
|
||||
try {
|
||||
frame.showGame(gameId, playerId);
|
||||
logger.info("Game " + gameId + " started for player " + playerId);
|
||||
frame.showGame(currentTableId, parentTableId, gameId, playerId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
|
@ -619,20 +621,20 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
}
|
||||
|
||||
protected void draftStarted(int messageId, UUID draftId, UUID playerId) {
|
||||
protected void draftStarted(int messageId, UUID tableId, UUID draftId, UUID playerId) {
|
||||
try {
|
||||
frame.showDraft(draftId);
|
||||
logger.info("Draft " + draftId + " started for player " + playerId);
|
||||
frame.showDraft(tableId, draftId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void tournamentStarted(int messageId, UUID tournamentId, UUID playerId) {
|
||||
protected void tournamentStarted(int messageId, UUID tournamentId, UUID tableId, UUID playerId) {
|
||||
try {
|
||||
frame.showTournament(tournamentId);
|
||||
AudioManager.playTournamentStarted();
|
||||
logger.info("Tournament " + tournamentId + " started for player " + playerId);
|
||||
frame.showTournament(tableId, tournamentId);
|
||||
AudioManager.playTournamentStarted();
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
|
@ -640,22 +642,20 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
|
||||
/**
|
||||
* Shows the tournament info panel for a tournament
|
||||
*
|
||||
* @param tournamentId
|
||||
*/
|
||||
protected void showTournament(UUID tournamentId) {
|
||||
protected void showTournament(UUID tableId, UUID tournamentId) {
|
||||
try {
|
||||
frame.showTournament(tournamentId);
|
||||
logger.info("Showing tournament " + tournamentId);
|
||||
frame.showTournament(tableId, tournamentId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void watchGame(UUID gameId) {
|
||||
protected void watchGame(UUID currentTableId, UUID parentTableId, UUID gameId) {
|
||||
try {
|
||||
frame.watchGame(gameId);
|
||||
logger.info("Watching game " + gameId);
|
||||
frame.watchGame(currentTableId, parentTableId, gameId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
|
@ -663,27 +663,27 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
|
||||
protected void replayGame(UUID gameId) {
|
||||
try {
|
||||
logger.info("Replaying game " + gameId);
|
||||
frame.replayGame(gameId);
|
||||
logger.info("Replaying game");
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void sideboard(Deck deck, UUID tableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.SIDEBOARDING, deck, tableId, time);
|
||||
protected void sideboard(Deck deck, UUID currentTableId, UUID parentTableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.SIDEBOARDING, deck, currentTableId, parentTableId, time);
|
||||
}
|
||||
|
||||
protected void construct(Deck deck, UUID tableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.LIMITED_BUILDING, deck, tableId, time);
|
||||
protected void construct(Deck deck, UUID currentTableId, UUID parentTableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.LIMITED_BUILDING, deck, currentTableId, parentTableId, time);
|
||||
}
|
||||
|
||||
protected void construct_sideboard(Deck deck, UUID tableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.LIMITED_SIDEBOARD_BUILDING, deck, tableId, time);
|
||||
protected void construct_sideboard(Deck deck, UUID currentTableId, UUID parentTableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.LIMITED_SIDEBOARD_BUILDING, deck, currentTableId, parentTableId, time);
|
||||
}
|
||||
|
||||
protected void viewLimitedDeck(Deck deck, UUID tableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.VIEW_LIMITED_DECK, deck, tableId, time);
|
||||
protected void viewLimitedDeck(Deck deck, UUID currentTableId, UUID parentTableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.VIEW_LIMITED_DECK, deck, currentTableId, parentTableId, time);
|
||||
}
|
||||
|
||||
protected void viewSideboard(UUID gameId, UUID playerId) {
|
||||
|
|
|
|||
|
|
@ -10,13 +10,15 @@ import mage.client.MagePane;
|
|||
*/
|
||||
public class TournamentPane extends MagePane {
|
||||
|
||||
UUID tableId = null;
|
||||
UUID tournamentId = null;
|
||||
|
||||
public TournamentPane() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void showTournament(UUID tournamentId) {
|
||||
public void showTournament(UUID tableId, UUID tournamentId) {
|
||||
this.tableId = tableId;
|
||||
this.tournamentId = tournamentId;
|
||||
this.setTitle("Tournament " + tournamentId);
|
||||
this.tournamentPanel.showTournament(tournamentId);
|
||||
|
|
@ -45,6 +47,11 @@ public class TournamentPane extends MagePane {
|
|||
return tournamentPanel.getTournamentId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSortTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
|
|
|||
|
|
@ -9,49 +9,69 @@ import mage.cards.decks.Deck;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public class TableClientMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private DeckView deck;
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID currentTableId;
|
||||
private UUID parentTableId; // tourney uses sub-tables for matches
|
||||
private UUID gameId;
|
||||
private UUID playerId;
|
||||
private int time;
|
||||
private boolean flag = false;
|
||||
|
||||
public TableClientMessage(Deck deck, UUID tableId, int time) {
|
||||
public TableClientMessage() {
|
||||
}
|
||||
|
||||
public TableClientMessage withDeck(Deck deck) {
|
||||
this.deck = new DeckView(deck);
|
||||
this.tableId = tableId;
|
||||
this.time = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableClientMessage(Deck deck, UUID tableId, int time, boolean flag) {
|
||||
this.deck = new DeckView(deck);
|
||||
this.tableId = tableId;
|
||||
this.time = time;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public TableClientMessage(UUID gameId, UUID playerId) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public TableClientMessage(UUID roomId, UUID tableId, boolean flag) {
|
||||
public TableClientMessage withRoom(UUID roomId) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableClientMessage withTime(int time) {
|
||||
this.time = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableClientMessage withFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableClientMessage withPlayer(UUID playerId) {
|
||||
this.playerId = playerId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableClientMessage withTable(UUID currentTableId, UUID parentTableId) {
|
||||
this.currentTableId = currentTableId;
|
||||
this.parentTableId = parentTableId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableClientMessage withGame(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeckView getDeck() {
|
||||
return deck;
|
||||
}
|
||||
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
public UUID getCurrentTableId() {
|
||||
return currentTableId;
|
||||
}
|
||||
|
||||
public UUID getParentTableId() {
|
||||
return parentTableId;
|
||||
}
|
||||
|
||||
public UUID getRoomId() {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import java.util.concurrent.ScheduledFuture;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public class TableController {
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ public class TableController {
|
|||
if (seat.getPlayer().isHuman()) {
|
||||
seat.getPlayer().setUserData(user.getUserData());
|
||||
user.addTable(player.getId(), table);
|
||||
user.ccJoinedTable(table.getRoomId(), table.getId(), true);
|
||||
user.ccJoinedTable(table.getRoomId(), table.getId(), table.getParentTableId(), true);
|
||||
userPlayerMap.put(userId, player.getId());
|
||||
}
|
||||
|
||||
|
|
@ -394,7 +394,7 @@ public class TableController {
|
|||
if (!table.isTournamentSubTable()) {
|
||||
user.addTable(player.getId(), table);
|
||||
}
|
||||
user.ccJoinedTable(table.getRoomId(), table.getId(), false);
|
||||
user.ccJoinedTable(table.getRoomId(), table.getId(), table.getParentTableId(), false);
|
||||
userPlayerMap.put(userId, player.getId());
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +524,7 @@ public class TableController {
|
|||
|
||||
public boolean watchTable(UUID userId) {
|
||||
if (table.isTournament()) {
|
||||
managerFactory.userManager().getUser(userId).ifPresent(user -> user.ccShowTournament(table.getTournament().getId()));
|
||||
managerFactory.userManager().getUser(userId).ifPresent(user -> user.ccShowTournament(table.getId(), table.getTournament().getId()));
|
||||
return true;
|
||||
} else {
|
||||
if (table.isTournamentSubTable() && !table.getTournament().getOptions().isWatchingAllowed()) {
|
||||
|
|
@ -541,7 +541,7 @@ public class TableController {
|
|||
if (!_user.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
return _user.get().ccWatchGame(match.getGame().getId());
|
||||
return _user.get().ccWatchGame(table.getId(), table.getParentTableId(), match.getGame().getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -685,7 +685,7 @@ public class TableController {
|
|||
Optional<User> _user = managerFactory.userManager().getUser(entry.getKey());
|
||||
if (_user.isPresent()) {
|
||||
User user = _user.get();
|
||||
user.ccGameStarted(match.getGame().getId(), entry.getValue());
|
||||
user.ccGameStarted(table.getId(), table.getParentTableId(), match.getGame().getId(), entry.getValue());
|
||||
|
||||
if (creator == null) {
|
||||
creator = user.getName();
|
||||
|
|
@ -744,7 +744,7 @@ public class TableController {
|
|||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
managerFactory.userManager().getUser(entry.getKey()).ifPresent(user -> {
|
||||
logger.info(new StringBuilder("User ").append(user.getName()).append(" tournament started: ").append(tournament.getId()).append(" userId: ").append(user.getId()));
|
||||
user.ccTournamentStarted(tournament.getId(), entry.getValue());
|
||||
user.ccTournamentStarted(table.getId(), tournament.getId(), entry.getValue());
|
||||
});
|
||||
}
|
||||
ServerMessagesUtil.instance.incTournamentsStarted();
|
||||
|
|
@ -757,13 +757,13 @@ public class TableController {
|
|||
}
|
||||
|
||||
public void startDraft(Draft draft) {
|
||||
table.initDraft();
|
||||
table.initDraft(draft);
|
||||
managerFactory.draftManager().createDraftSession(draft, userPlayerMap, table.getId());
|
||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
Optional<User> user = managerFactory.userManager().getUser(entry.getKey());
|
||||
if (user.isPresent()) {
|
||||
logger.info(new StringBuilder("User ").append(user.get().getName()).append(" draft started: ").append(draft.getId()).append(" userId: ").append(user.get().getId()));
|
||||
user.get().ccDraftStarted(draft.getId(), entry.getValue());
|
||||
user.get().ccDraftStarted(table.getId(), draft.getId(), entry.getValue());
|
||||
} else {
|
||||
logger.fatal(new StringBuilder("Start draft user not found userId: ").append(entry.getKey()));
|
||||
}
|
||||
|
|
@ -776,7 +776,7 @@ public class TableController {
|
|||
if (entry.getValue().equals(playerId)) {
|
||||
Optional<User> user = managerFactory.userManager().getUser(entry.getKey());
|
||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||
user.ifPresent(user1 -> user1.ccSideboard(deck, table.getId(), remaining, options.isLimited()));
|
||||
user.ifPresent(user1 -> user1.ccSideboard(deck, table.getId(), table.getParentTableId(), remaining, options.isLimited()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import mage.interfaces.callback.ClientCallback;
|
|||
import mage.interfaces.callback.ClientCallbackMethod;
|
||||
import mage.players.net.UserData;
|
||||
import mage.server.draft.DraftSession;
|
||||
import mage.server.game.GameController;
|
||||
import mage.server.game.GameSessionPlayer;
|
||||
import mage.server.managers.ManagerFactory;
|
||||
import mage.server.rating.GlickoRating;
|
||||
|
|
@ -262,41 +263,77 @@ public class User {
|
|||
}
|
||||
}
|
||||
|
||||
public void ccJoinedTable(final UUID roomId, final UUID tableId, boolean isTournament) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.JOINED_TABLE, tableId, new TableClientMessage(roomId, tableId, isTournament)));
|
||||
public void ccJoinedTable(final UUID roomId, final UUID currentTableId, final UUID parentTableId, boolean isTournament) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.JOINED_TABLE,
|
||||
currentTableId,
|
||||
new TableClientMessage().withRoom(roomId).withTable(currentTableId, parentTableId).withFlag(isTournament)
|
||||
));
|
||||
}
|
||||
|
||||
public void ccGameStarted(final UUID gameId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.START_GAME, gameId, new TableClientMessage(gameId, playerId)));
|
||||
public void ccGameStarted(final UUID currentTableId, final UUID parentTableId, final UUID gameId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.START_GAME,
|
||||
gameId,
|
||||
new TableClientMessage().withTable(currentTableId, parentTableId).withGame(gameId).withPlayer(playerId)
|
||||
));
|
||||
}
|
||||
|
||||
public void ccDraftStarted(final UUID draftId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.START_DRAFT, draftId, new TableClientMessage(draftId, playerId)));
|
||||
public void ccDraftStarted(final UUID tableId, final UUID draftId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.START_DRAFT,
|
||||
draftId,
|
||||
new TableClientMessage().withTable(tableId, null).withPlayer(playerId)
|
||||
));
|
||||
}
|
||||
|
||||
public void ccTournamentStarted(final UUID tournamentId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.START_TOURNAMENT, tournamentId, new TableClientMessage(tournamentId, playerId)));
|
||||
public void ccTournamentStarted(final UUID tableID, final UUID tournamentId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.START_TOURNAMENT,
|
||||
tournamentId,
|
||||
new TableClientMessage().withTable(tableID, null).withPlayer(playerId)
|
||||
));
|
||||
}
|
||||
|
||||
public void ccSideboard(final Deck deck, final UUID tableId, final int time, boolean limited) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.SIDEBOARD, tableId, new TableClientMessage(deck, tableId, time, limited)));
|
||||
sideboarding.put(tableId, deck);
|
||||
public void ccSideboard(final Deck deck, final UUID currentTableId, final UUID parentTableId, final int time, boolean limited) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.SIDEBOARD,
|
||||
currentTableId,
|
||||
new TableClientMessage().withDeck(deck).withTable(currentTableId, parentTableId).withTime(time).withFlag(limited)
|
||||
));
|
||||
sideboarding.put(currentTableId, 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 ccViewLimitedDeck(final Deck deck, final UUID currentTableId, final UUID parentTableId, final int time, boolean limited) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.VIEW_LIMITED_DECK,
|
||||
currentTableId,
|
||||
new TableClientMessage().withDeck(deck).withTable(currentTableId, parentTableId).withTime(time).withFlag(limited)
|
||||
));
|
||||
}
|
||||
|
||||
public void ccViewSideboard(final UUID tableId, final UUID gameId, final UUID targetPlayerId) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.VIEW_SIDEBOARD, tableId, new TableClientMessage(gameId, targetPlayerId)));
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.VIEW_SIDEBOARD,
|
||||
tableId,
|
||||
new TableClientMessage().withGame(gameId).withPlayer(targetPlayerId)
|
||||
));
|
||||
}
|
||||
|
||||
public void ccConstruct(final Deck deck, final UUID tableId, final int time) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.CONSTRUCT, tableId, new TableClientMessage(deck, tableId, time)));
|
||||
public void ccConstruct(final Deck deck, final UUID currentTableId, final UUID parentTableId, final int time) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.CONSTRUCT,
|
||||
currentTableId,
|
||||
new TableClientMessage().withDeck(deck).withTable(currentTableId, parentTableId).withTime(time)
|
||||
));
|
||||
}
|
||||
|
||||
public void ccShowTournament(final UUID tournamentId) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_TOURNAMENT, tournamentId));
|
||||
public void ccShowTournament(final UUID tableId, final UUID tournamentId) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.SHOW_TOURNAMENT,
|
||||
tournamentId,
|
||||
new TableClientMessage().withTable(tableId, null)
|
||||
));
|
||||
}
|
||||
|
||||
public void showUserMessage(final String title, String message) {
|
||||
|
|
@ -306,8 +343,12 @@ public class User {
|
|||
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
||||
}
|
||||
|
||||
public boolean ccWatchGame(final UUID gameId) {
|
||||
fireCallback(new ClientCallback(ClientCallbackMethod.WATCHGAME, gameId));
|
||||
public boolean ccWatchGame(final UUID currentTableId, final UUID parentTableId, final UUID gameId) {
|
||||
fireCallback(new ClientCallback(
|
||||
ClientCallbackMethod.WATCHGAME,
|
||||
gameId,
|
||||
new TableClientMessage().withTable(currentTableId, parentTableId)
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -367,7 +408,7 @@ public class User {
|
|||
|
||||
// active tables
|
||||
for (Entry<UUID, Table> entry : tables.entrySet()) {
|
||||
ccJoinedTable(entry.getValue().getRoomId(), entry.getValue().getId(), entry.getValue().isTournament());
|
||||
ccJoinedTable(entry.getValue().getRoomId(), entry.getValue().getId(), entry.getValue().getParentTableId(), entry.getValue().isTournament());
|
||||
}
|
||||
|
||||
// active tourneys
|
||||
|
|
@ -375,7 +416,7 @@ public class User {
|
|||
Entry<UUID, UUID> next = iterator.next();
|
||||
Optional<TournamentController> tournamentController = managerFactory.tournamentManager().getTournamentController(next.getValue());
|
||||
if (tournamentController.isPresent()) {
|
||||
ccTournamentStarted(next.getValue(), next.getKey());
|
||||
ccTournamentStarted(tournamentController.get().getTableId(), next.getValue(), next.getKey());
|
||||
tournamentController.get().rejoin(next.getKey());
|
||||
} else {
|
||||
iterator.remove(); // tournament has ended meanwhile
|
||||
|
|
@ -384,14 +425,20 @@ public class User {
|
|||
|
||||
// active games
|
||||
for (Entry<UUID, GameSessionPlayer> entry : gameSessions.entrySet()) {
|
||||
ccGameStarted(entry.getValue().getGameId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
managerFactory.gameManager().sendPlayerString(entry.getValue().getGameId(), userId, "");
|
||||
GameController gameController = managerFactory.gameManager().getGameController().getOrDefault(entry.getValue().getGameId(), null);
|
||||
if (gameController != null) {
|
||||
Table table = managerFactory.tableManager().getTable(gameController.getTableId());
|
||||
if (table != null) {
|
||||
ccGameStarted(table.getId(), table.getParentTableId(), entry.getValue().getGameId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
managerFactory.gameManager().sendPlayerString(entry.getValue().getGameId(), userId, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// active drafts
|
||||
for (Entry<UUID, DraftSession> entry : draftSessions.entrySet()) {
|
||||
ccDraftStarted(entry.getValue().getDraftId(), entry.getKey());
|
||||
ccDraftStarted(entry.getValue().getDraft().getTableId(), entry.getValue().getDraft().getId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
entry.getValue().update();
|
||||
}
|
||||
|
|
@ -403,9 +450,9 @@ public class User {
|
|||
|
||||
// active sideboarding
|
||||
for (Entry<UUID, Deck> entry : sideboarding.entrySet()) {
|
||||
Optional<TableController> controller = managerFactory.tableManager().getController(entry.getKey());
|
||||
if (controller.isPresent()) {
|
||||
ccSideboard(entry.getValue(), entry.getKey(), controller.get().getRemainingTime(), controller.get().getOptions().isLimited());
|
||||
TableController controller = managerFactory.tableManager().getController(entry.getKey()).orElse(null);
|
||||
if (controller != null) {
|
||||
ccSideboard(entry.getValue(), controller.getTable().getId(), controller.getTable().getParentTableId(), controller.getRemainingTime(), controller.getOptions().isLimited());
|
||||
} else {
|
||||
// Table is missing after connection was lost during sideboard.
|
||||
// Means other players were removed or conceded the game?
|
||||
|
|
|
|||
|
|
@ -156,8 +156,8 @@ public class DraftSession {
|
|||
return new DraftPickView(draft.getPlayer(playerId), timeout);
|
||||
}
|
||||
|
||||
public UUID getDraftId() {
|
||||
return draft.getId();
|
||||
public Draft getDraft() {
|
||||
return draft;
|
||||
}
|
||||
|
||||
public UUID getMarkedCard() {
|
||||
|
|
|
|||
|
|
@ -378,9 +378,14 @@ public class GameController implements GameCallback {
|
|||
if (session != null) {
|
||||
problemPlayerFixes = "re-send start game event";
|
||||
logger.warn("Send forced game start event for player " + player.getName() + " in gameId: " + game.getId());
|
||||
user.ccGameStarted(session.getGameId(), player.getId());
|
||||
session.init();
|
||||
managerFactory.gameManager().sendPlayerString(session.getGameId(), user.getId(), "");
|
||||
Table table = managerFactory.tableManager().getTable(this.tableId);
|
||||
if (table != null) {
|
||||
user.ccGameStarted(table.getId(), table.getParentTableId(), session.getGameId(), player.getId());
|
||||
session.init();
|
||||
managerFactory.gameManager().sendPlayerString(session.getGameId(), user.getId(), "");
|
||||
} else {
|
||||
logger.error("Can't find table on fix and re-send start game event: " + this.tableId);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Wrong code usage: session can't be null cause it created in forced joinGame already");
|
||||
//player.leave();
|
||||
|
|
@ -735,9 +740,9 @@ public class GameController implements GameCallback {
|
|||
|
||||
if (isSideboardOnly) {
|
||||
// sideboard data already sent in PlayerView, so no need to re-sent it TODO: re-sent deck instead?
|
||||
user.ccViewSideboard(tableId, game.getId(), targetPlayerId);
|
||||
user.ccViewSideboard(table.getId(), game.getId(), targetPlayerId);
|
||||
} else {
|
||||
user.ccViewLimitedDeck(deckSource.getDeckForViewer(), tableId, requestsOpen, true);
|
||||
user.ccViewLimitedDeck(deckSource.getDeckForViewer(), table.getId(), table.getParentTableId(), requestsOpen, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1410,4 +1415,8 @@ public class GameController implements GameCallback {
|
|||
|
||||
return fixedAlready;
|
||||
}
|
||||
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ public class TournamentController {
|
|||
try {
|
||||
TableManager tableManager = managerFactory.tableManager();
|
||||
Table table = tableManager.createTable(managerFactory.gamesRoomManager().getMainRoomId(), matchOptions);
|
||||
table.setTournamentSubTable(true);
|
||||
table.setTournamentSubTable(this.tableId);
|
||||
table.setTournament(tournament);
|
||||
table.setState(TableState.WAITING);
|
||||
TournamentPlayer player1 = pair.getPlayer1();
|
||||
|
|
@ -267,7 +267,7 @@ public class TournamentController {
|
|||
try {
|
||||
TableManager tableManager = managerFactory.tableManager();
|
||||
Table table = tableManager.createTable(managerFactory.gamesRoomManager().getMainRoomId(), matchOptions);
|
||||
table.setTournamentSubTable(true);
|
||||
table.setTournamentSubTable(this.tableId);
|
||||
table.setTournament(tournament);
|
||||
table.setState(TableState.WAITING);
|
||||
if (round.getAllPlayers().stream().allMatch(tournamentPlayer -> getPlayerUserId(tournamentPlayer.getPlayer().getId()).isPresent())) {
|
||||
|
|
@ -397,7 +397,7 @@ public class TournamentController {
|
|||
} else {
|
||||
managerFactory.draftManager().getController(tableId).ifPresent(draftController -> {
|
||||
draftController.getDraftSession(playerId).ifPresent(draftSession
|
||||
-> managerFactory.draftManager().kill(draftSession.getDraftId(), userId));
|
||||
-> managerFactory.draftManager().kill(draftSession.getDraft().getId(), userId));
|
||||
|
||||
});
|
||||
}
|
||||
|
|
@ -526,4 +526,8 @@ public class TournamentController {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class TournamentSession {
|
|||
setupTimeout(timeout);
|
||||
managerFactory.userManager().getUser(userId).ifPresent(user -> {
|
||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||
user.ccConstruct(tournament.getPlayer(playerId).getDeck(), tableId, remaining);
|
||||
user.ccConstruct(tournament.getPlayer(playerId).getDeck(), tableId, null, remaining);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
|
||||
package org.mage.test.stub;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.draft.Draft;
|
||||
|
|
@ -16,7 +12,13 @@ import mage.game.tournament.*;
|
|||
import mage.players.Player;
|
||||
import mage.players.PlayerType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Tests only
|
||||
*
|
||||
* @author Quercitron
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.io.Serializable;
|
|||
import java.util.*;
|
||||
import mage.cards.decks.DeckValidator;
|
||||
import mage.constants.TableState;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.TableEvent;
|
||||
import mage.game.events.TableEventSource;
|
||||
|
|
@ -15,7 +16,7 @@ import mage.players.Player;
|
|||
import mage.players.PlayerType;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public class Table implements Serializable {
|
||||
|
||||
|
|
@ -28,7 +29,10 @@ public class Table implements Serializable {
|
|||
private Seat[] seats;
|
||||
private int numSeats;
|
||||
private boolean isTournament;
|
||||
private boolean tournamentSubTable;
|
||||
|
||||
private boolean tournamentSubTable; // must assign by setTournamentSubTable only
|
||||
private UUID parentTableId = null; // original tourney table
|
||||
|
||||
private DeckValidator validator;
|
||||
private TableState state;
|
||||
private Match match;
|
||||
|
|
@ -87,6 +91,10 @@ public class Table implements Serializable {
|
|||
return tableId;
|
||||
}
|
||||
|
||||
public UUID getParentTableId() {
|
||||
return parentTableId;
|
||||
}
|
||||
|
||||
public UUID getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
|
@ -104,9 +112,10 @@ public class Table implements Serializable {
|
|||
setState(TableState.FINISHED);
|
||||
}
|
||||
|
||||
public void initDraft() {
|
||||
public void initDraft(Draft draft) {
|
||||
setState(TableState.DRAFTING);
|
||||
tournament.setStepStartTime(new Date());
|
||||
draft.setTableId(this.getId());
|
||||
}
|
||||
|
||||
public void construct() {
|
||||
|
|
@ -262,8 +271,9 @@ public class Table implements Serializable {
|
|||
return tournamentSubTable;
|
||||
}
|
||||
|
||||
public void setTournamentSubTable(boolean tournamentSubTable) {
|
||||
this.tournamentSubTable = tournamentSubTable;
|
||||
public void setTournamentSubTable(UUID parentTableId) {
|
||||
this.tournamentSubTable = true;
|
||||
this.parentTableId = parentTableId;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import mage.players.Player;
|
|||
*/
|
||||
public interface Draft extends MageItem, Serializable {
|
||||
|
||||
UUID getTableId();
|
||||
void setTableId(UUID tableId);
|
||||
|
||||
void addPlayer(Player player);
|
||||
Collection<DraftPlayer> getPlayers();
|
||||
boolean replacePlayer(Player oldPlayer, Player newPlayer);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public abstract class DraftImpl implements Draft {
|
|||
protected static final Logger logger = Logger.getLogger(DraftImpl.class);
|
||||
|
||||
protected final UUID id;
|
||||
protected UUID tableId = null;
|
||||
protected final Map<UUID, DraftPlayer> players = new LinkedHashMap<>();
|
||||
protected final PlayerList table = new PlayerList();
|
||||
protected int numberBoosters;
|
||||
|
|
@ -47,7 +48,7 @@ public abstract class DraftImpl implements Draft {
|
|||
protected ScheduledExecutorService boosterLoadingExecutor = null;
|
||||
|
||||
public DraftImpl(DraftOptions options, List<ExpansionSet> sets) {
|
||||
id = UUID.randomUUID();
|
||||
this.id = UUID.randomUUID();
|
||||
this.setCodes = options.getSetCodes();
|
||||
this.draftCube = options.getDraftCube();
|
||||
this.timing = options.getTiming();
|
||||
|
|
@ -60,6 +61,16 @@ public abstract class DraftImpl implements Draft {
|
|||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTableId(UUID tableId) {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayer(Player player) {
|
||||
DraftPlayer draftPlayer = new DraftPlayer(player);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
public abstract class TournamentImpl implements Tournament {
|
||||
|
||||
protected UUID id = UUID.randomUUID();
|
||||
protected UUID tableId = null; // assign on table create
|
||||
protected List<Round> rounds = new CopyOnWriteArrayList<>();
|
||||
protected Map<UUID, TournamentPlayer> players = new HashMap<>();
|
||||
protected TournamentOptions options;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue