mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
removed the Session out of local scope and introduced a static SessionHandler that acts as interface to remote.Session
This commit is contained in:
parent
360823ec2e
commit
3019991473
28 changed files with 545 additions and 271 deletions
|
|
@ -167,7 +167,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
|
|
||||||
private static MageFrame instance;
|
private static MageFrame instance;
|
||||||
|
|
||||||
private static Session session;
|
|
||||||
private ConnectDialog connectDialog;
|
private ConnectDialog connectDialog;
|
||||||
private final ErrorDialog errorDialog;
|
private final ErrorDialog errorDialog;
|
||||||
private static CallbackClient callbackClient;
|
private static CallbackClient callbackClient;
|
||||||
|
|
@ -199,9 +198,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
/**
|
/**
|
||||||
* @return the session
|
* @return the session
|
||||||
*/
|
*/
|
||||||
public static Session getSession() {
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JDesktopPane getDesktop() {
|
public static JDesktopPane getDesktop() {
|
||||||
return desktopPane;
|
return desktopPane;
|
||||||
|
|
@ -308,7 +304,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
DialogManager.updateParams(768, 1024, false);
|
DialogManager.updateParams(768, 1024, false);
|
||||||
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||||
|
|
||||||
session = new SessionImpl(this);
|
SessionHandler.startSession(this);
|
||||||
callbackClient = new CallbackClientImpl(this);
|
callbackClient = new CallbackClientImpl(this);
|
||||||
connectDialog = new ConnectDialog();
|
connectDialog = new ConnectDialog();
|
||||||
desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
|
desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
|
||||||
|
|
@ -320,7 +316,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
PING_TASK_EXECUTOR.scheduleAtFixedRate(new Runnable() {
|
PING_TASK_EXECUTOR.scheduleAtFixedRate(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
session.ping();
|
SessionHandler.ping();
|
||||||
}
|
}
|
||||||
}, 60, 60, TimeUnit.SECONDS);
|
}, 60, 60, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
@ -445,7 +441,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
private void setWindowTitle() {
|
private void setWindowTitle() {
|
||||||
setTitle(TITLE_NAME + " Client: "
|
setTitle(TITLE_NAME + " Client: "
|
||||||
+ (VERSION == null ? "<not available>" : VERSION.toString()) + " Server: "
|
+ (VERSION == null ? "<not available>" : VERSION.toString()) + " Server: "
|
||||||
+ ((session != null && session.isConnected()) ? session.getVersionInfo() : "<not connected>"));
|
+ ((SessionHandler.getSession() != null && SessionHandler.isConnected()) ? SessionHandler.getVersionInfo() : "<not connected>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTooltipContainer() {
|
private void addTooltipContainer() {
|
||||||
|
|
@ -820,13 +816,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean connect(Connection connection) {
|
public static boolean connect(Connection connection) {
|
||||||
boolean result = session.connect(connection);
|
boolean result = SessionHandler.connect(connection);
|
||||||
MageFrame.getInstance().setWindowTitle();
|
MageFrame.getInstance().setWindowTitle();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean stopConnecting() {
|
public static boolean stopConnecting() {
|
||||||
return session.stopConnecting();
|
return SessionHandler.stopConnecting();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean autoConnect() {
|
public boolean autoConnect() {
|
||||||
|
|
@ -1056,7 +1052,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}//GEN-LAST:event_btnExitActionPerformed
|
}//GEN-LAST:event_btnExitActionPerformed
|
||||||
|
|
||||||
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
||||||
if (session.isConnected()) {
|
if (SessionHandler.isConnected()) {
|
||||||
UserRequestMessage message = new UserRequestMessage("Confirm disconnect", "Are you sure you want to disconnect?");
|
UserRequestMessage message = new UserRequestMessage("Confirm disconnect", "Are you sure you want to disconnect?");
|
||||||
message.setButton1("No", null);
|
message.setButton1("No", null);
|
||||||
message.setButton2("Yes", PlayerAction.CLIENT_DISCONNECT);
|
message.setButton2("Yes", PlayerAction.CLIENT_DISCONNECT);
|
||||||
|
|
@ -1089,7 +1085,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}//GEN-LAST:event_btnPreferencesActionPerformed
|
}//GEN-LAST:event_btnPreferencesActionPerformed
|
||||||
|
|
||||||
public void btnSendFeedbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendFeedbackActionPerformed
|
public void btnSendFeedbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendFeedbackActionPerformed
|
||||||
if (!session.isConnected()) {
|
if (!SessionHandler.isConnected()) {
|
||||||
JOptionPane.showMessageDialog(null, "You may send us feedback only when connected to server.", "Information", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "You may send us feedback only when connected to server.", "Information", JOptionPane.INFORMATION_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1097,7 +1093,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}//GEN-LAST:event_btnSendFeedbackActionPerformed
|
}//GEN-LAST:event_btnSendFeedbackActionPerformed
|
||||||
|
|
||||||
public void exitApp() {
|
public void exitApp() {
|
||||||
if (session.isConnected()) {
|
if (SessionHandler.isConnected()) {
|
||||||
UserRequestMessage message = new UserRequestMessage("Confirm disconnect", "You are currently connected. Are you sure you want to disconnect?");
|
UserRequestMessage message = new UserRequestMessage("Confirm disconnect", "You are currently connected. Are you sure you want to disconnect?");
|
||||||
message.setButton1("No", null);
|
message.setButton1("No", null);
|
||||||
message.setButton2("Yes", PlayerAction.CLIENT_EXIT);
|
message.setButton2("Yes", PlayerAction.CLIENT_EXIT);
|
||||||
|
|
@ -1424,7 +1420,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
disableButtons();
|
disableButtons();
|
||||||
hideGames();
|
hideGames();
|
||||||
hideTables();
|
hideTables();
|
||||||
session.disconnect(false);
|
SessionHandler.disconnect(false);
|
||||||
if (errorCall) {
|
if (errorCall) {
|
||||||
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect?");
|
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect?");
|
||||||
message.setButton1("No", null);
|
message.setButton1("No", null);
|
||||||
|
|
@ -1441,14 +1437,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
public void showMessage(String message) {
|
public void showMessage(String message) {
|
||||||
final UserRequestMessage requestMessage = new UserRequestMessage("Message", message);
|
final UserRequestMessage requestMessage = new UserRequestMessage("Message", message);
|
||||||
requestMessage.setButton1("OK", null);
|
requestMessage.setButton1("OK", null);
|
||||||
MageFrame.getInstance().showUserRequestDialog(requestMessage);
|
showUserRequestDialog(requestMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showError(final String message) {
|
public void showError(final String message) {
|
||||||
final UserRequestMessage requestMessage = new UserRequestMessage("Error", message);
|
final UserRequestMessage requestMessage = new UserRequestMessage("Error", message);
|
||||||
requestMessage.setButton1("OK", null);
|
requestMessage.setButton1("OK", null);
|
||||||
MageFrame.getInstance().showUserRequestDialog(requestMessage);
|
showUserRequestDialog(requestMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1465,26 +1461,26 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
DownloadPictures.startDownload(null, missingCards);
|
DownloadPictures.startDownload(null, missingCards);
|
||||||
break;
|
break;
|
||||||
case CLIENT_DISCONNECT:
|
case CLIENT_DISCONNECT:
|
||||||
session.disconnect(false);
|
SessionHandler.disconnect(false);
|
||||||
tablesPane.clearChat();
|
tablesPane.clearChat();
|
||||||
showMessage("You have disconnected");
|
showMessage("You have disconnected");
|
||||||
setWindowTitle();
|
setWindowTitle();
|
||||||
break;
|
break;
|
||||||
case CLIENT_QUIT_TOURNAMENT:
|
case CLIENT_QUIT_TOURNAMENT:
|
||||||
MageFrame.getSession().quitTournament(userRequestMessage.getTournamentId());
|
SessionHandler.quitTournament(userRequestMessage.getTournamentId());
|
||||||
break;
|
break;
|
||||||
case CLIENT_QUIT_DRAFT_TOURNAMENT:
|
case CLIENT_QUIT_DRAFT_TOURNAMENT:
|
||||||
MageFrame.getSession().quitDraft(userRequestMessage.getTournamentId());
|
SessionHandler.quitDraft(userRequestMessage.getTournamentId());
|
||||||
MageFrame.removeDraft(userRequestMessage.getTournamentId());
|
MageFrame.removeDraft(userRequestMessage.getTournamentId());
|
||||||
break;
|
break;
|
||||||
case CLIENT_CONCEDE_GAME:
|
case CLIENT_CONCEDE_GAME:
|
||||||
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, userRequestMessage.getGameId(), null);
|
SessionHandler.sendPlayerAction(PlayerAction.CONCEDE, userRequestMessage.getGameId(), null);
|
||||||
break;
|
break;
|
||||||
case CLIENT_CONCEDE_MATCH:
|
case CLIENT_CONCEDE_MATCH:
|
||||||
MageFrame.getSession().quitMatch(userRequestMessage.getGameId());
|
SessionHandler.quitMatch(userRequestMessage.getGameId());
|
||||||
break;
|
break;
|
||||||
case CLIENT_STOP_WATCHING:
|
case CLIENT_STOP_WATCHING:
|
||||||
session.stopWatching(userRequestMessage.getGameId());
|
SessionHandler.stopWatching(userRequestMessage.getGameId());
|
||||||
GamePanel gamePanel = getGame(userRequestMessage.getGameId());
|
GamePanel gamePanel = getGame(userRequestMessage.getGameId());
|
||||||
if (gamePanel != null) {
|
if (gamePanel != null) {
|
||||||
gamePanel.removeGame();
|
gamePanel.removeGame();
|
||||||
|
|
@ -1492,8 +1488,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
removeGame(userRequestMessage.getGameId());
|
removeGame(userRequestMessage.getGameId());
|
||||||
break;
|
break;
|
||||||
case CLIENT_EXIT:
|
case CLIENT_EXIT:
|
||||||
if (session.isConnected()) {
|
if (SessionHandler.isConnected()) {
|
||||||
session.disconnect(false);
|
SessionHandler.disconnect(false);
|
||||||
}
|
}
|
||||||
CardRepository.instance.closeDB();
|
CardRepository.instance.closeDB();
|
||||||
tablesPane.cleanUp();
|
tablesPane.cleanUp();
|
||||||
|
|
@ -1502,7 +1498,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
break;
|
break;
|
||||||
case CLIENT_REMOVE_TABLE:
|
case CLIENT_REMOVE_TABLE:
|
||||||
session.removeTable(userRequestMessage.getRoomId(), userRequestMessage.getTableId());
|
SessionHandler.removeTable(userRequestMessage.getRoomId(), userRequestMessage.getTableId());
|
||||||
break;
|
break;
|
||||||
case CLIENT_RECONNECT:
|
case CLIENT_RECONNECT:
|
||||||
if (performConnect()) {
|
if (performConnect()) {
|
||||||
|
|
@ -1510,11 +1506,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CLIENT_REPLAY_ACTION:
|
case CLIENT_REPLAY_ACTION:
|
||||||
session.stopReplay(userRequestMessage.getGameId());
|
SessionHandler.stopReplay(userRequestMessage.getGameId());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (session != null && playerAction != null) {
|
if (SessionHandler.getSession() != null && playerAction != null) {
|
||||||
session.sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
|
SessionHandler.sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
311
Mage.Client/src/main/java/mage/client/SessionHandler.java
Normal file
311
Mage.Client/src/main/java/mage/client/SessionHandler.java
Normal file
|
|
@ -0,0 +1,311 @@
|
||||||
|
package mage.client;
|
||||||
|
|
||||||
|
import mage.cards.decks.DeckCardLists;
|
||||||
|
import mage.constants.PlayerAction;
|
||||||
|
import mage.game.match.MatchOptions;
|
||||||
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
import mage.players.net.UserData;
|
||||||
|
import mage.remote.Connection;
|
||||||
|
import mage.remote.MageRemoteException;
|
||||||
|
import mage.remote.Session;
|
||||||
|
import mage.remote.SessionImpl;
|
||||||
|
import mage.view.*;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by IGOUDT on 15-9-2016.
|
||||||
|
*/
|
||||||
|
public class SessionHandler {
|
||||||
|
|
||||||
|
private static Session session;
|
||||||
|
|
||||||
|
public static void startSession(MageFrame mageFrame) {
|
||||||
|
|
||||||
|
session = new SessionImpl(mageFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ping() {
|
||||||
|
session.ping();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Session getSession() {
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isConnected() {
|
||||||
|
return session.isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getVersionInfo() {
|
||||||
|
return session.getVersionInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean connect(Connection connection) {
|
||||||
|
return session.connect(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean stopConnecting() {
|
||||||
|
return session.stopConnecting();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void disconnect(boolean showmessage) {
|
||||||
|
session.disconnect(showmessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPlayerAction(PlayerAction playerAction, UUID gameId, Object relatedUserId) {
|
||||||
|
session.sendPlayerAction(playerAction, gameId, relatedUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void quitTournament(UUID tournamentId) {
|
||||||
|
session.quitTournament(tournamentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void quitDraft(UUID tournamentId) {
|
||||||
|
session.quitDraft(tournamentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void quitMatch(UUID gameId) {
|
||||||
|
session.quitMatch(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void stopWatching(UUID gameId) {
|
||||||
|
session.stopWatching(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeTable(UUID roomId, UUID tableId) {
|
||||||
|
session.removeTable(roomId, tableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void stopReplay(UUID gameId) {
|
||||||
|
session.stopReplay(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPlayerUUID(UUID gameId, UUID id) {
|
||||||
|
session.sendPlayerUUID(gameId, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPlayerBoolean(UUID gameId, boolean b) {
|
||||||
|
session.sendPlayerBoolean(gameId, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getPlayerTypes() {
|
||||||
|
return session.getPlayerTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean joinTournamentTable(UUID roomId, UUID tableId, String text, String selectedItem, Integer integer, DeckCardLists deckCardLists, String s) {
|
||||||
|
return session.joinTournamentTable(roomId, tableId, text, selectedItem, integer, deckCardLists, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPlayerInteger(UUID gameId, int data) {
|
||||||
|
session.sendPlayerInteger(gameId, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPlayerString(UUID gameId, String data) {
|
||||||
|
session.sendPlayerString(gameId, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean sendFeedback(String title, String type, String message, String email) {
|
||||||
|
return session.sendFeedback(title, type, message, email);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void swapSeats(UUID roomId, UUID tableId, int row, int targetrow) {
|
||||||
|
session.swapSeats(roomId, tableId, row, targetrow);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean leaveTable(UUID roomId, UUID tableId) {
|
||||||
|
return session.leaveTable(roomId, tableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updatePreferencesForServer(UserData userData) {
|
||||||
|
session.updatePreferencesForServer(userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTableOwner(UUID roomId, UUID tableId) {
|
||||||
|
return session.isTableOwner(roomId, tableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID getTableChatId(UUID tableId) {
|
||||||
|
return session.getTableChatId(tableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean startTournament(UUID roomId, UUID tableId) {
|
||||||
|
return session.startTournament(roomId, tableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean startMatch(UUID roomId, UUID tableId) {
|
||||||
|
return session.startMatch(roomId, tableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID getGameChatId(UUID gameId) {
|
||||||
|
return session.getGameChatId(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean joinGame(UUID gameId) {
|
||||||
|
return session.joinGame(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean startReplay(UUID gameId) {
|
||||||
|
return session.startReplay(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void watchTournamentTable(UUID tableId) {
|
||||||
|
session.watchTournamentTable(tableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean joinTournament(UUID tournamentId) {
|
||||||
|
return session.joinTournament(tournamentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID getTournamentChatId(UUID tournamentId) {
|
||||||
|
return session.getTournamentChatId(tournamentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TournamentView getTournament(UUID tournamentId) {
|
||||||
|
try {
|
||||||
|
return session.getTournament(tournamentId);
|
||||||
|
} catch (MageRemoteException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUserName() {
|
||||||
|
return session.getUserName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean watchGame(UUID gameId) {
|
||||||
|
return session.watchGame(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void nextPlay(UUID gameId) {
|
||||||
|
session.nextPlay(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void previousPlay(UUID gameId) {
|
||||||
|
session.previousPlay(gameId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void skipForward(UUID gameId, int i) {
|
||||||
|
session.skipForward(gameId, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTestMode() {
|
||||||
|
return session.isTestMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void cheat(UUID gameId, UUID playerId, DeckCardLists deckCardLists) {
|
||||||
|
session.cheat(gameId, playerId, deckCardLists);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSessionId() {
|
||||||
|
return session.getSessionId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<TournamentTypeView> getTournamentTypes() {
|
||||||
|
return session.getTournamentTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean submitDeck(UUID tableId, DeckCardLists deckCardLists) {
|
||||||
|
return session.submitDeck(tableId, deckCardLists);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getDeckTypes() {
|
||||||
|
return session.getDeckTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getDraftCubes() {
|
||||||
|
return session.getDraftCubes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<GameTypeView> getTournamentGameTypes() {
|
||||||
|
return session.getTournamentGameTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TableView createTournamentTable(UUID roomId, TournamentOptions tOptions) {
|
||||||
|
return session.createTournamentTable(roomId, tOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TableView createTable(UUID roomId, MatchOptions options) {
|
||||||
|
return session.createTable(roomId, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean joinTable(UUID roomId, UUID tableId, String playerName, String human, int skill, DeckCardLists deckCardLists, String text) {
|
||||||
|
return session.joinTable(roomId, tableId, playerName, human, skill, deckCardLists, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<GameTypeView> getGameTypes() {
|
||||||
|
return session.getGameTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean joinDraft(UUID draftId) {
|
||||||
|
return session.joinDraft(draftId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DraftPickView sendCardPick(UUID draftId, UUID id, Set<UUID> cardsHidden) {
|
||||||
|
return session.sendCardPick(draftId, id, cardsHidden);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendCardMark(UUID draftId, UUID id) {
|
||||||
|
session.sendCardMark(draftId, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID getRoomChatId(UUID roomId) {
|
||||||
|
return session.getRoomChatId(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Collection<RoomUsersView> getRoomUsers(UUID roomId) {
|
||||||
|
try {
|
||||||
|
return session.getRoomUsers(roomId);
|
||||||
|
} catch (MageRemoteException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Collection<MatchView> getFinishedMatches(UUID roomId) {
|
||||||
|
try {
|
||||||
|
return session.getFinishedMatches(roomId);
|
||||||
|
} catch (MageRemoteException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void replayGame(UUID id) {
|
||||||
|
session.replayGame(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void watchTable(UUID roomId, UUID tableId) {
|
||||||
|
session.watchTable(roomId, tableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Collection<TableView> getTables(UUID roomId) {
|
||||||
|
try {
|
||||||
|
return session.getTables(roomId);
|
||||||
|
} catch (MageRemoteException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getServerMessages() {
|
||||||
|
return session.getServerMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean joinChat(UUID chatId) {
|
||||||
|
return session.joinChat(chatId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean leaveChat(UUID chatId) {
|
||||||
|
return session.leaveChat(chatId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean sendChatMessage(UUID chatId, String text) {
|
||||||
|
return session.sendChatMessage(chatId, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -101,7 +101,6 @@ import org.apache.log4j.Logger;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener {
|
public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener {
|
||||||
|
|
||||||
protected static Session session = MageFrame.getSession();
|
|
||||||
protected static DefaultActionCallback callback = DefaultActionCallback.getInstance();
|
protected static DefaultActionCallback callback = DefaultActionCallback.getInstance();
|
||||||
|
|
||||||
protected Point p;
|
protected Point p;
|
||||||
|
|
@ -401,7 +400,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
requestFocusInWindow();
|
requestFocusInWindow();
|
||||||
callback.mouseClicked(e, gameId, session, card);
|
callback.mouseClicked(e, gameId, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ import java.awt.event.KeyEvent;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.remote.Session;
|
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.ChatMessage.MessageType;
|
import mage.view.ChatMessage.MessageType;
|
||||||
import org.mage.card.arcane.ManaSymbols;
|
import org.mage.card.arcane.ManaSymbols;
|
||||||
|
|
@ -53,7 +53,6 @@ import org.mage.card.arcane.ManaSymbols;
|
||||||
public class ChatPanelBasic extends javax.swing.JPanel {
|
public class ChatPanelBasic extends javax.swing.JPanel {
|
||||||
|
|
||||||
protected UUID chatId;
|
protected UUID chatId;
|
||||||
protected Session session;
|
|
||||||
/**
|
/**
|
||||||
* Chat message color for opponents.
|
* Chat message color for opponents.
|
||||||
*/
|
*/
|
||||||
|
|
@ -172,16 +171,15 @@ public class ChatPanelBasic extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(UUID chatId) {
|
public void connect(UUID chatId) {
|
||||||
session = MageFrame.getSession();
|
|
||||||
this.chatId = chatId;
|
this.chatId = chatId;
|
||||||
if (session.joinChat(chatId)) {
|
if (SessionHandler.joinChat(chatId)) {
|
||||||
MageFrame.addChat(chatId, this);
|
MageFrame.addChat(chatId, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
if (session != null) {
|
if (SessionHandler.getSession() != null) {
|
||||||
session.leaveChat(chatId);
|
SessionHandler.leaveChat(chatId);
|
||||||
MageFrame.removeChat(chatId);
|
MageFrame.removeChat(chatId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -216,9 +214,9 @@ public class ChatPanelBasic extends javax.swing.JPanel {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (parentChatRef != null) {
|
if (parentChatRef != null) {
|
||||||
userColor = parentChatRef.session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||||
} else {
|
} else {
|
||||||
userColor = session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||||
}
|
}
|
||||||
textColor = MESSAGE_COLOR;
|
textColor = MESSAGE_COLOR;
|
||||||
userSeparator = ": ";
|
userSeparator = ": ";
|
||||||
|
|
@ -343,9 +341,9 @@ public class ChatPanelBasic extends javax.swing.JPanel {
|
||||||
public void handleKeyTyped(java.awt.event.KeyEvent evt) {
|
public void handleKeyTyped(java.awt.event.KeyEvent evt) {
|
||||||
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
|
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
|
||||||
if (parentChatRef != null) {
|
if (parentChatRef != null) {
|
||||||
parentChatRef.session.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
|
SessionHandler.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
|
||||||
} else {
|
} else {
|
||||||
session.sendChatMessage(chatId, this.txtMessage.getText());
|
SessionHandler.sendChatMessage(chatId, this.txtMessage.getText());
|
||||||
}
|
}
|
||||||
this.txtMessage.setText("");
|
this.txtMessage.setText("");
|
||||||
this.txtMessage.repaint();
|
this.txtMessage.repaint();
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
package mage.client.chat;
|
package mage.client.chat;
|
||||||
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.components.ColorPane;
|
import mage.client.components.ColorPane;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.view.ChatMessage;
|
import mage.view.ChatMessage;
|
||||||
|
|
@ -78,9 +80,9 @@ public class ChatPanelSeparated extends ChatPanelBasic {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (parentChatRef != null) {
|
if (parentChatRef != null) {
|
||||||
userColor = parentChatRef.session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||||
} else {
|
} else {
|
||||||
userColor = session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||||
}
|
}
|
||||||
textColor = MESSAGE_COLOR;
|
textColor = MESSAGE_COLOR;
|
||||||
userSeparator = ": ";
|
userSeparator = ": ";
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,8 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Session session, UUID gameId) {
|
public void init(UUID gameId) {
|
||||||
this.session = session;
|
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.cards.ICardGrid;
|
import mage.client.cards.ICardGrid;
|
||||||
import mage.client.constants.Constants.DeckEditorMode;
|
import mage.client.constants.Constants.DeckEditorMode;
|
||||||
|
|
@ -168,7 +169,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
this.btnExit.setVisible(false);
|
this.btnExit.setVisible(false);
|
||||||
this.btnImport.setVisible(false);
|
this.btnImport.setVisible(false);
|
||||||
this.btnGenDeck.setVisible(false);
|
this.btnGenDeck.setVisible(false);
|
||||||
if (!MageFrame.getSession().isTestMode()) {
|
if (!SessionHandler.isTestMode()) {
|
||||||
this.btnLoad.setVisible(false);
|
this.btnLoad.setVisible(false);
|
||||||
}
|
}
|
||||||
this.deckArea.showSideboard(false);
|
this.deckArea.showSideboard(false);
|
||||||
|
|
@ -178,7 +179,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
if (timeout != 0) {
|
if (timeout != 0) {
|
||||||
countdown.start();
|
countdown.start();
|
||||||
if (updateDeckTask == null || updateDeckTask.isDone()) {
|
if (updateDeckTask == null || updateDeckTask.isDone()) {
|
||||||
updateDeckTask = new UpdateDeckTask(MageFrame.getSession(), tableId, deck);
|
updateDeckTask = new UpdateDeckTask(SessionHandler.getSession(), tableId, deck);
|
||||||
updateDeckTask.execute();
|
updateDeckTask.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +193,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
this.btnExit.setVisible(true);
|
this.btnExit.setVisible(true);
|
||||||
this.btnImport.setVisible(true);
|
this.btnImport.setVisible(true);
|
||||||
this.btnGenDeck.setVisible(true);
|
this.btnGenDeck.setVisible(true);
|
||||||
if (!MageFrame.getSession().isTestMode()) {
|
if (!SessionHandler.isTestMode()) {
|
||||||
this.btnLoad.setVisible(true);
|
this.btnLoad.setVisible(true);
|
||||||
}
|
}
|
||||||
this.deckArea.showSideboard(true);
|
this.deckArea.showSideboard(true);
|
||||||
|
|
@ -841,7 +842,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
updateDeckTask.cancel(true);
|
updateDeckTask.cancel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists())) {
|
if (SessionHandler.submitDeck(tableId, deck.getDeckCardLists())) {
|
||||||
removeDeckEditor();
|
removeDeckEditor();
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnSubmitActionPerformed
|
}//GEN-LAST:event_btnSubmitActionPerformed
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
@ -254,7 +255,7 @@ public class FeedbackDialog extends javax.swing.JDialog {
|
||||||
if (email.length() > 100) {
|
if (email.length() > 100) {
|
||||||
email = email.substring(0, 100);
|
email = email.substring(0, 100);
|
||||||
}
|
}
|
||||||
if (MageFrame.getSession().sendFeedback(title, type, message, email)) {
|
if (SessionHandler.sendFeedback(title, type, message, email)) {
|
||||||
JOptionPane.showMessageDialog(null, "Feedback was sent. Thank you!", "Success", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Feedback was sent. Thank you!", "Success", JOptionPane.INFORMATION_MESSAGE);
|
||||||
reset();
|
reset();
|
||||||
dialog.setVisible(false);
|
dialog.setVisible(false);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import java.util.UUID;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ public class JoinTableDialog extends MageDialog {
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.tableId = tableId;
|
this.tableId = tableId;
|
||||||
this.isTournament = isTournament;
|
this.isTournament = isTournament;
|
||||||
this.newPlayerPanel.setPlayerName(MageFrame.getSession().getUserName());
|
this.newPlayerPanel.setPlayerName(SessionHandler.getUserName());
|
||||||
this.newPlayerPanel.showDeckElements(!isLimited);
|
this.newPlayerPanel.showDeckElements(!isLimited);
|
||||||
this.setModal(true);
|
this.setModal(true);
|
||||||
this.setLocation(100, 100);
|
this.setLocation(100, 100);
|
||||||
|
|
@ -146,7 +147,7 @@ public class JoinTableDialog extends MageDialog {
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||||
Session session = MageFrame.getSession();
|
Session session = SessionHandler.getSession();
|
||||||
try {
|
try {
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText());
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText());
|
||||||
if (isTournament) {
|
if (isTournament) {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ import javax.swing.*;
|
||||||
|
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.table.TablePlayerPanel;
|
import mage.client.table.TablePlayerPanel;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
|
|
@ -47,7 +48,6 @@ import mage.constants.MultiplayerAttackOption;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
import mage.constants.SkillLevel;
|
import mage.constants.SkillLevel;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.remote.Session;
|
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -63,7 +63,6 @@ public class NewTableDialog extends MageDialog {
|
||||||
private TableView table;
|
private TableView table;
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private UUID roomId;
|
private UUID roomId;
|
||||||
private final Session session;
|
|
||||||
private String lastSessionId;
|
private String lastSessionId;
|
||||||
private final List<TablePlayerPanel> players = new ArrayList<>();
|
private final List<TablePlayerPanel> players = new ArrayList<>();
|
||||||
private final List<String> prefPlayerTypes = new ArrayList<>();
|
private final List<String> prefPlayerTypes = new ArrayList<>();
|
||||||
|
|
@ -74,7 +73,6 @@ public class NewTableDialog extends MageDialog {
|
||||||
* Creates new form NewTableDialog
|
* Creates new form NewTableDialog
|
||||||
*/
|
*/
|
||||||
public NewTableDialog() {
|
public NewTableDialog() {
|
||||||
session = MageFrame.getSession();
|
|
||||||
lastSessionId = "";
|
lastSessionId = "";
|
||||||
initComponents();
|
initComponents();
|
||||||
player1Panel.showLevel(false);
|
player1Panel.showLevel(false);
|
||||||
|
|
@ -402,13 +400,13 @@ public class NewTableDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
saveGameSettingsToPrefs(options, this.player1Panel.getDeckFile());
|
saveGameSettingsToPrefs(options, this.player1Panel.getDeckFile());
|
||||||
|
|
||||||
table = session.createTable(roomId, options);
|
table = SessionHandler.createTable(roomId, options);
|
||||||
if (table == null) {
|
if (table == null) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (session.joinTable(
|
if (SessionHandler.joinTable(
|
||||||
roomId,
|
roomId,
|
||||||
table.getTableId(),
|
table.getTableId(),
|
||||||
this.player1Panel.getPlayerName(),
|
this.player1Panel.getPlayerName(),
|
||||||
|
|
@ -419,7 +417,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
if (!player.getPlayerType().equals("Human")) {
|
if (!player.getPlayerType().equals("Human")) {
|
||||||
if (!player.joinTable(roomId, table.getTableId())) {
|
if (!player.joinTable(roomId, table.getTableId())) {
|
||||||
// error message must be send by the server
|
// error message must be send by the server
|
||||||
session.removeTable(roomId, table.getTableId());
|
SessionHandler.removeTable(roomId, table.getTableId());
|
||||||
table = null;
|
table = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -436,7 +434,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
}
|
}
|
||||||
// JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
// JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
session.removeTable(roomId, table.getTableId());
|
SessionHandler.removeTable(roomId, table.getTableId());
|
||||||
table = null;
|
table = null;
|
||||||
}//GEN-LAST:event_btnOKActionPerformed
|
}//GEN-LAST:event_btnOKActionPerformed
|
||||||
|
|
||||||
|
|
@ -560,11 +558,11 @@ public class NewTableDialog extends MageDialog {
|
||||||
|
|
||||||
public void showDialog(UUID roomId) {
|
public void showDialog(UUID roomId) {
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
if (!lastSessionId.equals(MageFrame.getSession().getSessionId())) {
|
if (!lastSessionId.equals(SessionHandler.getSessionId())) {
|
||||||
lastSessionId = session.getSessionId();
|
lastSessionId = SessionHandler.getSessionId();
|
||||||
this.player1Panel.setPlayerName(session.getUserName());
|
this.player1Panel.setPlayerName(SessionHandler.getUserName());
|
||||||
cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes().toArray()));
|
cbGameType.setModel(new DefaultComboBoxModel(SessionHandler.getGameTypes().toArray()));
|
||||||
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
|
cbDeckType.setModel(new DefaultComboBoxModel(SessionHandler.getDeckTypes()));
|
||||||
selectLimitedByDefault();
|
selectLimitedByDefault();
|
||||||
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
||||||
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
|
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
|
||||||
|
|
@ -614,7 +612,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2")));
|
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2")));
|
||||||
|
|
||||||
String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, "Two Player Duel");
|
String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, "Two Player Duel");
|
||||||
for (GameTypeView gtv : session.getGameTypes()) {
|
for (GameTypeView gtv : SessionHandler.getGameTypes()) {
|
||||||
if (gtv.getName().equals(gameTypeName)) {
|
if (gtv.getName().equals(gameTypeName)) {
|
||||||
cbGameType.setSelectedItem(gtv);
|
cbGameType.setSelectedItem(gtv);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.cards.repository.ExpansionInfo;
|
import mage.cards.repository.ExpansionInfo;
|
||||||
import mage.cards.repository.ExpansionRepository;
|
import mage.cards.repository.ExpansionRepository;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.table.TournamentPlayerPanel;
|
import mage.client.table.TournamentPlayerPanel;
|
||||||
import mage.constants.MatchTimeLimit;
|
import mage.constants.MatchTimeLimit;
|
||||||
import mage.constants.MultiplayerAttackOption;
|
import mage.constants.MultiplayerAttackOption;
|
||||||
|
|
@ -81,7 +82,6 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
private TableView table;
|
private TableView table;
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private UUID roomId;
|
private UUID roomId;
|
||||||
private final Session session;
|
|
||||||
private String lastSessionId;
|
private String lastSessionId;
|
||||||
private RandomPacksSelectorDialog randomPackSelector;
|
private RandomPacksSelectorDialog randomPackSelector;
|
||||||
private JTextArea txtRandomPacks;
|
private JTextArea txtRandomPacks;
|
||||||
|
|
@ -97,7 +97,6 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
/** Creates new form NewTournamentDialog */
|
/** Creates new form NewTournamentDialog */
|
||||||
public NewTournamentDialog() {
|
public NewTournamentDialog() {
|
||||||
initComponents();
|
initComponents();
|
||||||
session = MageFrame.getSession();
|
|
||||||
lastSessionId = "";
|
lastSessionId = "";
|
||||||
txtName.setText("Tournament");
|
txtName.setText("Tournament");
|
||||||
this.spnNumWins.setModel(new SpinnerNumberModel(2, 1, 5, 1));
|
this.spnNumWins.setModel(new SpinnerNumberModel(2, 1, 5, 1));
|
||||||
|
|
@ -109,18 +108,18 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
|
|
||||||
public void showDialog(UUID roomId) {
|
public void showDialog(UUID roomId) {
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
if (!lastSessionId.equals(MageFrame.getSession().getSessionId())) {
|
if (!lastSessionId.equals(SessionHandler.getSessionId())) {
|
||||||
lastSessionId = session.getSessionId();
|
lastSessionId = SessionHandler.getSessionId();
|
||||||
this.player1Panel.setPlayerName(session.getUserName());
|
this.player1Panel.setPlayerName(SessionHandler.getUserName());
|
||||||
this.player1Panel.showLevel(false); // no computer
|
this.player1Panel.showLevel(false); // no computer
|
||||||
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
|
cbTournamentType.setModel(new DefaultComboBoxModel(SessionHandler.getTournamentTypes().toArray()));
|
||||||
|
|
||||||
cbGameType.setModel(new DefaultComboBoxModel(session.getTournamentGameTypes().toArray()));
|
cbGameType.setModel(new DefaultComboBoxModel(SessionHandler.getTournamentGameTypes().toArray()));
|
||||||
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
|
cbDeckType.setModel(new DefaultComboBoxModel(SessionHandler.getDeckTypes()));
|
||||||
|
|
||||||
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
||||||
cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values()));
|
cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values()));
|
||||||
cbDraftCube.setModel(new DefaultComboBoxModel(session.getDraftCubes()));
|
cbDraftCube.setModel(new DefaultComboBoxModel(SessionHandler.getDraftCubes()));
|
||||||
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
|
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
|
||||||
// update player types
|
// update player types
|
||||||
int i=2;
|
int i=2;
|
||||||
|
|
@ -618,12 +617,12 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
tOptions.getMatchOptions().setRated(this.chkRated.isSelected());
|
tOptions.getMatchOptions().setRated(this.chkRated.isSelected());
|
||||||
saveTournamentSettingsToPrefs(tOptions);
|
saveTournamentSettingsToPrefs(tOptions);
|
||||||
|
|
||||||
table = session.createTournamentTable(roomId, tOptions);
|
table = SessionHandler.createTournamentTable(roomId, tOptions);
|
||||||
if (table == null) {
|
if (table == null) {
|
||||||
// message must be send by server!
|
// message must be send by server!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (session.joinTournamentTable(
|
if (SessionHandler.joinTournamentTable(
|
||||||
roomId,
|
roomId,
|
||||||
table.getTableId(),
|
table.getTableId(),
|
||||||
this.player1Panel.getPlayerName(),
|
this.player1Panel.getPlayerName(),
|
||||||
|
|
@ -634,7 +633,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
if (!player.getPlayerType().toString().equals("Human")) {
|
if (!player.getPlayerType().toString().equals("Human")) {
|
||||||
if (!player.joinTournamentTable(roomId, table.getTableId(), DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
|
if (!player.joinTournamentTable(roomId, table.getTableId(), DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
|
||||||
// error message must be send by sever
|
// error message must be send by sever
|
||||||
session.removeTable(roomId, table.getTableId());
|
SessionHandler.removeTable(roomId, table.getTableId());
|
||||||
table = null;
|
table = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -644,7 +643,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
session.removeTable(roomId, table.getTableId());
|
SessionHandler.removeTable(roomId, table.getTableId());
|
||||||
table = null;
|
table = null;
|
||||||
}//GEN-LAST:event_btnOkActionPerformed
|
}//GEN-LAST:event_btnOkActionPerformed
|
||||||
|
|
||||||
|
|
@ -978,7 +977,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
this.spnConstructTime.setValue(constructionTime);
|
this.spnConstructTime.setValue(constructionTime);
|
||||||
String tournamentTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, "Sealed Elimination");
|
String tournamentTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, "Sealed Elimination");
|
||||||
for (TournamentTypeView tournamentTypeView : session.getTournamentTypes()) {
|
for (TournamentTypeView tournamentTypeView : SessionHandler.getTournamentTypes()) {
|
||||||
if (tournamentTypeView.getName().equals(tournamentTypeName)) {
|
if (tournamentTypeView.getName().equals(tournamentTypeName)) {
|
||||||
cbTournamentType.setSelectedItem(tournamentTypeView);
|
cbTournamentType.setSelectedItem(tournamentTypeView);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ import javax.swing.JTextField;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
|
|
@ -2627,7 +2628,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
updateCache(KEY_AVATAR, String.valueOf(selectedAvatarId));
|
updateCache(KEY_AVATAR, String.valueOf(selectedAvatarId));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MageFrame.getSession().updatePreferencesForServer(getUserData());
|
SessionHandler.updatePreferencesForServer(getUserData());
|
||||||
|
|
||||||
prefs.flush();
|
prefs.flush();
|
||||||
} catch (BackingStoreException ex) {
|
} catch (BackingStoreException ex) {
|
||||||
|
|
@ -3428,7 +3429,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
if (selectedAvatarId != id) {
|
if (selectedAvatarId != id) {
|
||||||
setSelectedId(id);
|
setSelectedId(id);
|
||||||
MageFrame.getSession().updatePreferencesForServer(getUserData());
|
SessionHandler.updatePreferencesForServer(getUserData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ 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.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;
|
||||||
|
|
@ -68,7 +69,6 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
private UUID tableId;
|
private UUID tableId;
|
||||||
private UUID roomId;
|
private UUID roomId;
|
||||||
private boolean isTournament;
|
private boolean isTournament;
|
||||||
private Session session;
|
|
||||||
private final TableWaitModel tableWaitModel;
|
private final TableWaitModel tableWaitModel;
|
||||||
private UpdateSeatsTask updateTask;
|
private UpdateSeatsTask updateTask;
|
||||||
|
|
||||||
|
|
@ -77,7 +77,6 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
*/
|
*/
|
||||||
public TableWaitingDialog() {
|
public TableWaitingDialog() {
|
||||||
|
|
||||||
session = MageFrame.getSession();
|
|
||||||
tableWaitModel = new TableWaitModel();
|
tableWaitModel = new TableWaitModel();
|
||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
@ -150,9 +149,8 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.tableId = tableId;
|
this.tableId = tableId;
|
||||||
this.isTournament = isTournament;
|
this.isTournament = isTournament;
|
||||||
session = MageFrame.getSession();
|
updateTask = new UpdateSeatsTask(SessionHandler.getSession(), roomId, tableId, this);
|
||||||
updateTask = new UpdateSeatsTask(session, roomId, tableId, this);
|
if (SessionHandler.isTableOwner(roomId, tableId)) {
|
||||||
if (session.isTableOwner(roomId, tableId)) {
|
|
||||||
this.btnStart.setVisible(true);
|
this.btnStart.setVisible(true);
|
||||||
this.btnMoveDown.setVisible(true);
|
this.btnMoveDown.setVisible(true);
|
||||||
this.btnMoveUp.setVisible(true);
|
this.btnMoveUp.setVisible(true);
|
||||||
|
|
@ -161,7 +159,7 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
this.btnMoveDown.setVisible(false);
|
this.btnMoveDown.setVisible(false);
|
||||||
this.btnMoveUp.setVisible(false);
|
this.btnMoveUp.setVisible(false);
|
||||||
}
|
}
|
||||||
UUID chatId = session.getTableChatId(tableId);
|
UUID chatId = SessionHandler.getTableChatId(tableId);
|
||||||
if (chatId != null) {
|
if (chatId != null) {
|
||||||
this.chatPanel.connect(chatId);
|
this.chatPanel.connect(chatId);
|
||||||
updateTask.execute();
|
updateTask.execute();
|
||||||
|
|
@ -283,17 +281,17 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
|
|
||||||
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
|
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
|
||||||
if (!isTournament) {
|
if (!isTournament) {
|
||||||
if (session.startMatch(roomId, tableId)) {
|
if (SessionHandler.startMatch(roomId, tableId)) {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
} else if (session.startTournament(roomId, tableId)) {
|
} else if (SessionHandler.startTournament(roomId, tableId)) {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnStartActionPerformed
|
}//GEN-LAST:event_btnStartActionPerformed
|
||||||
|
|
||||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
try {
|
try {
|
||||||
if (!session.leaveTable(roomId, tableId)) {
|
if (!SessionHandler.leaveTable(roomId, tableId)) {
|
||||||
return; // already started, so leave no more possible
|
return; // already started, so leave no more possible
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -306,7 +304,7 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
private void btnMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveDownActionPerformed
|
private void btnMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveDownActionPerformed
|
||||||
int row = this.tableSeats.getSelectedRow();
|
int row = this.tableSeats.getSelectedRow();
|
||||||
if (row < this.tableSeats.getRowCount() - 1) {
|
if (row < this.tableSeats.getRowCount() - 1) {
|
||||||
session.swapSeats(roomId, tableId, row, row + 1);
|
SessionHandler.swapSeats(roomId, tableId, row, row + 1);
|
||||||
this.tableSeats.getSelectionModel().setSelectionInterval(row + 1, row + 1);
|
this.tableSeats.getSelectionModel().setSelectionInterval(row + 1, row + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -315,7 +313,7 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
private void btnMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveUpActionPerformed
|
private void btnMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveUpActionPerformed
|
||||||
int row = this.tableSeats.getSelectedRow();
|
int row = this.tableSeats.getSelectedRow();
|
||||||
if (row > 0) {
|
if (row > 0) {
|
||||||
session.swapSeats(roomId, tableId, row, row - 1);
|
SessionHandler.swapSeats(roomId, tableId, row, row - 1);
|
||||||
this.tableSeats.getSelectionModel().setSelectionInterval(row - 1, row - 1);
|
this.tableSeats.getSelectionModel().setSelectionInterval(row - 1, row - 1);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnMoveUpActionPerformed
|
}//GEN-LAST:event_btnMoveUpActionPerformed
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ import javax.swing.Timer;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.components.tray.MageTray;
|
import mage.client.components.tray.MageTray;
|
||||||
import mage.client.deckeditor.SortSettingDraft;
|
import mage.client.deckeditor.SortSettingDraft;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
|
@ -75,7 +76,6 @@ import mage.client.util.Listener;
|
||||||
import mage.client.util.audio.AudioManager;
|
import mage.client.util.audio.AudioManager;
|
||||||
import mage.client.util.gui.BufferedImageBuilder;
|
import mage.client.util.gui.BufferedImageBuilder;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
import mage.remote.Session;
|
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
import mage.view.DraftPickView;
|
import mage.view.DraftPickView;
|
||||||
import mage.view.DraftView;
|
import mage.view.DraftView;
|
||||||
|
|
@ -93,7 +93,6 @@ public class DraftPanel extends javax.swing.JPanel {
|
||||||
private static final Logger LOGGER = Logger.getLogger(DraftPanel.class);
|
private static final Logger LOGGER = Logger.getLogger(DraftPanel.class);
|
||||||
|
|
||||||
private UUID draftId;
|
private UUID draftId;
|
||||||
private Session session;
|
|
||||||
private Timer countdown;
|
private Timer countdown;
|
||||||
private int timeout;
|
private int timeout;
|
||||||
|
|
||||||
|
|
@ -183,9 +182,8 @@ public class DraftPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public synchronized void showDraft(UUID draftId) {
|
public synchronized void showDraft(UUID draftId) {
|
||||||
this.draftId = draftId;
|
this.draftId = draftId;
|
||||||
session = MageFrame.getSession();
|
|
||||||
MageFrame.addDraft(draftId, this);
|
MageFrame.addDraft(draftId, this);
|
||||||
if (!session.joinDraft(draftId)) {
|
if (!SessionHandler.joinDraft(draftId)) {
|
||||||
hideDraft();
|
hideDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,7 +332,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
||||||
public void event(Event event) {
|
public void event(Event event) {
|
||||||
if (event.getEventName().equals("pick-a-card")) {
|
if (event.getEventName().equals("pick-a-card")) {
|
||||||
SimpleCardView source = (SimpleCardView) event.getSource();
|
SimpleCardView source = (SimpleCardView) event.getSource();
|
||||||
DraftPickView view = session.sendCardPick(draftId, source.getId(), cardsHidden);
|
DraftPickView view = SessionHandler.sendCardPick(draftId, source.getId(), cardsHidden);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
loadCardsToPickedCardsArea(view.getPicks());
|
loadCardsToPickedCardsArea(view.getPicks());
|
||||||
draftBooster.loadBooster(EMPTY_VIEW, bigCard);
|
draftBooster.loadBooster(EMPTY_VIEW, bigCard);
|
||||||
|
|
@ -344,7 +342,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
if (event.getEventName().equals("mark-a-card")) {
|
if (event.getEventName().equals("mark-a-card")) {
|
||||||
SimpleCardView source = (SimpleCardView) event.getSource();
|
SimpleCardView source = (SimpleCardView) event.getSource();
|
||||||
session.sendCardMark(draftId, source.getId());
|
SessionHandler.sendCardMark(draftId, source.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.remote.Session;
|
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.AbilityPickerView;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
@ -49,15 +49,13 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
||||||
|
|
||||||
private Session session;
|
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
|
|
||||||
public AbilityPicker(String ThisIsnotUsedAnymore) {
|
public AbilityPicker(String ThisIsnotUsedAnymore) {
|
||||||
this.addPopupMenuListener(this);
|
this.addPopupMenuListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Session session, UUID gameId) {
|
public void init(UUID gameId) {
|
||||||
this.session = session;
|
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +83,7 @@ public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||||
session.sendPlayerBoolean(gameId, false);
|
SessionHandler.sendPlayerBoolean(gameId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AbilityPickerAction extends AbstractAction {
|
private class AbilityPickerAction extends AbstractAction {
|
||||||
|
|
@ -99,7 +97,7 @@ public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
session.sendPlayerUUID(gameId, id);
|
SessionHandler.sendPlayerUUID(gameId, id);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.chat.ChatPanelBasic;
|
import mage.client.chat.ChatPanelBasic;
|
||||||
import mage.client.dialog.MageDialog;
|
import mage.client.dialog.MageDialog;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
|
|
@ -68,7 +69,6 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
private Session session;
|
|
||||||
private FeedbackMode mode;
|
private FeedbackMode mode;
|
||||||
private MageDialog connectedDialog;
|
private MageDialog connectedDialog;
|
||||||
private ChatPanelBasic connectedChatPanel;
|
private ChatPanelBasic connectedChatPanel;
|
||||||
|
|
@ -86,7 +86,6 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public void init(UUID gameId) {
|
public void init(UUID gameId) {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
session = MageFrame.getSession();
|
|
||||||
helper.init(gameId);
|
helper.init(gameId);
|
||||||
setGUISize();
|
setGUISize();
|
||||||
}
|
}
|
||||||
|
|
@ -295,29 +294,29 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
connectedDialog = null;
|
connectedDialog = null;
|
||||||
}
|
}
|
||||||
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
||||||
session.sendPlayerInteger(gameId, 0);
|
SessionHandler.sendPlayerInteger(gameId, 0);
|
||||||
} else if (mode == FeedbackMode.END) {
|
} else if (mode == FeedbackMode.END) {
|
||||||
GamePanel gamePanel = MageFrame.getGame(gameId);
|
GamePanel gamePanel = MageFrame.getGame(gameId);
|
||||||
if (gamePanel != null) {
|
if (gamePanel != null) {
|
||||||
gamePanel.removeGame();
|
gamePanel.removeGame();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
session.sendPlayerBoolean(gameId, false);
|
SessionHandler.sendPlayerBoolean(gameId, false);
|
||||||
}
|
}
|
||||||
//AudioManager.playButtonOk();
|
//AudioManager.playButtonOk();
|
||||||
}//GEN-LAST:event_btnRightActionPerformed
|
}//GEN-LAST:event_btnRightActionPerformed
|
||||||
|
|
||||||
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
||||||
session.sendPlayerBoolean(gameId, true);
|
SessionHandler.sendPlayerBoolean(gameId, true);
|
||||||
AudioManager.playButtonCancel();
|
AudioManager.playButtonCancel();
|
||||||
}//GEN-LAST:event_btnLeftActionPerformed
|
}//GEN-LAST:event_btnLeftActionPerformed
|
||||||
|
|
||||||
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
|
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
|
||||||
session.sendPlayerString(gameId, "special");
|
SessionHandler.sendPlayerString(gameId, "special");
|
||||||
}//GEN-LAST:event_btnSpecialActionPerformed
|
}//GEN-LAST:event_btnSpecialActionPerformed
|
||||||
|
|
||||||
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.UNDO, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.UNDO, gameId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHelperPanel(HelperPanel helper) {
|
public void setHelperPanel(HelperPanel helper) {
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ import mage.cards.Card;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.chat.ChatPanelBasic;
|
import mage.client.chat.ChatPanelBasic;
|
||||||
import mage.client.combat.CombatManager;
|
import mage.client.combat.CombatManager;
|
||||||
|
|
@ -124,7 +125,6 @@ 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.remote.Session;
|
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.AbilityPickerView;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
|
|
@ -170,7 +170,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
private final ArrayList<ShowCardsDialog> pickTarget = new ArrayList<>();
|
private final ArrayList<ShowCardsDialog> pickTarget = new ArrayList<>();
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
private UUID playerId; // playerId of the player
|
private UUID playerId; // playerId of the player
|
||||||
private Session session;
|
|
||||||
GamePane gamePane;
|
GamePane gamePane;
|
||||||
private ReplayTask replayTask;
|
private ReplayTask replayTask;
|
||||||
private final PickNumberDialog pickNumber;
|
private final PickNumberDialog pickNumber;
|
||||||
|
|
@ -488,11 +487,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.gamePane = gamePane;
|
this.gamePane = gamePane;
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
session = MageFrame.getSession();
|
|
||||||
MageFrame.addGame(gameId, this);
|
MageFrame.addGame(gameId, this);
|
||||||
this.feedbackPanel.init(gameId);
|
this.feedbackPanel.init(gameId);
|
||||||
this.feedbackPanel.clear();
|
this.feedbackPanel.clear();
|
||||||
this.abilityPicker.init(session, gameId);
|
this.abilityPicker.init(gameId);
|
||||||
|
|
||||||
this.btnConcede.setVisible(true);
|
this.btnConcede.setVisible(true);
|
||||||
this.btnStopWatching.setVisible(false);
|
this.btnStopWatching.setVisible(false);
|
||||||
|
|
@ -509,8 +507,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(session.getGameChatId(gameId));
|
this.gameChatPanel.connect(SessionHandler.getGameChatId(gameId));
|
||||||
if (!session.joinGame(gameId)) {
|
if (!SessionHandler.joinGame(gameId)) {
|
||||||
removeGame();
|
removeGame();
|
||||||
} else {
|
} else {
|
||||||
// play start sound
|
// play start sound
|
||||||
|
|
@ -522,7 +520,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.gamePane = gamePane;
|
this.gamePane = gamePane;
|
||||||
this.playerId = null;
|
this.playerId = null;
|
||||||
session = MageFrame.getSession();
|
|
||||||
MageFrame.addGame(gameId, this);
|
MageFrame.addGame(gameId, this);
|
||||||
this.feedbackPanel.init(gameId);
|
this.feedbackPanel.init(gameId);
|
||||||
this.feedbackPanel.clear();
|
this.feedbackPanel.clear();
|
||||||
|
|
@ -542,8 +539,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(session.getGameChatId(gameId));
|
this.gameChatPanel.connect(SessionHandler.getGameChatId(gameId));
|
||||||
if (!session.watchGame(gameId)) {
|
if (!SessionHandler.watchGame(gameId)) {
|
||||||
removeGame();
|
removeGame();
|
||||||
}
|
}
|
||||||
for (PlayAreaPanel panel : getPlayers().values()) {
|
for (PlayAreaPanel panel : getPlayers().values()) {
|
||||||
|
|
@ -554,7 +551,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
public synchronized void replayGame(UUID gameId) {
|
public synchronized void replayGame(UUID gameId) {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.playerId = null;
|
this.playerId = null;
|
||||||
session = MageFrame.getSession();
|
|
||||||
MageFrame.addGame(gameId, this);
|
MageFrame.addGame(gameId, this);
|
||||||
this.feedbackPanel.init(gameId);
|
this.feedbackPanel.init(gameId);
|
||||||
this.feedbackPanel.clear();
|
this.feedbackPanel.clear();
|
||||||
|
|
@ -564,7 +560,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.btnStopWatching.setVisible(false);
|
this.btnStopWatching.setVisible(false);
|
||||||
this.pnlReplay.setVisible(true);
|
this.pnlReplay.setVisible(true);
|
||||||
this.gameChatPanel.clear();
|
this.gameChatPanel.clear();
|
||||||
if (!session.startReplay(gameId)) {
|
if (!SessionHandler.startReplay(gameId)) {
|
||||||
removeGame();
|
removeGame();
|
||||||
}
|
}
|
||||||
for (PlayAreaPanel panel : getPlayers().values()) {
|
for (PlayAreaPanel panel : getPlayers().values()) {
|
||||||
|
|
@ -1286,9 +1282,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
public void getAmount(int min, int max, String message) {
|
public void getAmount(int min, int max, String message) {
|
||||||
pickNumber.showDialog(min, max, message);
|
pickNumber.showDialog(min, max, message);
|
||||||
if (pickNumber.isCancel()) {
|
if (pickNumber.isCancel()) {
|
||||||
session.sendPlayerBoolean(gameId, false);
|
SessionHandler.sendPlayerBoolean(gameId, false);
|
||||||
} else {
|
} else {
|
||||||
session.sendPlayerInteger(gameId, pickNumber.getAmount());
|
SessionHandler.sendPlayerInteger(gameId, pickNumber.getAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1298,12 +1294,12 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pickChoice.showDialog(choice, objectId, choiceWindowState);
|
pickChoice.showDialog(choice, objectId, choiceWindowState);
|
||||||
if (choice.isKeyChoice()) {
|
if (choice.isKeyChoice()) {
|
||||||
if (pickChoice.isAutoSelect()) {
|
if (pickChoice.isAutoSelect()) {
|
||||||
session.sendPlayerString(gameId, "#" + choice.getChoiceKey());
|
SessionHandler.sendPlayerString(gameId, "#" + choice.getChoiceKey());
|
||||||
} else {
|
} else {
|
||||||
session.sendPlayerString(gameId, choice.getChoiceKey());
|
SessionHandler.sendPlayerString(gameId, choice.getChoiceKey());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
session.sendPlayerString(gameId, choice.getChoice());
|
SessionHandler.sendPlayerString(gameId, choice.getChoice());
|
||||||
}
|
}
|
||||||
choiceWindowState = new MageDialogState(pickChoice);
|
choiceWindowState = new MageDialogState(pickChoice);
|
||||||
pickChoice.removeDialog();
|
pickChoice.removeDialog();
|
||||||
|
|
@ -1313,7 +1309,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
hideAll();
|
hideAll();
|
||||||
PickPileDialog pickPileDialog = new PickPileDialog();
|
PickPileDialog pickPileDialog = new PickPileDialog();
|
||||||
pickPileDialog.loadCards(message, pile1, pile2, bigCard, gameId);
|
pickPileDialog.loadCards(message, pile1, pile2, bigCard, gameId);
|
||||||
session.sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
|
SessionHandler.sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
|
||||||
pickPileDialog.cleanUp();
|
pickPileDialog.cleanUp();
|
||||||
pickPileDialog.removeDialog();
|
pickPileDialog.removeDialog();
|
||||||
}
|
}
|
||||||
|
|
@ -1685,7 +1681,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.getActionMap().put("USEFIRSTMANAABILITY", new AbstractAction() {
|
this.getActionMap().put("USEFIRSTMANAABILITY", new AbstractAction() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
session.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_ON, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_ON, gameId, null);
|
||||||
setMenuStates(
|
setMenuStates(
|
||||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"),
|
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"),
|
||||||
|
|
@ -1729,7 +1725,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.getActionMap().put("USEFIRSTMANAABILITY_RELEASE", new AbstractAction() {
|
this.getActionMap().put("USEFIRSTMANAABILITY_RELEASE", new AbstractAction() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
session.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
|
||||||
setMenuStates(
|
setMenuStates(
|
||||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"),
|
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"),
|
||||||
|
|
@ -2113,49 +2109,49 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
||||||
AudioManager.playOnSkipButton();
|
AudioManager.playOnSkipButton();
|
||||||
updateSkipButtons(true, false, false, false, false, false);
|
updateSkipButtons(true, false, false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||||
AudioManager.playOnSkipButton();
|
AudioManager.playOnSkipButton();
|
||||||
updateSkipButtons(false, true, false, false, false, false);
|
updateSkipButtons(false, true, false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnEndTurnSkipStackActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnEndTurnSkipStackActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
|
||||||
AudioManager.playOnSkipButton();
|
AudioManager.playOnSkipButton();
|
||||||
updateSkipButtons(true, false, false, false, true, false);
|
updateSkipButtons(true, false, false, false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||||
AudioManager.playOnSkipButton();
|
AudioManager.playOnSkipButton();
|
||||||
updateSkipButtons(false, false, true, false, false, false);
|
updateSkipButtons(false, false, true, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
||||||
AudioManager.playOnSkipButton();
|
AudioManager.playOnSkipButton();
|
||||||
updateSkipButtons(false, false, false, true, false, false);
|
updateSkipButtons(false, false, false, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
|
||||||
AudioManager.playOnSkipButton();
|
AudioManager.playOnSkipButton();
|
||||||
updateSkipButtons(false, false, false, false, true, false);
|
updateSkipButtons(false, false, false, false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSkipToEndStepBeforeYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnSkipToEndStepBeforeYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
|
||||||
AudioManager.playOnSkipButton();
|
AudioManager.playOnSkipButton();
|
||||||
updateSkipButtons(false, false, false, false, false, true);
|
updateSkipButtons(false, false, false, false, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) {
|
private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||||
AudioManager.playOnSkipButtonCancel();
|
AudioManager.playOnSkipButtonCancel();
|
||||||
updateSkipButtons(false, false, false, false, false, false);
|
updateSkipButtons(false, false, false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
@ -2205,22 +2201,22 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}//GEN-LAST:event_btnStopReplayActionPerformed
|
}//GEN-LAST:event_btnStopReplayActionPerformed
|
||||||
|
|
||||||
private void btnNextPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextPlayActionPerformed
|
private void btnNextPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextPlayActionPerformed
|
||||||
session.nextPlay(gameId);
|
SessionHandler.nextPlay(gameId);
|
||||||
}//GEN-LAST:event_btnNextPlayActionPerformed
|
}//GEN-LAST:event_btnNextPlayActionPerformed
|
||||||
|
|
||||||
private void btnPreviousPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPreviousPlayActionPerformed
|
private void btnPreviousPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPreviousPlayActionPerformed
|
||||||
session.previousPlay(gameId);
|
SessionHandler.previousPlay(gameId);
|
||||||
}//GEN-LAST:event_btnPreviousPlayActionPerformed
|
}//GEN-LAST:event_btnPreviousPlayActionPerformed
|
||||||
|
|
||||||
private void btnPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayActionPerformed
|
private void btnPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayActionPerformed
|
||||||
if (replayTask == null || replayTask.isDone()) {
|
if (replayTask == null || replayTask.isDone()) {
|
||||||
replayTask = new ReplayTask(session, gameId);
|
replayTask = new ReplayTask(gameId);
|
||||||
replayTask.execute();
|
replayTask.execute();
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnPlayActionPerformed
|
}//GEN-LAST:event_btnPlayActionPerformed
|
||||||
|
|
||||||
private void btnSkipForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSkipForwardActionPerformed
|
private void btnSkipForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSkipForwardActionPerformed
|
||||||
session.skipForward(gameId, 10);
|
SessionHandler.skipForward(gameId, 10);
|
||||||
}//GEN-LAST:event_btnSkipForwardActionPerformed
|
}//GEN-LAST:event_btnSkipForwardActionPerformed
|
||||||
|
|
||||||
public void setJLayeredPane(JLayeredPane jLayeredPane) {
|
public void setJLayeredPane(JLayeredPane jLayeredPane) {
|
||||||
|
|
@ -2279,27 +2275,27 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
switch (e.getActionCommand()) {
|
switch (e.getActionCommand()) {
|
||||||
case CMD_AUTO_ORDER_FIRST:
|
case CMD_AUTO_ORDER_FIRST:
|
||||||
session.sendPlayerAction(TRIGGER_AUTO_ORDER_ABILITY_FIRST, gameId, abilityId);
|
SessionHandler.sendPlayerAction(TRIGGER_AUTO_ORDER_ABILITY_FIRST, gameId, abilityId);
|
||||||
session.sendPlayerUUID(gameId, abilityId);
|
SessionHandler.sendPlayerUUID(gameId, abilityId);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ORDER_LAST:
|
case CMD_AUTO_ORDER_LAST:
|
||||||
session.sendPlayerAction(TRIGGER_AUTO_ORDER_ABILITY_LAST, gameId, abilityId);
|
SessionHandler.sendPlayerAction(TRIGGER_AUTO_ORDER_ABILITY_LAST, gameId, abilityId);
|
||||||
session.sendPlayerUUID(gameId, null); // Don't use this but refresh the displayed abilities
|
SessionHandler.sendPlayerUUID(gameId, null); // Don't use this but refresh the displayed abilities
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ORDER_NAME_FIRST:
|
case CMD_AUTO_ORDER_NAME_FIRST:
|
||||||
if (abilityRuleText != null) {
|
if (abilityRuleText != null) {
|
||||||
session.sendPlayerAction(TRIGGER_AUTO_ORDER_NAME_FIRST, gameId, abilityRuleText);
|
SessionHandler.sendPlayerAction(TRIGGER_AUTO_ORDER_NAME_FIRST, gameId, abilityRuleText);
|
||||||
session.sendPlayerUUID(gameId, abilityId);
|
SessionHandler.sendPlayerUUID(gameId, abilityId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ORDER_NAME_LAST:
|
case CMD_AUTO_ORDER_NAME_LAST:
|
||||||
if (abilityRuleText != null) {
|
if (abilityRuleText != null) {
|
||||||
session.sendPlayerAction(TRIGGER_AUTO_ORDER_NAME_LAST, gameId, abilityRuleText);
|
SessionHandler.sendPlayerAction(TRIGGER_AUTO_ORDER_NAME_LAST, gameId, abilityRuleText);
|
||||||
session.sendPlayerUUID(gameId, null); // Don't use this but refresh the displayed abilities
|
SessionHandler.sendPlayerUUID(gameId, null); // Don't use this but refresh the displayed abilities
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ORDER_RESET_ALL:
|
case CMD_AUTO_ORDER_RESET_ALL:
|
||||||
session.sendPlayerAction(TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
|
SessionHandler.sendPlayerAction(TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (ShowCardsDialog dialog : pickTarget) {
|
for (ShowCardsDialog dialog : pickTarget) {
|
||||||
|
|
@ -2350,9 +2346,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
return gameChatPanel.getText();
|
return gameChatPanel.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session getSession() {
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Card> getLoadedCards() {
|
public Map<String, Card> getLoadedCards() {
|
||||||
return loadedCards;
|
return loadedCards;
|
||||||
|
|
@ -2401,9 +2394,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
holdingPriority = holdPriority;
|
holdingPriority = holdPriority;
|
||||||
txtHoldPriority.setVisible(holdPriority);
|
txtHoldPriority.setVisible(holdPriority);
|
||||||
if (holdPriority) {
|
if (holdPriority) {
|
||||||
session.sendPlayerAction(PlayerAction.HOLD_PRIORITY, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.HOLD_PRIORITY, gameId, null);
|
||||||
} else {
|
} else {
|
||||||
session.sendPlayerAction(PlayerAction.UNHOLD_PRIORITY, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.UNHOLD_PRIORITY, gameId, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2474,20 +2467,18 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
|
|
||||||
private final Session session;
|
|
||||||
private final UUID gameId;
|
private final UUID gameId;
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ReplayTask.class);
|
private static final Logger logger = Logger.getLogger(ReplayTask.class);
|
||||||
|
|
||||||
ReplayTask(Session session, UUID gameId) {
|
ReplayTask(UUID gameId) {
|
||||||
this.session = session;
|
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
session.nextPlay(gameId);
|
SessionHandler.nextPlay(gameId);
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ import javax.swing.SwingUtilities;
|
||||||
import javax.swing.ToolTipManager;
|
import javax.swing.ToolTipManager;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.components.MageTextArea;
|
import mage.client.components.MageTextArea;
|
||||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||||
import static mage.client.game.FeedbackPanel.FeedbackMode.QUESTION;
|
import static mage.client.game.FeedbackPanel.FeedbackMode.QUESTION;
|
||||||
|
|
@ -100,7 +101,6 @@ public class HelperPanel extends JPanel {
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
private Session session;
|
|
||||||
|
|
||||||
public HelperPanel() {
|
public HelperPanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
@ -108,7 +108,6 @@ public class HelperPanel extends JPanel {
|
||||||
|
|
||||||
public void init(UUID gameId) {
|
public void init(UUID gameId) {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
session = MageFrame.getSession();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeGUISize() {
|
public void changeGUISize() {
|
||||||
|
|
@ -414,23 +413,23 @@ public class HelperPanel extends JPanel {
|
||||||
public void handleAutoAnswerPopupMenuEvent(ActionEvent e) {
|
public void handleAutoAnswerPopupMenuEvent(ActionEvent e) {
|
||||||
switch (e.getActionCommand()) {
|
switch (e.getActionCommand()) {
|
||||||
case CMD_AUTO_ANSWER_ID_YES:
|
case CMD_AUTO_ANSWER_ID_YES:
|
||||||
session.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_YES, gameId, originalId.toString() + "#" + message);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_YES, gameId, originalId.toString() + "#" + message);
|
||||||
clickButton(btnLeft);
|
clickButton(btnLeft);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ANSWER_ID_NO:
|
case CMD_AUTO_ANSWER_ID_NO:
|
||||||
session.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_NO, gameId, originalId.toString() + "#" + message);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_NO, gameId, originalId.toString() + "#" + message);
|
||||||
clickButton(btnRight);
|
clickButton(btnRight);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ANSWER_NAME_YES:
|
case CMD_AUTO_ANSWER_NAME_YES:
|
||||||
session.sendPlayerAction(REQUEST_AUTO_ANSWER_TEXT_YES, gameId, message);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_TEXT_YES, gameId, message);
|
||||||
clickButton(btnLeft);
|
clickButton(btnLeft);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ANSWER_NAME_NO:
|
case CMD_AUTO_ANSWER_NAME_NO:
|
||||||
session.sendPlayerAction(REQUEST_AUTO_ANSWER_TEXT_NO, gameId, message);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_TEXT_NO, gameId, message);
|
||||||
clickButton(btnRight);
|
clickButton(btnRight);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ANSWER_RESET_ALL:
|
case CMD_AUTO_ANSWER_RESET_ALL:
|
||||||
session.sendPlayerAction(REQUEST_AUTO_ANSWER_RESET_ALL, gameId, null);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_RESET_ALL, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ import javax.swing.MenuSelectionManager;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS;
|
import static mage.client.dialog.PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS;
|
||||||
|
|
@ -168,31 +169,31 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "F3": {
|
case "F3": {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "F4": {
|
case "F4": {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "F5": {
|
case "F5": {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "F6": {
|
case "F6": {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "F7": {
|
case "F7": {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "F9": {
|
case "F9": {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "F11": {
|
case "F11": {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -292,7 +293,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem) e.getSource()).getState();
|
boolean manaPoolAutomatic = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true" : "false");
|
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true" : "false");
|
||||||
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState(), useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
|
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState(), useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
|
||||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON : PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
SessionHandler.sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON : PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -310,7 +311,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem) e.getSource()).getState();
|
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true" : "false");
|
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true" : "false");
|
||||||
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted, useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
|
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted, useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
|
||||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON : PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
|
SessionHandler.sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON : PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -328,7 +329,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
boolean useFirstManaAbility = ((JCheckBoxMenuItem) e.getSource()).getState();
|
boolean useFirstManaAbility = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||||
PreferencesDialog.saveValue(KEY_USE_FIRST_MANA_ABILITY, useFirstManaAbility ? "true" : "false");
|
PreferencesDialog.saveValue(KEY_USE_FIRST_MANA_ABILITY, useFirstManaAbility ? "true" : "false");
|
||||||
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbility, holdPriorityMenuItem.getState());
|
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbility, holdPriorityMenuItem.getState());
|
||||||
gamePanel.getSession().sendPlayerAction(useFirstManaAbility ? PlayerAction.USE_FIRST_MANA_ABILITY_ON : PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
|
SessionHandler.sendPlayerAction(useFirstManaAbility ? PlayerAction.USE_FIRST_MANA_ABILITY_ON : PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -344,7 +345,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -356,7 +357,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -368,7 +369,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -385,7 +386,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
SessionHandler.sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -400,7 +401,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
boolean requestsAllowed = ((JCheckBoxMenuItem) e.getSource()).getState();
|
boolean requestsAllowed = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||||
PreferencesDialog.setPrefValue(KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, requestsAllowed);
|
PreferencesDialog.setPrefValue(KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, requestsAllowed);
|
||||||
gamePanel.getSession().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON : PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
|
SessionHandler.sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON : PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -413,7 +414,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
|
SessionHandler.sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -423,7 +424,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int turnsToRollBack = Integer.parseInt(e.getActionCommand());
|
int turnsToRollBack = Integer.parseInt(e.getActionCommand());
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.ROLLBACK_TURNS, gameId, turnsToRollBack);
|
SessionHandler.sendPlayerAction(PlayerAction.ROLLBACK_TURNS, gameId, turnsToRollBack);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -548,7 +549,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
SessionHandler.sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -578,7 +579,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
this.battlefieldPanel.init(gameId, bigCard);
|
this.battlefieldPanel.init(gameId, bigCard);
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.playerId = player.getPlayerId();
|
this.playerId = player.getPlayerId();
|
||||||
if (MageFrame.getSession().isTestMode()) {
|
if (SessionHandler.isTestMode()) {
|
||||||
this.btnCheat.setVisible(true);
|
this.btnCheat.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
this.btnCheat.setVisible(false);
|
this.btnCheat.setVisible(false);
|
||||||
|
|
@ -646,7 +647,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
MageFrame.getSession().cheat(gameId, playerId, DeckImporterUtil.importDeck("cheat.dck"));
|
SessionHandler.cheat(gameId, playerId, DeckImporterUtil.importDeck("cheat.dck"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSmallMode() {
|
public boolean isSmallMode() {
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ import javax.swing.border.LineBorder;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.importer.DckDeckImporter;
|
import mage.cards.decks.importer.DckDeckImporter;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.components.HoverButton;
|
import mage.client.components.HoverButton;
|
||||||
import mage.client.components.MageRoundPane;
|
import mage.client.components.MageRoundPane;
|
||||||
|
|
@ -134,8 +135,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
this.bigCard = bigCard;
|
this.bigCard = bigCard;
|
||||||
session = MageFrame.getSession();
|
cheat.setVisible(SessionHandler.isTestMode());
|
||||||
cheat.setVisible(session.isTestMode());
|
|
||||||
cheat.setFocusable(false);
|
cheat.setFocusable(false);
|
||||||
flagName = null;
|
flagName = null;
|
||||||
if (priorityTime > 0) {
|
if (priorityTime > 0) {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import mage.cards.MageCard;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.cards.action.TransferData;
|
import mage.cards.action.TransferData;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
|
@ -38,7 +39,6 @@ import mage.client.util.gui.ArrowUtil;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.components.CardInfoPane;
|
import mage.components.CardInfoPane;
|
||||||
import mage.constants.EnlargeMode;
|
import mage.constants.EnlargeMode;
|
||||||
import mage.remote.Session;
|
|
||||||
import mage.utils.ThreadUtils;
|
import mage.utils.ThreadUtils;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
|
|
@ -69,7 +69,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
private JPopupMenu jPopupMenu;
|
private JPopupMenu jPopupMenu;
|
||||||
private BigCard bigCard;
|
private BigCard bigCard;
|
||||||
protected static final DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
|
protected static final DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
|
||||||
protected static Session session = MageFrame.getSession();
|
|
||||||
private CardView tooltipCard;
|
private CardView tooltipCard;
|
||||||
private TransferData popupData;
|
private TransferData popupData;
|
||||||
private JComponent cardInfoPane;
|
private JComponent cardInfoPane;
|
||||||
|
|
@ -104,9 +104,6 @@ public class MageActionCallback implements ActionCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void refreshSession() {
|
public synchronized void refreshSession() {
|
||||||
if (session == null) {
|
|
||||||
session = MageFrame.getSession();
|
|
||||||
}
|
|
||||||
if (cardInfoPane == null) {
|
if (cardInfoPane == null) {
|
||||||
cardInfoPane = Plugins.getInstance().getCardInfoPane();
|
cardInfoPane = Plugins.getInstance().getCardInfoPane();
|
||||||
}
|
}
|
||||||
|
|
@ -173,7 +170,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
public void run() {
|
public void run() {
|
||||||
ThreadUtils.sleep(tooltipDelay);
|
ThreadUtils.sleep(tooltipDelay);
|
||||||
|
|
||||||
if (tooltipCard == null || !tooltipCard.equals(data.card) || session == null || !popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
if (tooltipCard == null || !tooltipCard.equals(data.card) || SessionHandler.getSession() == null || !popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,14 +250,14 @@ public class MageActionCallback implements ActionCallback {
|
||||||
this.startedDragging = false;
|
this.startedDragging = false;
|
||||||
if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements
|
if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements
|
||||||
transferData.component.requestFocusInWindow();
|
transferData.component.requestFocusInWindow();
|
||||||
defaultCallback.mouseClicked(e, transferData.gameId, session, transferData.card);
|
defaultCallback.mouseClicked(e, transferData.gameId, transferData.card);
|
||||||
// Closes popup & enlarged view if a card/Permanent is selected
|
// Closes popup & enlarged view if a card/Permanent is selected
|
||||||
hideTooltipPopup();
|
hideTooltipPopup();
|
||||||
}
|
}
|
||||||
e.consume();
|
e.consume();
|
||||||
} else {
|
} else {
|
||||||
transferData.component.requestFocusInWindow();
|
transferData.component.requestFocusInWindow();
|
||||||
defaultCallback.mouseClicked(e, transferData.gameId, session, transferData.card);
|
defaultCallback.mouseClicked(e, transferData.gameId, transferData.card);
|
||||||
// Closes popup & enlarged view if a card/Permanent is selected
|
// Closes popup & enlarged view if a card/Permanent is selected
|
||||||
hideTooltipPopup();
|
hideTooltipPopup();
|
||||||
e.consume();
|
e.consume();
|
||||||
|
|
@ -423,7 +420,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
jPopupMenu.setVisible(false);
|
jPopupMenu.setVisible(false);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (session == null) {
|
if (SessionHandler.getSession() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set enlarged card display to visible = false
|
// set enlarged card display to visible = false
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ import java.util.UUID;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
|
|
@ -53,7 +54,6 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
protected PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
|
protected PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
|
||||||
|
|
||||||
private Session session;
|
|
||||||
|
|
||||||
/** Creates new form TablePlayerPanel */
|
/** Creates new form TablePlayerPanel */
|
||||||
public TablePlayerPanel() {
|
public TablePlayerPanel() {
|
||||||
|
|
@ -62,8 +62,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(int playerNum, String playerType) {
|
public void init(int playerNum, String playerType) {
|
||||||
session = MageFrame.getSession();
|
cbPlayerType.setModel(new DefaultComboBoxModel(SessionHandler.getPlayerTypes()));
|
||||||
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
|
|
||||||
this.lblPlayerNum.setText("Player " + playerNum);
|
this.lblPlayerNum.setText("Player " + playerNum);
|
||||||
if (Config.defaultOtherPlayerIndex != null) {
|
if (Config.defaultOtherPlayerIndex != null) {
|
||||||
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount()) {
|
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount()) {
|
||||||
|
|
@ -81,7 +80,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
|
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||||
return session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
|
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import java.util.UUID;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.MagePane;
|
import mage.client.MagePane;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -70,7 +71,7 @@ public class TablesPane extends MagePane {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showTables() {
|
public void showTables() {
|
||||||
UUID roomId = MageFrame.getSession().getMainRoomId();
|
UUID roomId = SessionHandler.getSession().getMainRoomId();
|
||||||
if (roomId != null) {
|
if (roomId != null) {
|
||||||
this.setTitle("Tables");
|
this.setTitle("Tables");
|
||||||
tablesPanel.showTables(roomId);
|
tablesPanel.showTables(roomId);
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ import javax.swing.SwingWorker;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
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.dialog.JoinTableDialog;
|
import mage.client.dialog.JoinTableDialog;
|
||||||
|
|
@ -93,7 +94,6 @@ import mage.constants.RangeOfInfluence;
|
||||||
import mage.constants.SkillLevel;
|
import mage.constants.SkillLevel;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.remote.MageRemoteException;
|
import mage.remote.MageRemoteException;
|
||||||
import mage.remote.Session;
|
|
||||||
import mage.view.MatchView;
|
import mage.view.MatchView;
|
||||||
import mage.view.RoomUsersView;
|
import mage.view.RoomUsersView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
|
|
@ -119,7 +119,6 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
private NewTableDialog newTableDialog;
|
private NewTableDialog newTableDialog;
|
||||||
private NewTournamentDialog newTournamentDialog;
|
private NewTournamentDialog newTournamentDialog;
|
||||||
private GameChooser gameChooser;
|
private GameChooser gameChooser;
|
||||||
private Session session;
|
|
||||||
private List<String> messages;
|
private List<String> messages;
|
||||||
private int currentMessage;
|
private int currentMessage;
|
||||||
private MageTableRowSorter activeTablesSorter;
|
private MageTableRowSorter activeTablesSorter;
|
||||||
|
|
@ -139,7 +138,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
gameChooser = new GameChooser();
|
gameChooser = new GameChooser();
|
||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
tableModel.setSession(session);
|
// tableModel.setSession(session);
|
||||||
|
|
||||||
tableTables.createDefaultColumnsFromModel();
|
tableTables.createDefaultColumnsFromModel();
|
||||||
|
|
||||||
|
|
@ -186,7 +185,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
String owner = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_OWNER);
|
String owner = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_OWNER);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "Join":
|
case "Join":
|
||||||
if (owner.equals(session.getUserName()) || owner.startsWith(session.getUserName() + ",")) {
|
if (owner.equals(SessionHandler.getUserName()) || owner.startsWith(SessionHandler.getUserName() + ",")) {
|
||||||
try {
|
try {
|
||||||
JDesktopPane desktopPane = (JDesktopPane) MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
JDesktopPane desktopPane = (JDesktopPane) MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
||||||
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
|
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
|
||||||
|
|
@ -211,7 +210,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
LOGGER.info("Joining tournament " + tableId);
|
LOGGER.info("Joining tournament " + tableId);
|
||||||
if (deckType.startsWith("Limited")) {
|
if (deckType.startsWith("Limited")) {
|
||||||
if (!status.endsWith("PW")) {
|
if (!status.endsWith("PW")) {
|
||||||
session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human", 1, null, "");
|
SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), "Human", 1, null, "");
|
||||||
} else {
|
} else {
|
||||||
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
|
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
|
||||||
}
|
}
|
||||||
|
|
@ -232,18 +231,18 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
case "Show":
|
case "Show":
|
||||||
if (isTournament) {
|
if (isTournament) {
|
||||||
LOGGER.info("Showing tournament table " + tableId);
|
LOGGER.info("Showing tournament table " + tableId);
|
||||||
session.watchTable(roomId, tableId);
|
SessionHandler.watchTable(roomId, tableId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Watch":
|
case "Watch":
|
||||||
if (!isTournament) {
|
if (!isTournament) {
|
||||||
LOGGER.info("Watching table " + tableId);
|
LOGGER.info("Watching table " + tableId);
|
||||||
session.watchTable(roomId, tableId);
|
SessionHandler.watchTable(roomId, tableId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Replay":
|
case "Replay":
|
||||||
LOGGER.info("Replaying game " + gameId);
|
LOGGER.info("Replaying game " + gameId);
|
||||||
session.replayGame(gameId);
|
SessionHandler.replayGame(gameId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +259,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
List<UUID> gameList = matchesModel.getListofGames(modelRow);
|
List<UUID> gameList = matchesModel.getListofGames(modelRow);
|
||||||
if (gameList != null && gameList.size() > 0) {
|
if (gameList != null && gameList.size() > 0) {
|
||||||
if (gameList.size() == 1) {
|
if (gameList.size() == 1) {
|
||||||
session.replayGame(gameList.get(0));
|
SessionHandler.replayGame(gameList.get(0));
|
||||||
} else {
|
} else {
|
||||||
gameChooser.show(gameList, MageFrame.getDesktop().getMousePosition());
|
gameChooser.show(gameList, MageFrame.getDesktop().getMousePosition());
|
||||||
}
|
}
|
||||||
|
|
@ -270,7 +269,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
case "Show":;
|
case "Show":;
|
||||||
if (matchesModel.isTournament(modelRow)) {
|
if (matchesModel.isTournament(modelRow)) {
|
||||||
LOGGER.info("Showing tournament table " + matchesModel.getTableId(modelRow));
|
LOGGER.info("Showing tournament table " + matchesModel.getTableId(modelRow));
|
||||||
session.watchTable(roomId, matchesModel.getTableId(modelRow));
|
SessionHandler.watchTable(roomId, matchesModel.getTableId(modelRow));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -439,18 +438,18 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startTasks() {
|
public void startTasks() {
|
||||||
if (session != null) {
|
if (SessionHandler.getSession() != null) {
|
||||||
if (updateTablesTask == null || updateTablesTask.isDone()) {
|
if (updateTablesTask == null || updateTablesTask.isDone()) {
|
||||||
updateTablesTask = new UpdateTablesTask(session, roomId, this);
|
updateTablesTask = new UpdateTablesTask(roomId, this);
|
||||||
updateTablesTask.execute();
|
updateTablesTask.execute();
|
||||||
}
|
}
|
||||||
if (updatePlayersTask == null || updatePlayersTask.isDone()) {
|
if (updatePlayersTask == null || updatePlayersTask.isDone()) {
|
||||||
updatePlayersTask = new UpdatePlayersTask(session, roomId, this.chatPanelMain);
|
updatePlayersTask = new UpdatePlayersTask(roomId, this.chatPanelMain);
|
||||||
updatePlayersTask.execute();
|
updatePlayersTask.execute();
|
||||||
}
|
}
|
||||||
if (this.btnStateFinished.isSelected()) {
|
if (this.btnStateFinished.isSelected()) {
|
||||||
if (updateMatchesTask == null || updateMatchesTask.isDone()) {
|
if (updateMatchesTask == null || updateMatchesTask.isDone()) {
|
||||||
updateMatchesTask = new UpdateMatchesTask(session, roomId, this);
|
updateMatchesTask = new UpdateMatchesTask(roomId, this);
|
||||||
updateMatchesTask.execute();
|
updateMatchesTask.execute();
|
||||||
}
|
}
|
||||||
} else if (updateMatchesTask != null) {
|
} else if (updateMatchesTask != null) {
|
||||||
|
|
@ -473,12 +472,11 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public void showTables(UUID roomId) {
|
public void showTables(UUID roomId) {
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
session = MageFrame.getSession();
|
|
||||||
UUID chatRoomId = null;
|
UUID chatRoomId = null;
|
||||||
if (session != null) {
|
if (SessionHandler.getSession() != null) {
|
||||||
btnQuickStart.setVisible(session.isTestMode());
|
btnQuickStart.setVisible(SessionHandler.isTestMode());
|
||||||
gameChooser.init(session);
|
gameChooser.init();
|
||||||
chatRoomId = session.getRoomChatId(roomId);
|
chatRoomId = SessionHandler.getRoomChatId(roomId);
|
||||||
}
|
}
|
||||||
if (newTableDialog == null) {
|
if (newTableDialog == null) {
|
||||||
newTableDialog = new NewTableDialog();
|
newTableDialog = new NewTableDialog();
|
||||||
|
|
@ -500,7 +498,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
} else {
|
} else {
|
||||||
hideTables();
|
hideTables();
|
||||||
}
|
}
|
||||||
tableModel.setSession(session);
|
//tableModel.setSession(session);
|
||||||
|
|
||||||
reloadMessages();
|
reloadMessages();
|
||||||
|
|
||||||
|
|
@ -518,7 +516,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
protected void reloadMessages() {
|
protected void reloadMessages() {
|
||||||
// reload server messages
|
// reload server messages
|
||||||
List<String> serverMessages = session.getServerMessages();
|
List<String> serverMessages = SessionHandler.getServerMessages();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.messages = serverMessages;
|
this.messages = serverMessages;
|
||||||
this.currentMessage = 0;
|
this.currentMessage = 0;
|
||||||
|
|
@ -1286,11 +1284,11 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
options.setSkillLevel(SkillLevel.CASUAL);
|
options.setSkillLevel(SkillLevel.CASUAL);
|
||||||
options.setRollbackTurnsAllowed(true);
|
options.setRollbackTurnsAllowed(true);
|
||||||
options.setQuitRatio(100);
|
options.setQuitRatio(100);
|
||||||
table = session.createTable(roomId, options);
|
table = SessionHandler.createTable(roomId, options);
|
||||||
|
|
||||||
session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"), "");
|
SessionHandler.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"), "");
|
||||||
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"), "");
|
SessionHandler.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"), "");
|
||||||
session.startMatch(roomId, table.getTableId());
|
SessionHandler.startMatch(roomId, table.getTableId());
|
||||||
} catch (HeadlessException ex) {
|
} catch (HeadlessException ex) {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
}
|
}
|
||||||
|
|
@ -1404,7 +1402,6 @@ class TableTableModel extends AbstractTableModel {
|
||||||
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
|
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
|
||||||
;
|
;
|
||||||
|
|
||||||
private Session session;
|
|
||||||
|
|
||||||
public void loadData(Collection<TableView> tables) throws MageRemoteException {
|
public void loadData(Collection<TableView> tables) throws MageRemoteException {
|
||||||
this.tables = tables.toArray(new TableView[0]);
|
this.tables = tables.toArray(new TableView[0]);
|
||||||
|
|
@ -1421,9 +1418,6 @@ class TableTableModel extends AbstractTableModel {
|
||||||
return columnNames.length;
|
return columnNames.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSession(Session session) {
|
|
||||||
this.session = session;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int arg0, int arg1) {
|
public Object getValueAt(int arg0, int arg1) {
|
||||||
|
|
@ -1455,7 +1449,7 @@ class TableTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
case WAITING:
|
case WAITING:
|
||||||
String owner = tables[arg0].getControllerName();
|
String owner = tables[arg0].getControllerName();
|
||||||
if (session != null && owner.equals(session.getUserName())) {
|
if (SessionHandler.getSession() != null && owner.equals(SessionHandler.getUserName())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return "Join";
|
return "Join";
|
||||||
|
|
@ -1469,7 +1463,7 @@ class TableTableModel extends AbstractTableModel {
|
||||||
return "Show";
|
return "Show";
|
||||||
} else {
|
} else {
|
||||||
owner = tables[arg0].getControllerName();
|
owner = tables[arg0].getControllerName();
|
||||||
if (session != null && owner.equals(session.getUserName())) {
|
if (SessionHandler.getSession() != null && owner.equals(SessionHandler.getUserName())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return "Watch";
|
return "Watch";
|
||||||
|
|
@ -1522,7 +1516,6 @@ class TableTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
||||||
|
|
||||||
private final Session session;
|
|
||||||
private final UUID roomId;
|
private final UUID roomId;
|
||||||
private final TablesPanel panel;
|
private final TablesPanel panel;
|
||||||
|
|
||||||
|
|
@ -1530,8 +1523,8 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
||||||
|
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
|
|
||||||
UpdateTablesTask(Session session, UUID roomId, TablesPanel panel) {
|
UpdateTablesTask(UUID roomId, TablesPanel panel) {
|
||||||
this.session = session;
|
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.panel = panel;
|
this.panel = panel;
|
||||||
}
|
}
|
||||||
|
|
@ -1539,7 +1532,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
Collection<TableView> tables = session.getTables(roomId);
|
Collection<TableView> tables = SessionHandler.getTables(roomId);
|
||||||
if (tables != null) {
|
if (tables != null) {
|
||||||
this.publish(tables);
|
this.publish(tables);
|
||||||
}
|
}
|
||||||
|
|
@ -1572,14 +1565,13 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
||||||
|
|
||||||
class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
|
class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
|
||||||
|
|
||||||
private final Session session;
|
|
||||||
private final UUID roomId;
|
private final UUID roomId;
|
||||||
private final PlayersChatPanel chat;
|
private final PlayersChatPanel chat;
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(UpdatePlayersTask.class);
|
private static final Logger logger = Logger.getLogger(UpdatePlayersTask.class);
|
||||||
|
|
||||||
UpdatePlayersTask(Session session, UUID roomId, PlayersChatPanel chat) {
|
UpdatePlayersTask( UUID roomId, PlayersChatPanel chat) {
|
||||||
this.session = session;
|
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.chat = chat;
|
this.chat = chat;
|
||||||
}
|
}
|
||||||
|
|
@ -1587,7 +1579,7 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
this.publish(session.getRoomUsers(roomId));
|
this.publish(SessionHandler.getRoomUsers(roomId));
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -1713,14 +1705,12 @@ class MatchesTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
|
class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
|
|
||||||
private final Session session;
|
|
||||||
private final UUID roomId;
|
private final UUID roomId;
|
||||||
private final TablesPanel panel;
|
private final TablesPanel panel;
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);
|
private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);
|
||||||
|
|
||||||
UpdateMatchesTask(Session session, UUID roomId, TablesPanel panel) {
|
UpdateMatchesTask(UUID roomId, TablesPanel panel) {
|
||||||
this.session = session;
|
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.panel = panel;
|
this.panel = panel;
|
||||||
}
|
}
|
||||||
|
|
@ -1728,7 +1718,7 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
Collection<MatchView> matches = session.getFinishedMatches(roomId);
|
Collection<MatchView> matches = SessionHandler.getFinishedMatches(roomId);
|
||||||
if (matches != null) {
|
if (matches != null) {
|
||||||
this.publish(matches);
|
this.publish(matches);
|
||||||
}
|
}
|
||||||
|
|
@ -1756,10 +1746,9 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
|
|
||||||
class GameChooser extends JPopupMenu {
|
class GameChooser extends JPopupMenu {
|
||||||
|
|
||||||
private Session session;
|
|
||||||
|
|
||||||
public void init(Session session) {
|
public void init() {
|
||||||
this.session = session;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(List<UUID> games, Point p) {
|
public void show(List<UUID> games, Point p) {
|
||||||
|
|
@ -1785,7 +1774,7 @@ class GameChooser extends JPopupMenu {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
session.replayGame(id);
|
SessionHandler.replayGame(id);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import javax.swing.DefaultComboBoxModel;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,7 +48,6 @@ import mage.remote.Session;
|
||||||
*/
|
*/
|
||||||
public class TournamentPlayerPanel extends javax.swing.JPanel {
|
public class TournamentPlayerPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private Session session;
|
|
||||||
|
|
||||||
/** Creates new form TournamentPlayerPanel */
|
/** Creates new form TournamentPlayerPanel */
|
||||||
public TournamentPlayerPanel() {
|
public TournamentPlayerPanel() {
|
||||||
|
|
@ -56,8 +56,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(int playerNum) {
|
public void init(int playerNum) {
|
||||||
session = MageFrame.getSession();
|
cbPlayerType.setModel(new DefaultComboBoxModel(SessionHandler.getPlayerTypes()));
|
||||||
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
|
|
||||||
this.lblPlayerNum.setText("Player " + playerNum);
|
this.lblPlayerNum.setText("Player " + playerNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +66,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public boolean joinTournamentTable(UUID roomId, UUID tableId, DeckCardLists deckCardLists) {
|
public boolean joinTournamentTable(UUID roomId, UUID tableId, DeckCardLists deckCardLists) {
|
||||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||||
return session.joinTournamentTable(
|
return SessionHandler.joinTournamentTable(
|
||||||
roomId,
|
roomId,
|
||||||
tableId,
|
tableId,
|
||||||
this.txtPlayerName.getText(),
|
this.txtPlayerName.getText(),
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ 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.chat.ChatPanelBasic;
|
import mage.client.chat.ChatPanelBasic;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_MATCH_COLUMNS_ORDER;
|
import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_MATCH_COLUMNS_ORDER;
|
||||||
|
|
@ -61,7 +62,6 @@ import mage.client.util.GUISizeHelper;
|
||||||
import mage.client.util.gui.TableUtil;
|
import mage.client.util.gui.TableUtil;
|
||||||
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
import mage.remote.Session;
|
|
||||||
import mage.view.RoundView;
|
import mage.view.RoundView;
|
||||||
import mage.view.TournamentGameView;
|
import mage.view.TournamentGameView;
|
||||||
import mage.view.TournamentPlayerView;
|
import mage.view.TournamentPlayerView;
|
||||||
|
|
@ -82,7 +82,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private UUID tournamentId;
|
private UUID tournamentId;
|
||||||
private boolean firstInitDone = false;
|
private boolean firstInitDone = false;
|
||||||
private Session session;
|
|
||||||
private final TournamentPlayersTableModel playersModel;
|
private final TournamentPlayersTableModel playersModel;
|
||||||
private TournamentMatchesTableModel matchesModel;
|
private TournamentMatchesTableModel matchesModel;
|
||||||
private UpdateTournamentTask updateTask;
|
private UpdateTournamentTask updateTask;
|
||||||
|
|
@ -129,7 +129,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
// }
|
// }
|
||||||
if (state.startsWith("Dueling") && actionText.equals("Watch")) {
|
if (state.startsWith("Dueling") && actionText.equals("Watch")) {
|
||||||
LOGGER.info("Watching game " + gameId);
|
LOGGER.info("Watching game " + gameId);
|
||||||
session.watchTournamentTable(tableId);
|
SessionHandler.watchTournamentTable(tableId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -201,10 +201,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;
|
||||||
session = MageFrame.getSession();
|
|
||||||
// MageFrame.addTournament(tournamentId, this);
|
// MageFrame.addTournament(tournamentId, this);
|
||||||
UUID chatRoomId = session.getTournamentChatId(tournamentId);
|
UUID chatRoomId = SessionHandler.getTournamentChatId(tournamentId);
|
||||||
if (session.joinTournament(tournamentId) && chatRoomId != null) {
|
if (SessionHandler.joinTournament(tournamentId) && chatRoomId != null) {
|
||||||
this.chatPanel1.connect(chatRoomId);
|
this.chatPanel1.connect(chatRoomId);
|
||||||
startTasks();
|
startTasks();
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
|
|
@ -292,7 +291,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
btnQuitTournament.setVisible(false);
|
btnQuitTournament.setVisible(false);
|
||||||
if (tournament.getEndTime() == null) {
|
if (tournament.getEndTime() == null) {
|
||||||
for (TournamentPlayerView player : tournament.getPlayers()) {
|
for (TournamentPlayerView player : tournament.getPlayers()) {
|
||||||
if (player.getName().equals(session.getUserName())) {
|
if (player.getName().equals(SessionHandler.getUserName())) {
|
||||||
if (!player.hasQuit()) {
|
if (!player.hasQuit()) {
|
||||||
btnQuitTournament.setVisible(true);
|
btnQuitTournament.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
@ -304,9 +303,9 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startTasks() {
|
public void startTasks() {
|
||||||
if (session != null) {
|
if (SessionHandler.getSession() != null) {
|
||||||
if (updateTask == null || updateTask.isDone()) {
|
if (updateTask == null || updateTask.isDone()) {
|
||||||
updateTask = new UpdateTournamentTask(session, tournamentId, this);
|
updateTask = new UpdateTournamentTask(tournamentId, this);
|
||||||
updateTask.execute();
|
updateTask.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -725,14 +724,13 @@ class TournamentMatchesTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
|
class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
|
||||||
|
|
||||||
private final Session session;
|
|
||||||
private final UUID tournamentId;
|
private final UUID tournamentId;
|
||||||
private final TournamentPanel panel;
|
private final TournamentPanel panel;
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(UpdateTournamentTask.class);
|
private static final Logger logger = Logger.getLogger(UpdateTournamentTask.class);
|
||||||
|
|
||||||
UpdateTournamentTask(Session session, UUID tournamentId, TournamentPanel panel) {
|
UpdateTournamentTask(UUID tournamentId, TournamentPanel panel) {
|
||||||
this.session = session;
|
|
||||||
this.tournamentId = tournamentId;
|
this.tournamentId = tournamentId;
|
||||||
this.panel = panel;
|
this.panel = panel;
|
||||||
}
|
}
|
||||||
|
|
@ -740,7 +738,7 @@ class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
this.publish(session.getTournament(tournamentId));
|
this.publish(SessionHandler.getTournament(tournamentId));
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ package mage.client.unusedFiles;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.dialog.ShowCardsDialog;
|
import mage.client.dialog.ShowCardsDialog;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
|
|
@ -50,7 +51,6 @@ public class PlayerPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
private Session session;
|
|
||||||
private PlayerView player;
|
private PlayerView player;
|
||||||
|
|
||||||
private ShowCardsDialog graveyard;
|
private ShowCardsDialog graveyard;
|
||||||
|
|
@ -67,7 +67,6 @@ public class PlayerPanel extends javax.swing.JPanel {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
this.bigCard = bigCard;
|
this.bigCard = bigCard;
|
||||||
session = MageFrame.getSession();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(PlayerView player) {
|
public void update(PlayerView player) {
|
||||||
|
|
@ -192,7 +191,7 @@ public class PlayerPanel extends javax.swing.JPanel {
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void btnPlayerNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerNameActionPerformed
|
private void btnPlayerNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerNameActionPerformed
|
||||||
session.sendPlayerUUID(gameId, playerId);
|
SessionHandler.sendPlayerUUID(gameId, playerId);
|
||||||
}//GEN-LAST:event_btnPlayerNameActionPerformed
|
}//GEN-LAST:event_btnPlayerNameActionPerformed
|
||||||
|
|
||||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package mage.client.util;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import mage.client.SessionHandler;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
|
||||||
|
|
@ -17,12 +18,12 @@ public class DefaultActionCallback {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseClicked(MouseEvent e, UUID gameId, Session session, CardView card) {
|
public void mouseClicked(MouseEvent e, UUID gameId, CardView card) {
|
||||||
if (gameId != null) {
|
if (gameId != null) {
|
||||||
if (card.isAbility() && card.getAbility() != null) {
|
if (card.isAbility() && card.getAbility() != null) {
|
||||||
session.sendPlayerUUID(gameId, card.getAbility().getId());
|
SessionHandler.sendPlayerUUID(gameId, card.getAbility().getId());
|
||||||
} else {
|
} else {
|
||||||
session.sendPlayerUUID(gameId, card.getId());
|
SessionHandler.sendPlayerUUID(gameId, card.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue