mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Merge pull request #2992 from ingmargoudt/optionals
rewrites to optionals
This commit is contained in:
commit
bc81f7974a
28 changed files with 760 additions and 494 deletions
|
@ -1,9 +1,7 @@
|
||||||
package mage.client;
|
package mage.client;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.client.chat.LocalCommands;
|
import mage.client.chat.LocalCommands;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
|
@ -129,7 +127,7 @@ public final class SessionHandler {
|
||||||
return session.isTableOwner(roomId, tableId);
|
return session.isTableOwner(roomId, tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getTableChatId(UUID tableId) {
|
public static Optional<UUID> getTableChatId(UUID tableId) {
|
||||||
return session.getTableChatId(tableId);
|
return session.getTableChatId(tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +139,7 @@ public final class SessionHandler {
|
||||||
return session.startMatch(roomId, tableId);
|
return session.startMatch(roomId, tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getGameChatId(UUID gameId) {
|
public static Optional<UUID> getGameChatId(UUID gameId) {
|
||||||
return session.getGameChatId(gameId);
|
return session.getGameChatId(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +159,7 @@ public final class SessionHandler {
|
||||||
return session.joinTournament(tournamentId);
|
return session.joinTournament(tournamentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getTournamentChatId(UUID tournamentId) {
|
public static Optional<UUID> getTournamentChatId(UUID tournamentId) {
|
||||||
return session.getTournamentChatId(tournamentId);
|
return session.getTournamentChatId(tournamentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +253,7 @@ public final class SessionHandler {
|
||||||
session.sendCardMark(draftId, id);
|
session.sendCardMark(draftId, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getRoomChatId(UUID roomId) {
|
public static Optional<UUID> getRoomChatId(UUID roomId) {
|
||||||
return session.getRoomChatId(roomId);
|
return session.getRoomChatId(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +262,7 @@ public final class SessionHandler {
|
||||||
return session.getRoomUsers(roomId);
|
return session.getRoomUsers(roomId);
|
||||||
} catch (MageRemoteException e) {
|
} catch (MageRemoteException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +271,7 @@ public final class SessionHandler {
|
||||||
return session.getFinishedMatches(roomId);
|
return session.getFinishedMatches(roomId);
|
||||||
} catch (MageRemoteException e) {
|
} catch (MageRemoteException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +288,7 @@ public final class SessionHandler {
|
||||||
return session.getTables(roomId);
|
return session.getTables(roomId);
|
||||||
} catch (MageRemoteException e) {
|
} catch (MageRemoteException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +316,7 @@ public final class SessionHandler {
|
||||||
return session.sendPlayerManaType(gameId, playerId, data);
|
return session.sendPlayerManaType(gameId, playerId, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TableView getTable(UUID roomId, UUID tableId) {
|
public static Optional<TableView> getTable(UUID roomId, UUID tableId) {
|
||||||
return session.getTable(roomId, tableId);
|
return session.getTable(roomId, tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,19 +35,23 @@ package mage.client.dialog;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.chat.ChatPanelBasic;
|
import mage.client.chat.ChatPanelBasic;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.components.tray.MageTray;
|
import mage.client.components.tray.MageTray;
|
||||||
|
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER;
|
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
|
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
|
||||||
|
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.client.util.audio.AudioManager;
|
import mage.client.util.audio.AudioManager;
|
||||||
import mage.client.util.gui.TableUtil;
|
import mage.client.util.gui.TableUtil;
|
||||||
|
@ -58,7 +62,6 @@ import mage.view.TableView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class TableWaitingDialog extends MageDialog {
|
public class TableWaitingDialog extends MageDialog {
|
||||||
|
@ -159,9 +162,9 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
this.btnMoveDown.setVisible(false);
|
this.btnMoveDown.setVisible(false);
|
||||||
this.btnMoveUp.setVisible(false);
|
this.btnMoveUp.setVisible(false);
|
||||||
}
|
}
|
||||||
UUID chatId = SessionHandler.getTableChatId(tableId);
|
Optional<UUID> chatId = SessionHandler.getTableChatId(tableId);
|
||||||
if (chatId != null) {
|
if (chatId.isPresent()) {
|
||||||
this.chatPanel.connect(chatId);
|
this.chatPanel.connect(chatId.get());
|
||||||
updateTask.execute();
|
updateTask.execute();
|
||||||
this.setModal(false);
|
this.setModal(false);
|
||||||
this.setLocation(100, 100);
|
this.setLocation(100, 100);
|
||||||
|
@ -234,30 +237,30 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnMoveDown)
|
.addComponent(btnMoveDown)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnMoveUp)
|
.addComponent(btnMoveUp)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btnStart)
|
.addComponent(btnStart)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnCancel)
|
.addComponent(btnCancel)
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnMoveDown)
|
.addComponent(btnMoveDown)
|
||||||
.addComponent(btnMoveUp)
|
.addComponent(btnMoveUp)
|
||||||
.addComponent(btnCancel)
|
.addComponent(btnCancel)
|
||||||
.addComponent(btnStart))
|
.addComponent(btnStart))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
|
@ -416,8 +419,15 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
this.publish(SessionHandler.getTable(roomId, tableId));
|
SessionHandler.getTable(roomId, tableId).ifPresent(tableView -> {
|
||||||
Thread.sleep(1000);
|
|
||||||
|
this.publish(tableView);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
||||||
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
|
@ -99,7 +100,9 @@ import mage.client.dialog.PickChoiceDialog;
|
||||||
import mage.client.dialog.PickNumberDialog;
|
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.*;
|
import static mage.client.dialog.PreferencesDialog.*;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -116,11 +119,13 @@ import mage.constants.Constants;
|
||||||
import mage.constants.EnlargeMode;
|
import mage.constants.EnlargeMode;
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
|
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_FIRST;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_FIRST;
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_LAST;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_LAST;
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_FIRST;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_FIRST;
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_LAST;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_LAST;
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
|
||||||
|
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.events.PlayerQueryEvent;
|
import mage.game.events.PlayerQueryEvent;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.AbilityPickerView;
|
||||||
|
@ -139,7 +144,6 @@ import org.mage.card.arcane.CardPanel;
|
||||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com, nantuko8
|
* @author BetaSteward_at_googlemail.com, nantuko8
|
||||||
*/
|
*/
|
||||||
public final class GamePanel extends javax.swing.JPanel {
|
public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
@ -194,6 +198,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
TRIGGER_ORDER
|
TRIGGER_ORDER
|
||||||
}
|
}
|
||||||
|
|
||||||
// CardView popupMenu was invoked last
|
// CardView popupMenu was invoked last
|
||||||
private CardView cardViewPopupMenu;
|
private CardView cardViewPopupMenu;
|
||||||
|
|
||||||
|
@ -497,7 +502,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.pnlReplay.setVisible(false);
|
this.pnlReplay.setVisible(false);
|
||||||
|
|
||||||
this.gameChatPanel.clear();
|
this.gameChatPanel.clear();
|
||||||
this.gameChatPanel.connect(SessionHandler.getGameChatId(gameId));
|
SessionHandler.getGameChatId(gameId).ifPresent(uuid -> this.gameChatPanel.connect(uuid));
|
||||||
if (!SessionHandler.joinGame(gameId)) {
|
if (!SessionHandler.joinGame(gameId)) {
|
||||||
removeGame();
|
removeGame();
|
||||||
} else {
|
} else {
|
||||||
|
@ -529,7 +534,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
this.pnlReplay.setVisible(false);
|
this.pnlReplay.setVisible(false);
|
||||||
this.gameChatPanel.clear();
|
this.gameChatPanel.clear();
|
||||||
this.gameChatPanel.connect(SessionHandler.getGameChatId(gameId));
|
SessionHandler.getGameChatId(gameId).ifPresent(uuid ->
|
||||||
|
this.gameChatPanel.connect(uuid));
|
||||||
if (!SessionHandler.watchGame(gameId)) {
|
if (!SessionHandler.watchGame(gameId)) {
|
||||||
removeGame();
|
removeGame();
|
||||||
}
|
}
|
||||||
|
@ -1770,24 +1776,24 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pnlReplay.setLayout(gl_pnlReplay);
|
pnlReplay.setLayout(gl_pnlReplay);
|
||||||
gl_pnlReplay.setHorizontalGroup(
|
gl_pnlReplay.setHorizontalGroup(
|
||||||
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(gl_pnlReplay.createSequentialGroup()
|
.addGroup(gl_pnlReplay.createSequentialGroup()
|
||||||
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
);
|
);
|
||||||
gl_pnlReplay.setVerticalGroup(
|
gl_pnlReplay.setVerticalGroup(
|
||||||
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
|
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
|
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
|
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
|
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
|
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Game info panel (buttons on the right panel)
|
// Game info panel (buttons on the right panel)
|
||||||
|
@ -1861,8 +1867,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String[] phases = {"Untap", "Upkeep", "Draw", "Main1",
|
String[] phases = {"Untap", "Upkeep", "Draw", "Main1",
|
||||||
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
|
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
|
||||||
"Main2", "Cleanup", "Next_Turn"};
|
"Main2", "Cleanup", "Next_Turn"};
|
||||||
for (String name : phases) {
|
for (String name : phases) {
|
||||||
createPhaseButton(name, phasesMouseAdapter);
|
createPhaseButton(name, phasesMouseAdapter);
|
||||||
}
|
}
|
||||||
|
@ -1899,46 +1905,46 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
javax.swing.GroupLayout gl_helperHandButtonsStackArea = new javax.swing.GroupLayout(pnlHelperHandButtonsStackArea);
|
javax.swing.GroupLayout gl_helperHandButtonsStackArea = new javax.swing.GroupLayout(pnlHelperHandButtonsStackArea);
|
||||||
gl_helperHandButtonsStackArea.setHorizontalGroup(
|
gl_helperHandButtonsStackArea.setHorizontalGroup(
|
||||||
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
||||||
// .addGap(0)
|
// .addGap(0)
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
)
|
||||||
|
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
||||||
|
.addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
.addGap(0)
|
||||||
.addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
|
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
|
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
||||||
)
|
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||||
)
|
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(0)
|
)))
|
||||||
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
|
||||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
|
||||||
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
)))
|
|
||||||
);
|
);
|
||||||
gl_helperHandButtonsStackArea.setVerticalGroup(
|
gl_helperHandButtonsStackArea.setVerticalGroup(
|
||||||
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.TRAILING)
|
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.TRAILING)
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||||
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
)
|
|
||||||
//.addPreferredGap(ComponentPlacement.RELATED)
|
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
|
||||||
.addGap(2)
|
|
||||||
.addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addComponent(stackObjects, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
)
|
)
|
||||||
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
//.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
||||||
|
.addGap(2)
|
||||||
|
.addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(stackObjects, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
)
|
||||||
|
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
|
||||||
|
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
pnlHelperHandButtonsStackArea.setLayout(gl_helperHandButtonsStackArea);
|
pnlHelperHandButtonsStackArea.setLayout(gl_helperHandButtonsStackArea);
|
||||||
|
|
||||||
|
@ -1971,11 +1977,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE)
|
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
|
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2353,7 +2359,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
private mage.client.components.ability.AbilityPicker abilityPicker;
|
private mage.client.components.ability.AbilityPicker abilityPicker;
|
||||||
private mage.client.cards.BigCard bigCard;
|
private mage.client.cards.BigCard bigCard;
|
||||||
|
|
||||||
// private JPanel cancelSkipPanel;
|
// private JPanel cancelSkipPanel;
|
||||||
private KeyboundButton btnCancelSkip;
|
private KeyboundButton btnCancelSkip;
|
||||||
private KeyboundButton btnSkipToNextTurn; // F4
|
private KeyboundButton btnSkipToNextTurn; // F4
|
||||||
private KeyboundButton btnSkipToEndTurn; // F5
|
private KeyboundButton btnSkipToEndTurn; // F5
|
||||||
|
|
|
@ -480,7 +480,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
if (SessionHandler.getSession() != null) {
|
if (SessionHandler.getSession() != null) {
|
||||||
btnQuickStart.setVisible(SessionHandler.isTestMode());
|
btnQuickStart.setVisible(SessionHandler.isTestMode());
|
||||||
gameChooser.init();
|
gameChooser.init();
|
||||||
chatRoomId = SessionHandler.getRoomChatId(roomId);
|
chatRoomId = SessionHandler.getRoomChatId(roomId).orElse(null);
|
||||||
}
|
}
|
||||||
if (newTableDialog == null) {
|
if (newTableDialog == null) {
|
||||||
newTableDialog = new NewTableDialog();
|
newTableDialog = new NewTableDialog();
|
||||||
|
@ -520,7 +520,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
this.messages = serverMessages;
|
this.messages = serverMessages;
|
||||||
this.currentMessage = 0;
|
this.currentMessage = 0;
|
||||||
}
|
}
|
||||||
if (serverMessages == null || serverMessages.isEmpty()) {
|
if (serverMessages.isEmpty()) {
|
||||||
this.jPanelBottom.setVisible(false);
|
this.jPanelBottom.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
this.jPanelBottom.setVisible(true);
|
this.jPanelBottom.setVisible(true);
|
||||||
|
@ -1447,7 +1447,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
Collection<TableView> tables = SessionHandler.getTables(roomId);
|
Collection<TableView> tables = SessionHandler.getTables(roomId);
|
||||||
if (tables != null) {
|
if (!tables.isEmpty()) {
|
||||||
this.publish(tables);
|
this.publish(tables);
|
||||||
}
|
}
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
|
@ -1633,7 +1633,7 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
Collection<MatchView> matches = SessionHandler.getFinishedMatches(roomId);
|
Collection<MatchView> matches = SessionHandler.getFinishedMatches(roomId);
|
||||||
if (matches != null) {
|
if (!matches.isEmpty()) {
|
||||||
this.publish(matches);
|
this.publish(matches);
|
||||||
}
|
}
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.awt.event.ActionEvent;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -48,6 +49,8 @@ import javax.swing.Action;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
|
import mage.cards.o.Opt;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.chat.ChatPanelBasic;
|
import mage.client.chat.ChatPanelBasic;
|
||||||
|
@ -202,9 +205,9 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
public synchronized void showTournament(UUID tournamentId) {
|
public synchronized void showTournament(UUID tournamentId) {
|
||||||
this.tournamentId = tournamentId;
|
this.tournamentId = tournamentId;
|
||||||
// MageFrame.addTournament(tournamentId, this);
|
// MageFrame.addTournament(tournamentId, this);
|
||||||
UUID chatRoomId = SessionHandler.getTournamentChatId(tournamentId);
|
Optional<UUID> chatRoomId = SessionHandler.getTournamentChatId(tournamentId);
|
||||||
if (SessionHandler.joinTournament(tournamentId) && chatRoomId != null) {
|
if (SessionHandler.joinTournament(tournamentId) && chatRoomId.isPresent()) {
|
||||||
this.chatPanel1.connect(chatRoomId);
|
this.chatPanel1.connect(chatRoomId.get());
|
||||||
startTasks();
|
startTasks();
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.interfaces;
|
package mage.interfaces;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
|
@ -113,7 +114,7 @@ public interface MageServer {
|
||||||
|
|
||||||
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
TableView getTable(UUID roomId, UUID tableId) throws MageException;
|
Optional<TableView> getTable(UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
List<TableView> getTables(UUID roomId) throws MageException;
|
List<TableView> getTables(UUID roomId) throws MageException;
|
||||||
|
|
||||||
|
@ -124,13 +125,13 @@ public interface MageServer {
|
||||||
|
|
||||||
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
||||||
|
|
||||||
UUID getTableChatId(UUID tableId) throws MageException;
|
Optional<UUID> getTableChatId(UUID tableId) throws MageException;
|
||||||
|
|
||||||
UUID getGameChatId(UUID gameId) throws MageException;
|
Optional<UUID> getGameChatId(UUID gameId) throws MageException;
|
||||||
|
|
||||||
UUID getRoomChatId(UUID roomId) throws MageException;
|
Optional<UUID> getRoomChatId(UUID roomId) throws MageException;
|
||||||
|
|
||||||
UUID getTournamentChatId(UUID tournamentId) throws MageException;
|
Optional<UUID> getTournamentChatId(UUID tournamentId) throws MageException;
|
||||||
|
|
||||||
//room methods
|
//room methods
|
||||||
UUID getMainRoomId() throws MageException;
|
UUID getMainRoomId() throws MageException;
|
||||||
|
|
|
@ -600,7 +600,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getRoomChatId(UUID roomId) {
|
public Optional<UUID> getRoomChatId(UUID roomId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getRoomChatId(roomId);
|
return server.getRoomChatId(roomId);
|
||||||
|
@ -608,11 +608,11 @@ public class SessionImpl implements Session {
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getTableChatId(UUID tableId) {
|
public Optional<UUID> getTableChatId(UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getTableChatId(tableId);
|
return server.getTableChatId(tableId);
|
||||||
|
@ -620,11 +620,11 @@ public class SessionImpl implements Session {
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getGameChatId(UUID gameId) {
|
public Optional<UUID> getGameChatId(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getGameChatId(gameId);
|
return server.getGameChatId(gameId);
|
||||||
|
@ -634,11 +634,11 @@ public class SessionImpl implements Session {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleThrowable(t);
|
handleThrowable(t);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableView getTable(UUID roomId, UUID tableId) {
|
public Optional<TableView> getTable(UUID roomId, UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getTable(roomId, tableId);
|
return server.getTable(roomId, tableId);
|
||||||
|
@ -646,7 +646,7 @@ public class SessionImpl implements Session {
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -735,7 +735,7 @@ public class SessionImpl implements Session {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleThrowable(t);
|
handleThrowable(t);
|
||||||
}
|
}
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -750,7 +750,7 @@ public class SessionImpl implements Session {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleThrowable(t);
|
handleThrowable(t);
|
||||||
}
|
}
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -765,7 +765,7 @@ public class SessionImpl implements Session {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleThrowable(t);
|
handleThrowable(t);
|
||||||
}
|
}
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -784,7 +784,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getTournamentChatId(UUID tournamentId) {
|
public Optional<UUID> getTournamentChatId(UUID tournamentId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getTournamentChatId(tournamentId);
|
return server.getTournamentChatId(tournamentId);
|
||||||
|
@ -794,7 +794,7 @@ public class SessionImpl implements Session {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleThrowable(t);
|
handleThrowable(t);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1420,7 +1420,7 @@ public class SessionImpl implements Session {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleThrowable(t);
|
handleThrowable(t);
|
||||||
}
|
}
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
package mage.remote.interfaces;
|
package mage.remote.interfaces;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,13 +35,13 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public interface ChatSession {
|
public interface ChatSession {
|
||||||
|
|
||||||
UUID getRoomChatId(UUID roomId);
|
Optional<UUID> getRoomChatId(UUID roomId);
|
||||||
|
|
||||||
UUID getTableChatId(UUID tableId);
|
Optional<UUID> getTableChatId(UUID tableId);
|
||||||
|
|
||||||
UUID getGameChatId(UUID gameId);
|
Optional<UUID> getGameChatId(UUID gameId);
|
||||||
|
|
||||||
UUID getTournamentChatId(UUID tournamentId);
|
Optional<UUID> getTournamentChatId(UUID tournamentId);
|
||||||
|
|
||||||
boolean joinChat(UUID chatId);
|
boolean joinChat(UUID chatId);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import mage.remote.MageRemoteException;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import mage.view.TournamentView;
|
import mage.view.TournamentView;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +72,7 @@ public interface PlayerActions {
|
||||||
|
|
||||||
boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
|
boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
|
||||||
|
|
||||||
TableView getTable(UUID roomId, UUID tableId);
|
Optional<TableView> getTable(UUID roomId, UUID tableId);
|
||||||
|
|
||||||
TournamentView getTournament(UUID tournamentId) throws MageRemoteException;
|
TournamentView getTournament(UUID tournamentId) throws MageRemoteException;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ package mage.remote.interfaces;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.remote.MageRemoteException;
|
import mage.remote.MageRemoteException;
|
||||||
import mage.view.MatchView;
|
import mage.view.MatchView;
|
||||||
|
|
|
@ -51,7 +51,6 @@ import static javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN;
|
||||||
import static javax.swing.JTable.AUTO_RESIZE_OFF;
|
import static javax.swing.JTable.AUTO_RESIZE_OFF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class ConsolePanel extends javax.swing.JPanel {
|
public class ConsolePanel extends javax.swing.JPanel {
|
||||||
|
@ -148,12 +147,12 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
||||||
jPanel3.setLayout(jPanel3Layout);
|
jPanel3.setLayout(jPanel3Layout);
|
||||||
jPanel3Layout.setHorizontalGroup(
|
jPanel3Layout.setHorizontalGroup(
|
||||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
jPanel3Layout.setVerticalGroup(
|
jPanel3Layout.setVerticalGroup(
|
||||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE)
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
jPanel4.setVerifyInputWhenFocusTarget(false);
|
jPanel4.setVerifyInputWhenFocusTarget(false);
|
||||||
|
@ -181,61 +180,61 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
|
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
|
||||||
jPanel4.setLayout(jPanel4Layout);
|
jPanel4.setLayout(jPanel4Layout);
|
||||||
jPanel4Layout.setHorizontalGroup(
|
jPanel4Layout.setHorizontalGroup(
|
||||||
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnDisconnect)
|
.addComponent(btnDisconnect)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||||
.addComponent(btnEndSession)
|
.addComponent(btnEndSession)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnMuteUser))
|
.addComponent(btnMuteUser))
|
||||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||||
.addComponent(btnDeActivate)
|
.addComponent(btnDeActivate)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnLockUser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
.addComponent(btnLockUser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(lblMinutes)
|
.addComponent(lblMinutes)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
.addComponent(spinnerMuteDurationMinutes, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(spinnerMuteDurationMinutes, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
jPanel4Layout.setVerticalGroup(
|
jPanel4Layout.setVerticalGroup(
|
||||||
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnDisconnect)
|
.addComponent(btnDisconnect)
|
||||||
.addComponent(btnEndSession)
|
.addComponent(btnEndSession)
|
||||||
.addComponent(btnMuteUser))
|
.addComponent(btnMuteUser))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnDeActivate)
|
.addComponent(btnDeActivate)
|
||||||
.addComponent(btnLockUser)))
|
.addComponent(btnLockUser)))
|
||||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||||
.addGap(16, 16, 16)
|
.addGap(16, 16, 16)
|
||||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(lblMinutes)
|
.addComponent(lblMinutes)
|
||||||
.addComponent(spinnerMuteDurationMinutes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
.addComponent(spinnerMuteDurationMinutes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||||
jPanel1.setLayout(jPanel1Layout);
|
jPanel1.setLayout(jPanel1Layout);
|
||||||
jPanel1Layout.setHorizontalGroup(
|
jPanel1Layout.setHorizontalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
jPanel1Layout.setVerticalGroup(
|
jPanel1Layout.setVerticalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
|
||||||
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGap(0, 0, 0)
|
.addGap(0, 0, 0)
|
||||||
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(0, 0, 0))
|
.addGap(0, 0, 0))
|
||||||
);
|
);
|
||||||
|
|
||||||
jSplitPane1.setLeftComponent(jPanel1);
|
jSplitPane1.setLeftComponent(jPanel1);
|
||||||
|
@ -246,12 +245,12 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
|
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
|
||||||
jPanel5.setLayout(jPanel5Layout);
|
jPanel5.setLayout(jPanel5Layout);
|
||||||
jPanel5Layout.setHorizontalGroup(
|
jPanel5Layout.setHorizontalGroup(
|
||||||
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
|
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
jPanel5Layout.setVerticalGroup(
|
jPanel5Layout.setVerticalGroup(
|
||||||
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
|
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
btnRemoveTable.setText("Remove Table");
|
btnRemoveTable.setText("Remove Table");
|
||||||
|
@ -260,32 +259,32 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
|
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
|
||||||
jPanel6.setLayout(jPanel6Layout);
|
jPanel6.setLayout(jPanel6Layout);
|
||||||
jPanel6Layout.setHorizontalGroup(
|
jPanel6Layout.setHorizontalGroup(
|
||||||
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel6Layout.createSequentialGroup()
|
.addGroup(jPanel6Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnRemoveTable)
|
.addComponent(btnRemoveTable)
|
||||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
jPanel6Layout.setVerticalGroup(
|
jPanel6Layout.setVerticalGroup(
|
||||||
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel6Layout.createSequentialGroup()
|
.addGroup(jPanel6Layout.createSequentialGroup()
|
||||||
.addComponent(btnRemoveTable)
|
.addComponent(btnRemoveTable)
|
||||||
.addContainerGap(31, Short.MAX_VALUE))
|
.addContainerGap(31, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
||||||
jPanel2.setLayout(jPanel2Layout);
|
jPanel2.setLayout(jPanel2Layout);
|
||||||
jPanel2Layout.setHorizontalGroup(
|
jPanel2Layout.setHorizontalGroup(
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
jPanel2Layout.setVerticalGroup(
|
jPanel2Layout.setVerticalGroup(
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||||
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGap(0, 0, 0)
|
.addGap(0, 0, 0)
|
||||||
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
);
|
);
|
||||||
|
|
||||||
jSplitPane1.setRightComponent(jPanel2);
|
jSplitPane1.setRightComponent(jPanel2);
|
||||||
|
@ -293,12 +292,12 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING)
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING)
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
);
|
);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
@ -558,7 +557,7 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
|
||||||
if (peopleIps.get(s) == null) {
|
if (peopleIps.get(s) == null) {
|
||||||
logger.warn("Found new user: " + u1.getUserName() + ',' + u1.getHost());
|
logger.warn("Found new user: " + u1.getUserName() + ',' + u1.getHost());
|
||||||
peopleIps.put(s, "1");
|
peopleIps.put(s, "1");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,12 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public TableView execute() throws MageException {
|
public TableView execute() throws MageException {
|
||||||
try {
|
try {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session to found : " + sessionId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
Optional<User> _user = UserManager.instance.getUser(userId);
|
Optional<User> _user = UserManager.instance.getUser(userId);
|
||||||
if (!_user.isPresent()) {
|
if (!_user.isPresent()) {
|
||||||
logger.error("User for session not found. session = " + sessionId);
|
logger.error("User for session not found. session = " + sessionId);
|
||||||
|
@ -247,9 +252,14 @@ public class MageServerImpl implements MageServer {
|
||||||
user.showUserMessage("Create tournament", message);
|
user.showUserMessage("Create tournament", message);
|
||||||
throw new MageException("No message");
|
throw new MageException("No message");
|
||||||
}
|
}
|
||||||
TableView table = GamesRoomManager.instance.getRoom(roomId).createTournamentTable(userId, options);
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
logger.debug("Tournament table " + table.getTableId() + " created");
|
if (!room.isPresent()) {
|
||||||
return table;
|
|
||||||
|
} else {
|
||||||
|
TableView table = room.get().createTournamentTable(userId, options);
|
||||||
|
logger.debug("Tournament table " + table.getTableId() + " created");
|
||||||
|
return table;
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
|
@ -261,8 +271,13 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void removeTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public void removeTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
execute("removeTable", sessionId, () -> {
|
execute("removeTable", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
TableManager.instance.removeTable(userId, tableId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
TableManager.instance.removeTable(userId, tableId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,13 +286,23 @@ public class MageServerImpl implements MageServer {
|
||||||
return executeWithResult("joinTable", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("joinTable", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
logger.debug(name + " joins tableId: " + tableId);
|
logger.debug(name + " joins tableId: " + tableId);
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId);
|
logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return GamesRoomManager.instance.getRoom(roomId).joinTable(userId, tableId, name, playerType, skill, deckList, password);
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
|
if (!room.isPresent()) {
|
||||||
|
logger.error("room not found : " + roomId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return room.get().joinTable(userId, tableId, name, playerType, skill, deckList, password);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -288,7 +313,12 @@ public class MageServerImpl implements MageServer {
|
||||||
return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
user.ifPresent(user1 -> logger.trace("join tourn. tableId: " + tableId + ' ' + name));
|
user.ifPresent(user1 -> logger.trace("join tourn. tableId: " + tableId + ' ' + name));
|
||||||
|
@ -297,7 +327,11 @@ public class MageServerImpl implements MageServer {
|
||||||
logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId);
|
logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return GamesRoomManager.instance.getRoom(roomId).joinTournamentTable(userId, tableId, name, playerType, skill, deckList, password);
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
|
if (room.isPresent()) {
|
||||||
|
return room.get().joinTournamentTable(userId, tableId, name, playerType, skill, deckList, password);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -308,10 +342,16 @@ public class MageServerImpl implements MageServer {
|
||||||
return executeWithResult("submitDeck", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("submitDeck", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
boolean ret = TableManager.instance.submitDeck(userId, tableId, deckList);
|
if (!session.isPresent()) {
|
||||||
logger.debug("Session " + sessionId + " submitted deck");
|
logger.error("Session not found : " + sessionId);
|
||||||
return ret;
|
return false;
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
boolean ret = TableManager.instance.submitDeck(userId, tableId, deckList);
|
||||||
|
logger.debug("Session " + sessionId + " submitted deck");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -319,9 +359,15 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void updateDeck(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException, GameException {
|
public void updateDeck(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException, GameException {
|
||||||
execute("updateDeck", sessionId, () -> {
|
execute("updateDeck", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
TableManager.instance.updateDeck(userId, tableId, deckList);
|
if (!session.isPresent()) {
|
||||||
logger.trace("Session " + sessionId + " updated deck");
|
logger.error("Session not found : " + sessionId);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
TableManager.instance.updateDeck(userId, tableId, deckList);
|
||||||
|
logger.trace("Session " + sessionId + " updated deck");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,11 +375,11 @@ public class MageServerImpl implements MageServer {
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public List<TableView> getTables(UUID roomId) throws MageException {
|
public List<TableView> getTables(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
GamesRoom room = GamesRoomManager.instance.getRoom(roomId);
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
if (room != null) {
|
if (room.isPresent()) {
|
||||||
return room.getTables();
|
return room.get().getTables();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
|
@ -345,47 +391,44 @@ public class MageServerImpl implements MageServer {
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public List<MatchView> getFinishedMatches(UUID roomId) throws MageException {
|
public List<MatchView> getFinishedMatches(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
GamesRoom room = GamesRoomManager.instance.getRoom(roomId);
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
if (room != null) {
|
if (room.isPresent()) {
|
||||||
return room.getFinished();
|
return room.get().getFinished();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RoomUsersView> getRoomUsers(UUID roomId) throws MageException {
|
public List<RoomUsersView> getRoomUsers(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
GamesRoom room = GamesRoomManager.instance.getRoom(roomId);
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
if (room != null) {
|
if (room.isPresent()) {
|
||||||
return room.getRoomUsersInfo();
|
return room.get().getRoomUsersInfo();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public TableView getTable(UUID roomId, UUID tableId) throws MageException {
|
public Optional<TableView> getTable(UUID roomId, UUID tableId) throws MageException {
|
||||||
try {
|
try {
|
||||||
GamesRoom room = GamesRoomManager.instance.getRoom(roomId);
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
if (room != null) {
|
return room.flatMap(r -> r.getTable(tableId));
|
||||||
return room.getTable(tableId);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -405,12 +448,22 @@ public class MageServerImpl implements MageServer {
|
||||||
// }
|
// }
|
||||||
@Override
|
@Override
|
||||||
public boolean startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
if (!TableManager.instance.getController(tableId).changeTableStateToStarting()) {
|
Optional<TableController> controller = TableManager.instance.getController(tableId);
|
||||||
|
if (!controller.isPresent()) {
|
||||||
|
logger.error("table not found : " + tableId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!controller.get().changeTableStateToStarting()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
execute("startMatch", sessionId, () -> {
|
execute("startMatch", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
TableManager.instance.startMatch(userId, roomId, tableId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
TableManager.instance.startMatch(userId, roomId, tableId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -427,12 +480,22 @@ public class MageServerImpl implements MageServer {
|
||||||
// }
|
// }
|
||||||
@Override
|
@Override
|
||||||
public boolean startTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean startTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
if (!TableManager.instance.getController(tableId).changeTableStateToStarting()) {
|
Optional<TableController> controller = TableManager.instance.getController(tableId);
|
||||||
|
if (!controller.isPresent()) {
|
||||||
|
logger.error("table not found : " + tableId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!controller.get().changeTableStateToStarting()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
execute("startTournament", sessionId, () -> {
|
execute("startTournament", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
TableManager.instance.startTournament(userId, roomId, tableId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
TableManager.instance.startTournament(userId, roomId, tableId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -463,8 +526,13 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void joinChat(final UUID chatId, final String sessionId, final String userName) throws MageException {
|
public void joinChat(final UUID chatId, final String sessionId, final String userName) throws MageException {
|
||||||
execute("joinChat", sessionId, () -> {
|
execute("joinChat", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
ChatManager.instance.joinChat(chatId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
ChatManager.instance.joinChat(chatId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,8 +540,13 @@ public class MageServerImpl implements MageServer {
|
||||||
public void leaveChat(final UUID chatId, final String sessionId) throws MageException {
|
public void leaveChat(final UUID chatId, final String sessionId) throws MageException {
|
||||||
execute("leaveChat", sessionId, () -> {
|
execute("leaveChat", sessionId, () -> {
|
||||||
if (chatId != null) {
|
if (chatId != null) {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
ChatManager.instance.leaveChat(chatId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
ChatManager.instance.leaveChat(chatId, userId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.warn("The chatId is null. sessionId = " + sessionId);
|
logger.warn("The chatId is null. sessionId = " + sessionId);
|
||||||
}
|
}
|
||||||
|
@ -493,13 +566,18 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getRoomChatId(UUID roomId) throws MageException {
|
public Optional<UUID> getRoomChatId(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return GamesRoomManager.instance.getRoom(roomId).getChatId();
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
|
if (!room.isPresent()) {
|
||||||
|
logger.error("roomId not found : " + roomId);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of(room.get().getChatId());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -507,8 +585,14 @@ public class MageServerImpl implements MageServer {
|
||||||
return executeWithResult("isTableOwner", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("isTableOwner", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() {
|
public Boolean execute() {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
return TableManager.instance.isTableOwner(tableId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
return TableManager.instance.isTableOwner(tableId, userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -516,63 +600,99 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void swapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException {
|
public void swapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException {
|
||||||
execute("swapSeats", sessionId, () -> {
|
execute("swapSeats", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
TableManager.instance.swapSeats(tableId, userId, seatNum1, seatNum2);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
TableManager.instance.swapSeats(tableId, userId, seatNum1, seatNum2);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean leaveTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean leaveTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
TableState tableState = TableManager.instance.getController(tableId).getTableState();
|
Optional<TableController> tableController = TableManager.instance.getController(tableId);
|
||||||
if (tableState != TableState.WAITING && tableState != TableState.READY_TO_START) {
|
if (tableController.isPresent()) {
|
||||||
// table was already started, so player can't leave anymore now
|
TableState tableState = tableController.get().getTableState();
|
||||||
return false;
|
if (tableState != TableState.WAITING && tableState != TableState.READY_TO_START) {
|
||||||
|
// table was already started, so player can't leave anymore now
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
execute("leaveTable", sessionId, () -> {
|
||||||
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
|
if (!room.isPresent()) {
|
||||||
|
logger.error("room not found : " + roomId);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
room.get().leaveTable(userId, tableId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
logger.error("table not found : " + tableId);
|
||||||
}
|
}
|
||||||
execute("leaveTable", sessionId, () -> {
|
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
|
||||||
GamesRoomManager.instance.getRoom(roomId).leaveTable(userId, tableId);
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getTableChatId(UUID tableId) throws MageException {
|
public Optional<UUID> getTableChatId(UUID tableId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return TableManager.instance.getChatId(tableId);
|
return TableManager.instance.getChatId(tableId);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void joinGame(final UUID gameId, final String sessionId) throws MageException {
|
public void joinGame(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("joinGame", sessionId, () -> {
|
execute("joinGame", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
GameManager.instance.joinGame(gameId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
GameManager.instance.joinGame(gameId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void joinDraft(final UUID draftId, final String sessionId) throws MageException {
|
public void joinDraft(final UUID draftId, final String sessionId) throws MageException {
|
||||||
execute("joinDraft", sessionId, () -> {
|
execute("joinDraft", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
DraftManager.instance.joinDraft(draftId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
DraftManager.instance.joinDraft(draftId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void joinTournament(final UUID tournamentId, final String sessionId) throws MageException {
|
public void joinTournament(final UUID tournamentId, final String sessionId) throws MageException {
|
||||||
execute("joinTournament", sessionId, () -> {
|
execute("joinTournament", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
TournamentManager.instance.joinTournament(tournamentId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
TournamentManager.instance.joinTournament(tournamentId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getGameChatId(UUID gameId) throws MageException {
|
public Optional<UUID> getGameChatId(UUID gameId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return GameManager.instance.getChatId(gameId);
|
return GameManager.instance.getChatId(gameId);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -583,13 +703,13 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getTournamentChatId(UUID tournamentId) throws MageException {
|
public Optional<UUID> getTournamentChatId(UUID tournamentId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return TournamentManager.instance.getChatId(tournamentId);
|
return TournamentManager.instance.getChatId(tournamentId);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -661,11 +781,12 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void sendCardMark(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException {
|
public void sendCardMark(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException {
|
||||||
execute("sendCardMark", sessionId, () -> {
|
execute("sendCardMark", sessionId, () -> {
|
||||||
Session session = SessionManager.instance.getSession(sessionId);
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
if (session != null) {
|
if (!session.isPresent()) {
|
||||||
DraftManager.instance.sendCardMark(draftId, session.getUserId(), cardPick);
|
logger.error("Session not found : " + sessionId);
|
||||||
} else {
|
} else {
|
||||||
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
UUID userId = session.get().getUserId();
|
||||||
|
DraftManager.instance.sendCardMark(draftId, userId, cardPick);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -673,11 +794,13 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void quitMatch(final UUID gameId, final String sessionId) throws MageException {
|
public void quitMatch(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("quitMatch", sessionId, () -> {
|
execute("quitMatch", sessionId, () -> {
|
||||||
Session session = SessionManager.instance.getSession(sessionId);
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
if (session != null) {
|
if (!session.isPresent()) {
|
||||||
GameManager.instance.quitMatch(gameId, session.getUserId());
|
logger.error("Session not found : " + sessionId);
|
||||||
} else {
|
} else {
|
||||||
logger.error("Session not found sessionId: " + sessionId + " gameId:" + gameId);
|
UUID userId = session.get().getUserId();
|
||||||
|
|
||||||
|
GameManager.instance.quitMatch(gameId, userId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -685,11 +808,13 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void quitTournament(final UUID tournamentId, final String sessionId) throws MageException {
|
public void quitTournament(final UUID tournamentId, final String sessionId) throws MageException {
|
||||||
execute("quitTournament", sessionId, () -> {
|
execute("quitTournament", sessionId, () -> {
|
||||||
Session session = SessionManager.instance.getSession(sessionId);
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
if (session != null) {
|
if (!session.isPresent()) {
|
||||||
TournamentManager.instance.quit(tournamentId, session.getUserId());
|
logger.error("Session not found : " + sessionId);
|
||||||
} else {
|
} else {
|
||||||
logger.error("Session not found sessionId: " + sessionId + " tournamentId:" + tournamentId);
|
UUID userId = session.get().getUserId();
|
||||||
|
|
||||||
|
TournamentManager.instance.quit(tournamentId, userId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -697,16 +822,17 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void quitDraft(final UUID draftId, final String sessionId) throws MageException {
|
public void quitDraft(final UUID draftId, final String sessionId) throws MageException {
|
||||||
execute("quitDraft", sessionId, () -> {
|
execute("quitDraft", sessionId, () -> {
|
||||||
Session session = SessionManager.instance.getSession(sessionId);
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
if (session == null) {
|
if (!session.isPresent()) {
|
||||||
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
logger.error("Session not found : " + sessionId);
|
||||||
return;
|
} else {
|
||||||
}
|
UUID userId = session.get().getUserId();
|
||||||
UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId();
|
UUID tableId = DraftManager.instance.getControllerByDraftId(draftId).getTableId();
|
||||||
Table table = TableManager.instance.getTable(tableId);
|
Table table = TableManager.instance.getTable(tableId);
|
||||||
if (table.isTournament()) {
|
if (table.isTournament()) {
|
||||||
UUID tournamentId = table.getTournament().getId();
|
UUID tournamentId = table.getTournament().getId();
|
||||||
TournamentManager.instance.quit(tournamentId, session.getUserId());
|
TournamentManager.instance.quit(tournamentId, userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -714,12 +840,13 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void sendPlayerAction(final PlayerAction playerAction, final UUID gameId, final String sessionId, final Object data) throws MageException {
|
public void sendPlayerAction(final PlayerAction playerAction, final UUID gameId, final String sessionId, final Object data) throws MageException {
|
||||||
execute("sendPlayerAction", sessionId, () -> {
|
execute("sendPlayerAction", sessionId, () -> {
|
||||||
Session session = SessionManager.instance.getSession(sessionId);
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
if (session == null) {
|
if (!session.isPresent()) {
|
||||||
logger.error("Session not found sessionId: " + sessionId + " gameId:" + gameId);
|
logger.error("Session not found : " + sessionId);
|
||||||
return;
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
GameManager.instance.sendPlayerAction(playerAction, gameId, userId, data);
|
||||||
}
|
}
|
||||||
GameManager.instance.sendPlayerAction(playerAction, gameId, session.getUserId(), data);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,8 +855,18 @@ public class MageServerImpl implements MageServer {
|
||||||
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
return GamesRoomManager.instance.getRoom(roomId).watchTable(userId, tableId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
if (GamesRoomManager.instance.getRoom(roomId).isPresent()) {
|
||||||
|
return GamesRoomManager.instance.getRoom(roomId).get().watchTable(userId, tableId);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -742,19 +879,29 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void watchGame(final UUID gameId, final String sessionId) throws MageException {
|
public void watchGame(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("watchGame", sessionId, () -> {
|
execute("watchGame", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
GameManager.instance.watchGame(gameId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
GameManager.instance.watchGame(gameId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopWatching(final UUID gameId, final String sessionId) throws MageException {
|
public void stopWatching(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("stopWatching", sessionId, () -> {
|
execute("stopWatching", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
if (!session.isPresent()) {
|
||||||
GameManager.instance.stopWatching(gameId, userId);
|
logger.error("Session not found : " + sessionId);
|
||||||
user.removeGameWatchInfo(gameId);
|
} else {
|
||||||
});
|
UUID userId = session.get().getUserId();
|
||||||
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
|
GameManager.instance.stopWatching(gameId, userId);
|
||||||
|
user.removeGameWatchInfo(gameId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -762,48 +909,78 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void replayGame(final UUID gameId, final String sessionId) throws MageException {
|
public void replayGame(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("replayGame", sessionId, () -> {
|
execute("replayGame", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
ReplayManager.instance.replayGame(gameId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
ReplayManager.instance.replayGame(gameId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startReplay(final UUID gameId, final String sessionId) throws MageException {
|
public void startReplay(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("startReplay", sessionId, () -> {
|
execute("startReplay", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
ReplayManager.instance.startReplay(gameId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
ReplayManager.instance.startReplay(gameId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopReplay(final UUID gameId, final String sessionId) throws MageException {
|
public void stopReplay(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("stopReplay", sessionId, () -> {
|
execute("stopReplay", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
ReplayManager.instance.stopReplay(gameId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
ReplayManager.instance.stopReplay(gameId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nextPlay(final UUID gameId, final String sessionId) throws MageException {
|
public void nextPlay(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("nextPlay", sessionId, () -> {
|
execute("nextPlay", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
ReplayManager.instance.nextPlay(gameId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
ReplayManager.instance.nextPlay(gameId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void previousPlay(final UUID gameId, final String sessionId) throws MageException {
|
public void previousPlay(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("previousPlay", sessionId, () -> {
|
execute("previousPlay", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
ReplayManager.instance.previousPlay(gameId, userId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
ReplayManager.instance.previousPlay(gameId, userId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void skipForward(final UUID gameId, final String sessionId, final int moves) throws MageException {
|
public void skipForward(final UUID gameId, final String sessionId, final int moves) throws MageException {
|
||||||
execute("skipForward", sessionId, () -> {
|
execute("skipForward", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
ReplayManager.instance.skipForward(gameId, userId, moves);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
ReplayManager.instance.skipForward(gameId, userId, moves);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,8 +1009,13 @@ public class MageServerImpl implements MageServer {
|
||||||
public void cheat(final UUID gameId, final String sessionId, final UUID playerId, final DeckCardLists deckList) throws MageException {
|
public void cheat(final UUID gameId, final String sessionId, final UUID playerId, final DeckCardLists deckList) throws MageException {
|
||||||
execute("cheat", sessionId, () -> {
|
execute("cheat", sessionId, () -> {
|
||||||
if (testMode) {
|
if (testMode) {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
GameManager.instance.cheat(gameId, userId, playerId, deckList);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
GameManager.instance.cheat(gameId, userId, playerId, deckList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -844,8 +1026,13 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() {
|
public Boolean execute() {
|
||||||
if (testMode) {
|
if (testMode) {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
return GameManager.instance.cheat(gameId, userId, playerId, cardName);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
return GameManager.instance.cheat(gameId, userId, playerId, cardName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -957,8 +1144,13 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public void removeTable(final String sessionId, final UUID tableId) throws MageException {
|
public void removeTable(final String sessionId, final UUID tableId) throws MageException {
|
||||||
execute("removeTable", sessionId, () -> {
|
execute("removeTable", sessionId, () -> {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
TableManager.instance.removeTable(userId, tableId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
TableManager.instance.removeTable(userId, tableId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,8 +1163,13 @@ public class MageServerImpl implements MageServer {
|
||||||
public void sendFeedbackMessage(final String sessionId, final String username, final String title, final String type, final String message, final String email) throws MageException {
|
public void sendFeedbackMessage(final String sessionId, final String username, final String title, final String type, final String message, final String email) throws MageException {
|
||||||
if (title != null && message != null) {
|
if (title != null && message != null) {
|
||||||
execute("sendFeedbackMessage", sessionId, () -> {
|
execute("sendFeedbackMessage", sessionId, () -> {
|
||||||
String host = SessionManager.instance.getSession(sessionId).getHost();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
FeedbackServiceImpl.instance.feedback(username, title, type, message, email, host);
|
if (!session.isPresent()) {
|
||||||
|
logger.error(String.format("Session not found: %s", sessionId));
|
||||||
|
} else {
|
||||||
|
FeedbackServiceImpl.instance.feedback(username, title, type, message, email, session.get().getHost());
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1104,8 +1301,14 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameView execute() throws MageException {
|
public GameView execute() throws MageException {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
return GameManager.instance.getGameView(gameId, userId, playerId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
return GameManager.instance.getGameView(gameId, userId, playerId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1120,8 +1323,14 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
return TableManager.instance.watchTable(userId, tableId);
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
|
return TableManager.instance.watchTable(userId, tableId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1140,9 +1349,9 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DraftPickView execute() {
|
public DraftPickView execute() {
|
||||||
Session session = SessionManager.instance.getSession(sessionId);
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
if (session != null) {
|
if (session.isPresent()) {
|
||||||
return DraftManager.instance.sendCardPick(draftId, session.getUserId(), cardPick, hiddenCards);
|
return DraftManager.instance.sendCardPick(draftId, session.get().getUserId(), cardPick, hiddenCards);
|
||||||
} else {
|
} else {
|
||||||
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1372,12 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableView execute() throws MageException {
|
public TableView execute() throws MageException {
|
||||||
UUID userId = SessionManager.instance.getSession(sessionId).getUserId();
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
Optional<User> _user = UserManager.instance.getUser(userId);
|
Optional<User> _user = UserManager.instance.getUser(userId);
|
||||||
if (!_user.isPresent()) {
|
if (!_user.isPresent()) {
|
||||||
logger.error("User for session not found. session = " + sessionId);
|
logger.error("User for session not found. session = " + sessionId);
|
||||||
|
@ -1183,13 +1397,19 @@ public class MageServerImpl implements MageServer {
|
||||||
throw new MageException("No message");
|
throw new MageException("No message");
|
||||||
}
|
}
|
||||||
|
|
||||||
TableView table = GamesRoomManager.instance.getRoom(roomId).createTable(userId, options);
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(roomId);
|
||||||
if (logger.isDebugEnabled()) {
|
if (room.isPresent()) {
|
||||||
logger.debug("TABLE created - tableId: " + table.getTableId() + ' ' + table.getTableName());
|
TableView table = room.get().createTable(userId, options);
|
||||||
logger.debug("- " + user.getName() + " userId: " + user.getId());
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("- chatId: " + TableManager.instance.getChatId(table.getTableId()));
|
logger.debug("TABLE created - tableId: " + table.getTableId() + ' ' + table.getTableName());
|
||||||
|
logger.debug("- " + user.getName() + " userId: " + user.getId());
|
||||||
|
logger.debug("- chatId: " + TableManager.instance.getChatId(table.getTableId()));
|
||||||
|
}
|
||||||
|
return table;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return table;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,17 +263,20 @@ public final class Main {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleConnectionException(Throwable throwable, Client client) {
|
public void handleConnectionException(Throwable throwable, Client client) {
|
||||||
Session session = SessionManager.instance.getSession(client.getSessionId());
|
String sessionId = client.getSessionId();
|
||||||
if (session != null) {
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
UUID userId = session.get().getUserId();
|
||||||
StringBuilder sessionInfo = new StringBuilder();
|
StringBuilder sessionInfo = new StringBuilder();
|
||||||
Optional<User> user = UserManager.instance.getUser(session.getUserId());
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
sessionInfo.append(user.get().getName()).append(" [").append(user.get().getGameInfo()).append(']');
|
sessionInfo.append(user.get().getName()).append(" [").append(user.get().getGameInfo()).append(']');
|
||||||
} else {
|
} else {
|
||||||
sessionInfo.append("[user missing] ");
|
sessionInfo.append("[user missing] ");
|
||||||
}
|
}
|
||||||
sessionInfo.append(" at ").append(session.getHost()).append(" sessionId: ").append(session.getId());
|
sessionInfo.append(" at ").append(session.get().getHost()).append(" sessionId: ").append(session.get().getId());
|
||||||
if (throwable instanceof ClientDisconnectedException) {
|
if (throwable instanceof ClientDisconnectedException) {
|
||||||
// Seems like the random diconnects from public server land here and should not be handled as explicit disconnects
|
// Seems like the random diconnects from public server land here and should not be handled as explicit disconnects
|
||||||
// So it should be possible to reconnect to server and continue games if DisconnectReason is set to LostConnection
|
// So it should be possible to reconnect to server and continue games if DisconnectReason is set to LostConnection
|
||||||
|
@ -372,7 +375,12 @@ public final class Main {
|
||||||
} else {
|
} else {
|
||||||
host = "localhost";
|
host = "localhost";
|
||||||
}
|
}
|
||||||
SessionManager.instance.getSession(sessionId).setHost(host);
|
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||||
|
if (!session.isPresent()) {
|
||||||
|
logger.error("Session not found : " + sessionId);
|
||||||
|
} else {
|
||||||
|
session.get().setHost(host);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.rmi.Remote;
|
import java.rmi.Remote;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,16 +27,12 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.constants.Constants;
|
import mage.constants.Constants;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.players.net.UserGroup;
|
import mage.players.net.UserGroup;
|
||||||
|
import mage.server.game.GamesRoom;
|
||||||
import mage.server.game.GamesRoomManager;
|
import mage.server.game.GamesRoomManager;
|
||||||
import mage.server.util.ConfigSettings;
|
import mage.server.util.ConfigSettings;
|
||||||
import mage.server.util.SystemUtil;
|
import mage.server.util.SystemUtil;
|
||||||
|
@ -47,8 +43,13 @@ import org.jboss.remoting.callback.Callback;
|
||||||
import org.jboss.remoting.callback.HandleCallbackException;
|
import org.jboss.remoting.callback.HandleCallbackException;
|
||||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class Session {
|
public class Session {
|
||||||
|
@ -129,7 +130,7 @@ public class Session {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static private String validateUserName(String userName) {
|
private static String validateUserName(String userName) {
|
||||||
if (userName.equals("Admin")) {
|
if (userName.equals("Admin")) {
|
||||||
return "User name Admin already in use";
|
return "User name Admin already in use";
|
||||||
}
|
}
|
||||||
|
@ -152,7 +153,7 @@ public class Session {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private String validatePassword(String password, String userName) {
|
private static String validatePassword(String password, String userName) {
|
||||||
ConfigSettings config = ConfigSettings.instance;
|
ConfigSettings config = ConfigSettings.instance;
|
||||||
if (password.length() < config.getMinPasswordLength()) {
|
if (password.length() < config.getMinPasswordLength()) {
|
||||||
return "Password may not be shorter than " + config.getMinPasswordLength() + " characters";
|
return "Password may not be shorter than " + config.getMinPasswordLength() + " characters";
|
||||||
|
@ -171,7 +172,7 @@ public class Session {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private String validateEmail(String email) {
|
private static String validateEmail(String email) {
|
||||||
|
|
||||||
if (email == null || email.isEmpty()) {
|
if (email == null || email.isEmpty()) {
|
||||||
return "Email address cannot be blank";
|
return "Email address cannot be blank";
|
||||||
|
@ -248,10 +249,12 @@ public class Session {
|
||||||
}
|
}
|
||||||
this.userId = user.getId();
|
this.userId = user.getId();
|
||||||
if (reconnect) { // must be connected to receive the message
|
if (reconnect) { // must be connected to receive the message
|
||||||
UUID chatId = GamesRoomManager.instance.getRoom(GamesRoomManager.instance.getMainRoomId()).getChatId();
|
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(GamesRoomManager.instance.getMainRoomId());
|
||||||
if (chatId != null) {
|
if (!room.isPresent()) {
|
||||||
ChatManager.instance.joinChat(chatId, userId);
|
logger.error("main room not found");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
ChatManager.instance.joinChat(room.get().getChatId(), userId);
|
||||||
ChatManager.instance.sendReconnectMessage(userId);
|
ChatManager.instance.sendReconnectMessage(userId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -331,7 +334,7 @@ public class Session {
|
||||||
return; //user was already disconnected by other thread
|
return; //user was already disconnected by other thread
|
||||||
}
|
}
|
||||||
User user = _user.get();
|
User user = _user.get();
|
||||||
if(!user.isConnected()){
|
if (!user.isConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!user.getSessionId().equals(sessionId)) {
|
if (!user.getSessionId().equals(sessionId)) {
|
||||||
|
@ -381,7 +384,7 @@ public class Session {
|
||||||
callbackHandler.handleCallbackOneway(new Callback(call));
|
callbackHandler.handleCallbackOneway(new Callback(call));
|
||||||
} catch (HandleCallbackException ex) {
|
} catch (HandleCallbackException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
UserManager.instance.getUser(userId).ifPresent(user-> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
logger.warn("SESSION CALLBACK EXCEPTION - " + user.getName() + " userId " + userId);
|
logger.warn("SESSION CALLBACK EXCEPTION - " + user.getName() + " userId " + userId);
|
||||||
logger.warn(" - method: " + call.getMethod());
|
logger.warn(" - method: " + call.getMethod());
|
||||||
logger.warn(" - cause: " + getBasicCause(ex).toString());
|
logger.warn(" - cause: " + getBasicCause(ex).toString());
|
||||||
|
|
|
@ -49,15 +49,15 @@ public enum SessionManager {
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public Session getSession(@Nonnull String sessionId) {
|
public Optional<Session> getSession(@Nonnull String sessionId) {
|
||||||
Session session = sessions.get(sessionId);
|
Session session = sessions.get(sessionId);
|
||||||
if (session != null && session.getUserId() != null && UserManager.instance.getUser(session.getUserId()) == null) {
|
if (session != null && session.getUserId() != null && UserManager.instance.getUser(session.getUserId()) == null) {
|
||||||
logger.error("User for session " + sessionId + " with userId " + session.getUserId() + " is missing. Session removed.");
|
logger.error("User for session " + sessionId + " with userId " + session.getUserId() + " is missing. Session removed.");
|
||||||
// can happen if user from same host signs in multiple time with multiple clients, after he disconnects with one client
|
// can happen if user from same host signs in multiple time with multiple clients, after he disconnects with one client
|
||||||
disconnect(sessionId, DisconnectReason.ConnectingOtherInstance);
|
disconnect(sessionId, DisconnectReason.ConnectingOtherInstance);
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return session;
|
return Optional.of(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createSession(String sessionId, InvokerCallbackHandler callbackHandler) {
|
public void createSession(String sessionId, InvokerCallbackHandler callbackHandler) {
|
||||||
|
@ -168,26 +168,26 @@ public enum SessionManager {
|
||||||
*/
|
*/
|
||||||
public void disconnectUser(String sessionId, String userSessionId) {
|
public void disconnectUser(String sessionId, String userSessionId) {
|
||||||
if (isAdmin(sessionId)) {
|
if (isAdmin(sessionId)) {
|
||||||
User userAdmin;
|
getUserFromSession(sessionId).ifPresent(admin -> {
|
||||||
if ((userAdmin = getUserFromSession(sessionId)) != null) {
|
Optional<User> u = getUserFromSession(userSessionId);
|
||||||
User user;
|
if (u.isPresent()) {
|
||||||
if ((user = getUserFromSession(userSessionId)) != null) {
|
User user = u.get();
|
||||||
user.showUserMessage("Admin operation", "Your session was disconnected by Admin.");
|
user.showUserMessage("Admin operation", "Your session was disconnected by Admin.");
|
||||||
userAdmin.showUserMessage("Admin action", "User" + user.getName() + " was disconnected.");
|
admin.showUserMessage("Admin action", "User" + user.getName() + " was disconnected.");
|
||||||
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
||||||
} else {
|
} else {
|
||||||
userAdmin.showUserMessage("Admin operation", "User with sessionId " + userSessionId + " could not be found!");
|
admin.showUserMessage("Admin operation", "User with sessionId " + userSessionId + " could not be found!");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private User getUserFromSession(String sessionId) {
|
private Optional<User> getUserFromSession(String sessionId) {
|
||||||
Session session = getSession(sessionId);
|
Optional<Session> session = getSession(sessionId);
|
||||||
if (session == null) {
|
if (!session.isPresent()) {
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return UserManager.instance.getUser(session.getUserId()).get();
|
return UserManager.instance.getUser(session.get().getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endUserSession(String sessionId, String userSessionId) {
|
public void endUserSession(String sessionId, String userSessionId) {
|
||||||
|
|
|
@ -242,7 +242,7 @@ public class TableController {
|
||||||
newTournamentPlayer.setState(oldTournamentPlayer.getState());
|
newTournamentPlayer.setState(oldTournamentPlayer.getState());
|
||||||
newTournamentPlayer.setReplacedTournamentPlayer(oldTournamentPlayer);
|
newTournamentPlayer.setReplacedTournamentPlayer(oldTournamentPlayer);
|
||||||
|
|
||||||
DraftManager.instance.getController(table.getId()).replacePlayer(oldPlayer, newPlayer);
|
DraftManager.instance.getController(table.getId()).ifPresent(controller -> controller.replacePlayer(oldPlayer, newPlayer));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,29 +307,29 @@ public class TableController {
|
||||||
user.showUserMessage("Join Table", message);
|
user.showUserMessage("Join Table", message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean restrictedColor = false;
|
boolean restrictedColor = false;
|
||||||
String badColor = "";
|
String badColor = "";
|
||||||
int colorVal = edhPowerLevel % 10;
|
int colorVal = edhPowerLevel % 10;
|
||||||
if (colorVal == 6 && deckEdhPowerLevel >= 10000000) {
|
if (colorVal == 6 && deckEdhPowerLevel >= 10000000) {
|
||||||
restrictedColor = true;
|
restrictedColor = true;
|
||||||
badColor = "white";
|
badColor = "white";
|
||||||
}
|
}
|
||||||
if (colorVal == 4 && deckEdhPowerLevel % 10000000 >= 1000000) {
|
if (colorVal == 4 && deckEdhPowerLevel % 10000000 >= 1000000) {
|
||||||
restrictedColor = true;
|
restrictedColor = true;
|
||||||
badColor = "blue";
|
badColor = "blue";
|
||||||
}
|
}
|
||||||
if (colorVal == 3 && deckEdhPowerLevel % 1000000 >= 100000) {
|
if (colorVal == 3 && deckEdhPowerLevel % 1000000 >= 100000) {
|
||||||
restrictedColor = true;
|
restrictedColor = true;
|
||||||
badColor = "black";
|
badColor = "black";
|
||||||
}
|
}
|
||||||
if (colorVal == 2 && deckEdhPowerLevel % 100000 >= 10000) {
|
if (colorVal == 2 && deckEdhPowerLevel % 100000 >= 10000) {
|
||||||
restrictedColor = true;
|
restrictedColor = true;
|
||||||
badColor = "red";
|
badColor = "red";
|
||||||
}
|
}
|
||||||
if (colorVal == 1 && deckEdhPowerLevel % 10000 >= 1000) {
|
if (colorVal == 1 && deckEdhPowerLevel % 10000 >= 1000) {
|
||||||
restrictedColor = true;
|
restrictedColor = true;
|
||||||
badColor = "green";
|
badColor = "green";
|
||||||
}
|
}
|
||||||
if (restrictedColor) {
|
if (restrictedColor) {
|
||||||
String message = new StringBuilder("Your deck contains ")
|
String message = new StringBuilder("Your deck contains ")
|
||||||
|
|
|
@ -49,6 +49,7 @@ import mage.game.match.Match;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
import mage.game.tournament.TournamentPlayer;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.server.game.GameController;
|
import mage.server.game.GameController;
|
||||||
import mage.server.game.GameManager;
|
import mage.server.game.GameManager;
|
||||||
|
@ -114,19 +115,22 @@ public enum TableManager {
|
||||||
return tables.get(tableId);
|
return tables.get(tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Match getMatch(UUID tableId) {
|
public Optional<Match> getMatch(UUID tableId) {
|
||||||
if (controllers.containsKey(tableId)) {
|
if (controllers.containsKey(tableId)) {
|
||||||
return controllers.get(tableId).getMatch();
|
return Optional.of(controllers.get(tableId).getMatch());
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Table> getTables() {
|
public Collection<Table> getTables() {
|
||||||
return tables.values();
|
return tables.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableController getController(UUID tableId) {
|
public Optional<TableController> getController(UUID tableId) {
|
||||||
return controllers.get(tableId);
|
if (controllers.containsKey(tableId)) {
|
||||||
|
return Optional.of(controllers.get(tableId));
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException {
|
public boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException {
|
||||||
|
@ -214,11 +218,11 @@ public enum TableManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getChatId(UUID tableId) {
|
public Optional<UUID> getChatId(UUID tableId) {
|
||||||
if (controllers.containsKey(tableId)) {
|
if (controllers.containsKey(tableId)) {
|
||||||
return controllers.get(tableId).getChatId();
|
return Optional.of(controllers.get(tableId).getChatId());
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -313,9 +317,9 @@ public enum TableManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(UUID userId, UUID tableId, Player player, String playerType, Deck deck) throws GameException {
|
public void addPlayer(UUID userId, UUID tableId, TournamentPlayer player) throws GameException {
|
||||||
if (controllers.containsKey(tableId)) {
|
if (controllers.containsKey(tableId)) {
|
||||||
controllers.get(tableId).addPlayer(userId, player, playerType, deck);
|
controllers.get(tableId).addPlayer(userId, player.getPlayer(), player.getPlayerType(), player.getDeck());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,10 +356,10 @@ public enum TableManager {
|
||||||
Collection<User> users = UserManager.instance.getUsers();
|
Collection<User> users = UserManager.instance.getUsers();
|
||||||
logger.debug("--------User: " + users.size() + " [userId | since | lock | name -----------------------");
|
logger.debug("--------User: " + users.size() + " [userId | since | lock | name -----------------------");
|
||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
Session session = SessionManager.instance.getSession(user.getSessionId());
|
Optional<Session> session = SessionManager.instance.getSession(user.getSessionId());
|
||||||
String sessionState = "N";
|
String sessionState = "N";
|
||||||
if (session != null) {
|
if (session.isPresent()) {
|
||||||
if (session.isLocked()) {
|
if (session.get().isLocked()) {
|
||||||
sessionState = "L";
|
sessionState = "L";
|
||||||
} else {
|
} else {
|
||||||
sessionState = "+";
|
sessionState = "+";
|
||||||
|
@ -390,8 +394,7 @@ public enum TableManager {
|
||||||
if (table.getState() != TableState.FINISHED) {
|
if (table.getState() != TableState.FINISHED) {
|
||||||
// remove tables and games not valid anymore
|
// remove tables and games not valid anymore
|
||||||
logger.debug(table.getId() + " [" + table.getName() + "] " + formatter.format(table.getStartTime() == null ? table.getCreateTime() : table.getCreateTime()) + " (" + table.getState().toString() + ") " + (table.isTournament() ? "- Tournament" : ""));
|
logger.debug(table.getId() + " [" + table.getName() + "] " + formatter.format(table.getStartTime() == null ? table.getCreateTime() : table.getCreateTime()) + " (" + table.getState().toString() + ") " + (table.isTournament() ? "- Tournament" : ""));
|
||||||
TableController tableController = getController(table.getId());
|
getController(table.getId()).ifPresent(tableController -> {
|
||||||
if (tableController != null) {
|
|
||||||
if ((table.isTournament() && !tableController.isTournamentStillValid()) ||
|
if ((table.isTournament() && !tableController.isTournamentStillValid()) ||
|
||||||
(!table.isTournament() && !tableController.isMatchTableStillValid())) {
|
(!table.isTournament() && !tableController.isMatchTableStillValid())) {
|
||||||
try {
|
try {
|
||||||
|
@ -401,7 +404,7 @@ public enum TableManager {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.debug("Table Health check error tableId: " + table.getId());
|
logger.debug("Table Health check error tableId: " + table.getId());
|
||||||
|
|
|
@ -27,14 +27,8 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
|
@ -246,10 +240,9 @@ public class User {
|
||||||
|
|
||||||
public void fireCallback(final ClientCallback call) {
|
public void fireCallback(final ClientCallback call) {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
Session session = SessionManager.instance.getSession(sessionId);
|
SessionManager.instance.getSession(sessionId).ifPresent(session ->
|
||||||
if (session != null) {
|
session.fireCallback(call)
|
||||||
session.fireCallback(call);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,8 +371,13 @@ public class User {
|
||||||
entry.getValue().construct(0); // TODO: Check if this is correct
|
entry.getValue().construct(0); // TODO: Check if this is correct
|
||||||
}
|
}
|
||||||
for (Entry<UUID, Deck> entry : sideboarding.entrySet()) {
|
for (Entry<UUID, Deck> entry : sideboarding.entrySet()) {
|
||||||
TableController controller = TableManager.instance.getController(entry.getKey());
|
Optional<TableController> controller = TableManager.instance.getController(entry.getKey());
|
||||||
ccSideboard(entry.getValue(), entry.getKey(), controller.getRemainingTime(), controller.getOptions().isLimited());
|
if(controller.isPresent()) {
|
||||||
|
ccSideboard(entry.getValue(), entry.getKey(), controller.get().getRemainingTime(), controller.get().getOptions().isLimited());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
logger.error("sideboarding id not found : "+entry.getKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ServerMessagesUtil.instance.incReconnects();
|
ServerMessagesUtil.instance.incReconnects();
|
||||||
logger.trace(userName + " ended reconnect");
|
logger.trace(userName + " ended reconnect");
|
||||||
|
@ -784,8 +782,11 @@ public class User {
|
||||||
if (table.getState() == TableState.FINISHED) {
|
if (table.getState() == TableState.FINISHED) {
|
||||||
number++;
|
number++;
|
||||||
} else {
|
} else {
|
||||||
TableController tableController = TableManager.instance.getController(table.getId());
|
Optional<TableController> tableController = TableManager.instance.getController(table.getId());
|
||||||
if (tableController != null && tableController.isUserStillActive(userId)) {
|
if(!tableController.isPresent()){
|
||||||
|
logger.error("table not found : "+table.getId());
|
||||||
|
}
|
||||||
|
else if (tableController.get().isUserStillActive(userId)) {
|
||||||
number++;
|
number++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ package mage.server.draft;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -129,11 +130,11 @@ public class DraftController {
|
||||||
checkStart();
|
checkStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DraftSession getDraftSession(UUID playerId) {
|
public Optional<DraftSession> getDraftSession(UUID playerId) {
|
||||||
if (draftSessions.containsKey(playerId)) {
|
if (draftSessions.containsKey(playerId)) {
|
||||||
return draftSessions.get(playerId);
|
return Optional.of(draftSessions.get(playerId));
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean replacePlayer(Player oldPlayer, Player newPlayer) {
|
public boolean replacePlayer(Player oldPlayer, Player newPlayer) {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.server.draft;
|
package mage.server.draft;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -87,12 +88,7 @@ public enum DraftManager {
|
||||||
return draftControllers.get(draftId);
|
return draftControllers.get(draftId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DraftController getController(UUID tableId) {
|
public Optional<DraftController> getController(UUID tableId) {
|
||||||
for (DraftController controller: draftControllers.values()) {
|
return draftControllers.values().stream().filter(controller -> controller.getTableId().equals(tableId)).findFirst();
|
||||||
if (controller.getTableId().equals(tableId)) {
|
|
||||||
return controller;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
|
@ -59,12 +60,12 @@ public enum GameManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getChatId(UUID gameId) {
|
public Optional<UUID> getChatId(UUID gameId) {
|
||||||
GameController gameController = gameControllers.get(gameId);
|
GameController gameController = gameControllers.get(gameId);
|
||||||
if (gameController != null) {
|
if (gameController != null) {
|
||||||
return gameController.getChatId();
|
return Optional.of(gameController.getChatId());
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayerUUID(UUID gameId, UUID userId, UUID data) {
|
public void sendPlayerUUID(UUID gameId, UUID userId, UUID data) {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
|
@ -55,7 +56,7 @@ public interface GamesRoom extends Room {
|
||||||
TableView createTournamentTable(UUID userId, TournamentOptions options);
|
TableView createTournamentTable(UUID userId, TournamentOptions options);
|
||||||
void removeTable(UUID userId, UUID tableId);
|
void removeTable(UUID userId, UUID tableId);
|
||||||
void removeTable(UUID tableId);
|
void removeTable(UUID tableId);
|
||||||
TableView getTable(UUID tableId);
|
Optional<TableView> getTable(UUID tableId);
|
||||||
void leaveTable(UUID userId, UUID tableId);
|
void leaveTable(UUID userId, UUID tableId);
|
||||||
boolean watchTable(UUID userId, UUID tableId) throws MageException;
|
boolean watchTable(UUID userId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,7 @@
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
@ -180,11 +177,11 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableView getTable(UUID tableId) {
|
public Optional<TableView> getTable(UUID tableId) {
|
||||||
if (tables.containsKey(tableId)) {
|
if (tables.containsKey(tableId)) {
|
||||||
return new TableView(tables.get(tableId));
|
return Optional.of(new TableView(tables.get(tableId)));
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -57,8 +58,12 @@ public enum GamesRoomManager {
|
||||||
return mainRoomId;
|
return mainRoomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GamesRoom getRoom(UUID roomId) {
|
public Optional<GamesRoom> getRoom(UUID roomId) {
|
||||||
return rooms.get(roomId);
|
if(rooms.containsKey(roomId)) {
|
||||||
|
return Optional.of(rooms.get(roomId));
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeTable(UUID tableId) {
|
public void removeTable(UUID tableId) {
|
||||||
|
|
|
@ -249,16 +249,21 @@ public class TournamentController {
|
||||||
table.setState(TableState.WAITING);
|
table.setState(TableState.WAITING);
|
||||||
TournamentPlayer player1 = pair.getPlayer1();
|
TournamentPlayer player1 = pair.getPlayer1();
|
||||||
TournamentPlayer player2 = pair.getPlayer2();
|
TournamentPlayer player2 = pair.getPlayer2();
|
||||||
tableManager.addPlayer(getPlayerUserId(player1.getPlayer().getId()), table.getId(), player1.getPlayer(), player1.getPlayerType(), player1.getDeck());
|
Optional<UUID> user1Id = getPlayerUserId(player1.getPlayer().getId());
|
||||||
tableManager.addPlayer(getPlayerUserId(player2.getPlayer().getId()), table.getId(), player2.getPlayer(), player2.getPlayerType(), player2.getDeck());
|
Optional<UUID> user2Id = getPlayerUserId(player2.getPlayer().getId());
|
||||||
table.setState(TableState.STARTING);
|
if (user1Id.isPresent() && user2Id.isPresent()) {
|
||||||
tableManager.startTournamentSubMatch(null, table.getId());
|
tableManager.addPlayer(getPlayerUserId(player1.getPlayer().getId()).get(), table.getId(), player1);
|
||||||
Match match = tableManager.getMatch(table.getId());
|
tableManager.addPlayer(getPlayerUserId(player2.getPlayer().getId()).get(), table.getId(), player2);
|
||||||
match.setTableId(tableId);
|
table.setState(TableState.STARTING);
|
||||||
pair.setMatch(match);
|
tableManager.startTournamentSubMatch(null, table.getId());
|
||||||
pair.setTableId(table.getId());
|
tableManager.getMatch(table.getId()).ifPresent(match -> {
|
||||||
player1.setState(TournamentPlayerState.DUELING);
|
match.setTableId(tableId);
|
||||||
player2.setState(TournamentPlayerState.DUELING);
|
pair.setMatch(match);
|
||||||
|
pair.setTableId(table.getId());
|
||||||
|
player1.setState(TournamentPlayerState.DUELING);
|
||||||
|
player2.setState(TournamentPlayerState.DUELING);
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
logger.fatal("TournamentController startMatch error", ex);
|
logger.fatal("TournamentController startMatch error", ex);
|
||||||
}
|
}
|
||||||
|
@ -271,18 +276,20 @@ public class TournamentController {
|
||||||
table.setTournamentSubTable(true);
|
table.setTournamentSubTable(true);
|
||||||
table.setTournament(tournament);
|
table.setTournament(tournament);
|
||||||
table.setState(TableState.WAITING);
|
table.setState(TableState.WAITING);
|
||||||
|
if (round.getAllPlayers().stream().allMatch(tournamentPlayer -> getPlayerUserId(tournamentPlayer.getPlayer().getId()).isPresent())) {
|
||||||
for (TournamentPlayer player : round.getAllPlayers()) {
|
for (TournamentPlayer player : round.getAllPlayers()) {
|
||||||
tableManager.addPlayer(getPlayerUserId(player.getPlayer().getId()), table.getId(), player.getPlayer(), player.getPlayerType(), player.getDeck());
|
tableManager.addPlayer(getPlayerUserId(player.getPlayer().getId()).get(), table.getId(), player);
|
||||||
}
|
}
|
||||||
table.setState(TableState.STARTING);
|
table.setState(TableState.STARTING);
|
||||||
tableManager.startTournamentSubMatch(null, table.getId());
|
tableManager.startTournamentSubMatch(null, table.getId());
|
||||||
Match match = tableManager.getMatch(table.getId());
|
tableManager.getMatch(table.getId()).ifPresent(match -> {
|
||||||
match.setTableId(tableId);
|
match.setTableId(tableId);
|
||||||
round.setMatch(match);
|
round.setMatch(match);
|
||||||
round.setTableId(table.getId());
|
round.setTableId(table.getId());
|
||||||
for (TournamentPlayer player : round.getAllPlayers()) {
|
for (TournamentPlayer player : round.getAllPlayers()) {
|
||||||
player.setState(TournamentPlayerState.DUELING);
|
player.setState(TournamentPlayerState.DUELING);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
logger.fatal("TournamentController startMatch error", ex);
|
logger.fatal("TournamentController startMatch error", ex);
|
||||||
|
@ -307,9 +314,13 @@ public class TournamentController {
|
||||||
if (tournamentSessions.containsKey(playerId)) {
|
if (tournamentSessions.containsKey(playerId)) {
|
||||||
TournamentSession tournamentSession = tournamentSessions.get(playerId);
|
TournamentSession tournamentSession = tournamentSessions.get(playerId);
|
||||||
tournamentSession.construct(timeout);
|
tournamentSession.construct(timeout);
|
||||||
UserManager.instance.getUser(getPlayerUserId(playerId)).get().addConstructing(playerId, tournamentSession);
|
getPlayerUserId(playerId).ifPresent(userId -> {
|
||||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
player.setState(TournamentPlayerState.CONSTRUCTING);
|
user.addConstructing(playerId, tournamentSession);
|
||||||
|
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||||
|
player.setState(TournamentPlayerState.CONSTRUCTING);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,13 +396,11 @@ public class TournamentController {
|
||||||
if (!checkToReplaceDraftPlayerByAi(userId, tournamentPlayer)) {
|
if (!checkToReplaceDraftPlayerByAi(userId, tournamentPlayer)) {
|
||||||
this.abortDraftTournament();
|
this.abortDraftTournament();
|
||||||
} else {
|
} else {
|
||||||
DraftController draftController = DraftManager.instance.getController(tableId);
|
DraftManager.instance.getController(tableId).ifPresent(draftController -> {
|
||||||
if (draftController != null) {
|
draftController.getDraftSession(playerId).ifPresent(draftSession ->
|
||||||
DraftSession draftSession = draftController.getDraftSession(playerId);
|
DraftManager.instance.kill(draftSession.getDraftId(), userId));
|
||||||
if (draftSession != null) {
|
|
||||||
DraftManager.instance.kill(draftSession.getDraftId(), userId);
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
status = TourneyQuitStatus.DURING_DRAFTING;
|
status = TourneyQuitStatus.DURING_DRAFTING;
|
||||||
} else if (tournamentPlayer.getState() == TournamentPlayerState.CONSTRUCTING) {
|
} else if (tournamentPlayer.getState() == TournamentPlayerState.CONSTRUCTING) {
|
||||||
|
@ -419,8 +428,8 @@ public class TournamentController {
|
||||||
// replace player that quits with draft bot
|
// replace player that quits with draft bot
|
||||||
if (humans > 1) {
|
if (humans > 1) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
TableController tableController = TableManager.instance.getController(tableId);
|
TableManager.instance.getController(tableId).ifPresent(tableController -> {
|
||||||
if (tableController != null) {
|
|
||||||
String replacePlayerName = "Draftbot";
|
String replacePlayerName = "Draftbot";
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
replacePlayerName = "Draftbot (" + user.get().getName() + ')';
|
replacePlayerName = "Draftbot (" + user.get().getName() + ')';
|
||||||
|
@ -432,19 +441,14 @@ public class TournamentController {
|
||||||
user.get().removeTournament(leavingPlayer.getPlayer().getId());
|
user.get().removeTournament(leavingPlayer.getPlayer().getId());
|
||||||
}
|
}
|
||||||
ChatManager.instance.broadcast(chatId, "", leavingPlayer.getPlayer().getLogName() + " was replaced by draftbot", MessageColor.BLACK, true, MessageType.STATUS, null);
|
ChatManager.instance.broadcast(chatId, "", leavingPlayer.getPlayer().getLogName() + " was replaced by draftbot", MessageColor.BLACK, true, MessageType.STATUS, null);
|
||||||
}
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID getPlayerUserId(UUID playerId) {
|
private Optional<UUID> getPlayerUserId(UUID playerId) {
|
||||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
return userPlayerMap.entrySet().stream().filter(entry -> entry.getValue().equals(playerId)).map(Entry::getKey).findFirst();
|
||||||
if (entry.getValue().equals(playerId)) {
|
|
||||||
return entry.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TournamentView getTournamentView() {
|
public TournamentView getTournamentView() {
|
||||||
|
@ -453,7 +457,7 @@ public class TournamentController {
|
||||||
|
|
||||||
private void abortDraftTournament() {
|
private void abortDraftTournament() {
|
||||||
tournament.setAbort(true);
|
tournament.setAbort(true);
|
||||||
DraftManager.instance.getController(tableId).abortDraft();
|
DraftManager.instance.getController(tableId).ifPresent(DraftController::abortDraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAbort() {
|
public boolean isAbort() {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.server.tournament;
|
package mage.server.tournament;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -85,10 +86,14 @@ public enum TournamentManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getChatId(UUID tournamentId) {
|
public Optional<UUID> getChatId(UUID tournamentId) {
|
||||||
return controllers.get(tournamentId).getChatId();
|
if(controllers.containsKey(tournamentId)) {
|
||||||
|
return Optional.of(controllers.get(tournamentId).getChatId());
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void removeTournament(UUID tournamentId) {
|
public void removeTournament(UUID tournamentId) {
|
||||||
TournamentController tournamentController = controllers.get(tournamentId);
|
TournamentController tournamentController = controllers.get(tournamentId);
|
||||||
if (tournamentController != null) {
|
if (tournamentController != null) {
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class LoadTest {
|
||||||
|
|
||||||
if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
|
if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
|
||||||
log.error("Error while joining table");
|
log.error("Error while joining table");
|
||||||
Assert.assertTrue("Error while joining table", false);
|
Assert.fail("Error while joining table");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public class LoadTest {
|
||||||
// connect to the table with the same deck
|
// connect to the table with the same deck
|
||||||
if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
|
if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
|
||||||
log.error("Error while joining table");
|
log.error("Error while joining table");
|
||||||
Assert.assertTrue("Error while joining table", false);
|
Assert.fail("Error while joining table");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public class LoadTest {
|
||||||
|
|
||||||
if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
|
if (!session.joinTable(roomId, table.getTableId(), TEST_USER_NAME + i, "Human", 1, deckList,"")) {
|
||||||
log.error("Error while joining table");
|
log.error("Error while joining table");
|
||||||
Assert.assertTrue("Error while joining table", false);
|
Assert.fail("Error while joining table");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ public class LoadTest {
|
||||||
// connect to the table with the same deck
|
// connect to the table with the same deck
|
||||||
if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
|
if (!session2.joinTable(roomId2, table.getTableId(), TEST_USER_NAME_2 + i, "Human", 1, deckList,"")) {
|
||||||
log.error("Error while joining table");
|
log.error("Error while joining table");
|
||||||
Assert.assertTrue("Error while joining table", false);
|
Assert.fail("Error while joining table");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue