initial commit - only table pane chat is working atm

This commit is contained in:
betasteward 2015-05-23 10:18:36 -04:00
parent f9bad74ca7
commit e45345d87a
84 changed files with 5370 additions and 3992 deletions

View file

@ -58,13 +58,13 @@ import mage.client.util.audio.MusicPlayer;
import mage.client.util.gui.ArrowBuilder;
import mage.client.util.stats.UpdateMemUsageTask;
import mage.components.ImagePanel;
import mage.interfaces.MageClient;
//import mage.interfaces.MageClient;
import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import mage.remote.Session;
import mage.remote.SessionImpl;
//import mage.remote.Session;
//import mage.remote.SessionImpl;
import mage.utils.MageVersion;
import mage.view.GameEndView;
import org.apache.log4j.Logger;
@ -92,10 +92,16 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import mage.client.util.audio.AudioManager;
import mage.interfaces.ServerState;
import mage.view.ChatMessage;
import mage.view.UserRequestMessage;
import net.java.truevfs.access.TArchiveDetector;
import net.java.truevfs.access.TConfig;
import net.java.truevfs.kernel.spec.FsAccessOption;
import org.mage.network.Client;
import org.mage.network.interfaces.MageClient;
import org.mage.network.model.MessageType;
/**
* @author BetaSteward_at_googlemail.com
@ -111,10 +117,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static MageFrame instance;
private static Session session;
// private static Session session;
// public static MageClient client;
private static Client client;
private ServerState serverState;
private ConnectDialog connectDialog;
private final ErrorDialog errorDialog;
private static CallbackClient callbackClient;
// private static CallbackClient callbackClient;
private static final Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
private JLabel title;
private Rectangle titleRectangle;
@ -136,13 +145,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static long startTime;
/**
* @return the session
*/
public static Session getSession() {
return session;
}
// /**
// * @return the session
// */
// public static Session getSession() {
// return session;
// }
public static Client getClient() {
return client;
}
public static JDesktopPane getDesktop() {
return desktopPane;
}
@ -159,7 +172,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
return grayMode;
}
@Override
public MageVersion getVersion() {
return version;
}
@ -203,8 +215,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
DialogManager.updateParams(768, 1024, false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
session = new SessionImpl(this);
callbackClient = new CallbackClientImpl(this);
// session = new SessionImpl(this);
// callbackClient = new CallbackClientImpl(this);
connectDialog = new ConnectDialog();
desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
errorDialog = new ErrorDialog();
@ -212,12 +224,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
desktopPane.add(errorDialog, JLayeredPane.POPUP_LAYER);
ui.addComponent(MageComponents.DESKTOP_PANE, desktopPane);
pingTaskExecutor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
session.ping();
}
}, 60, 60, TimeUnit.SECONDS);
// pingTaskExecutor.scheduleAtFixedRate(new Runnable() {
// @Override
// public void run() {
// session.ping();
// }
// }, 60, 60, TimeUnit.SECONDS);
updateMemUsageTask = new UpdateMemUsageTask(jMemUsageLabel);
@ -330,7 +342,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void setWindowTitle() {
setTitle(TITLE_NAME + " Client: "
+ version == null ? "<not available>" : version.toString() + " Server: "
+ ((session != null && session.isConnected()) ? session.getVersionInfo():"<not connected>"));
+ ((client != null && client.isConnected()) ? serverState.getVersion().toString():"<not connected>"));
}
private void addTooltipContainer() {
@ -682,15 +694,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
tableWaitingDialog.showDialog(roomId, tableId, isTournament);
}
public static boolean connect(Connection connection) {
boolean result = session.connect(connection);
MageFrame.getInstance().setWindowTitle();
public boolean connect(Connection connection) {
boolean result = client.connect(connection.getUsername(), connection.getHost(), connection.getPort(), version);
return result;
}
public static boolean stopConnecting() {
return session.stopConnecting();
}
// public static boolean stopConnecting() {
// return session.stopConnecting();
// }
public boolean autoConnect() {
boolean autoConnectParamValue = Boolean.parseBoolean(prefs.get("autoConnect", "false"));
@ -730,8 +741,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
connection.setAllowRequestShowHandCards(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"));
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
logger.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername);
if (MageFrame.connect(connection)) {
showGames(false);
if (connect(connection)) {
return true;
} else {
showMessage("Unable to connect to server");
@ -915,9 +925,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}//GEN-LAST:event_btnExitActionPerformed
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
if (session.isConnected()) {
if (client.isConnected()) {
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
session.disconnect(false);
client.disconnect();
tablesPane.clearChat();
setWindowTitle();
showMessage("You have disconnected");
@ -949,7 +959,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}//GEN-LAST:event_btnPreferencesActionPerformed
public void btnSendFeedbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendFeedbackActionPerformed
if (!session.isConnected()) {
if (!client.isConnected()) {
JOptionPane.showMessageDialog(null, "You may send us feedback only when connected to server.", "Information", JOptionPane.INFORMATION_MESSAGE);
return;
}
@ -957,11 +967,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}//GEN-LAST:event_btnSendFeedbackActionPerformed
public void exitApp() {
if (session.isConnected()) {
if (client.isConnected()) {
if (JOptionPane.showConfirmDialog(this, "You are currently connected. Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
session.disconnect(false);
client.disconnect();
} else {
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Confirm exit", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
@ -1167,6 +1177,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
instance = new MageFrame();
client = new Client(instance);
instance.setVisible(true);
}
@ -1266,7 +1277,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
@Override
public void disconnected(final boolean errorCall) {
if (SwingUtilities.isEventDispatchThread()) { // Returns true if the current thread is an AWT event dispatching thread.
logger.info("DISCONNECTED (Event Dispatch Thread)");
@ -1288,14 +1298,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
enableButtons();
}
} else {
session.disconnect(false);
client.disconnect();
}
}
});
}
}
@Override
public void showMessage(final String message) {
if (SwingUtilities.isEventDispatchThread()) {
JOptionPane.showMessageDialog(desktopPane, message);
@ -1309,7 +1318,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
@Override
public void showError(final String message) {
if (SwingUtilities.isEventDispatchThread()) {
JOptionPane.showMessageDialog(desktopPane, message, "Error", JOptionPane.ERROR_MESSAGE);
@ -1323,9 +1331,59 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
// @Override
// public void processCallback(ClientCallback callback) {
// callbackClient.processCallback(callback);
// }
@Override
public void processCallback(ClientCallback callback) {
callbackClient.processCallback(callback);
public void inform(String message, MessageType type) {
if (type == MessageType.ERROR) {
showError(message);
}
else {
showMessage(message);
}
}
@Override
public void receiveChatMessage(final UUID chatId, final ChatMessage message) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ChatPanel panel = MageFrame.getChat(chatId);
if (panel != null) {
// send the message to subchat if exists and it's not a game message
if (!message.getMessageType().equals(ChatMessage.MessageType.GAME) && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message);
} else {
panel.receiveMessage(message);
}
}
}
});
}
@Override
public void receiveBroadcastMessage(String message) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void clientRegistered(ServerState state) {
this.serverState = state;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setWindowTitle();
showGames(false);
}
});
}
@Override
public ServerState getServerState() {
return serverState;
}
}

View file

@ -47,7 +47,7 @@ import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.*;
import javax.swing.*;
@ -60,6 +60,7 @@ import java.util.List;
import java.util.UUID;
import static mage.client.constants.Constants.*;
import org.mage.network.Client;
/**
*
@ -68,7 +69,8 @@ import static mage.client.constants.Constants.*;
@SuppressWarnings("serial")
public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener {
protected static Session session = MageFrame.getSession();
// protected static Session session = MageFrame.getSession();
protected static Client client = MageFrame.getClient();
protected static DefaultActionCallback callback = DefaultActionCallback.getInstance();
protected Point p;
@ -353,7 +355,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override
public void mousePressed(MouseEvent e) {
requestFocusInWindow();
callback.mouseClicked(e, gameId, session, card);
callback.mouseClicked(e, gameId, client, card);
}
@Override

View file

@ -45,13 +45,16 @@ import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumnModel;
import mage.client.MageFrame;
import mage.client.util.MageTableRowSorter;
import mage.client.util.audio.AudioManager;
import mage.remote.MageRemoteException;
import mage.remote.Session;
import mage.view.ChatMessage;
//import mage.remote.Session;
import mage.view.ChatMessage.MessageColor;
import mage.view.ChatMessage.MessageType;
import mage.view.RoomUsersView;
import mage.view.UsersView;
import org.mage.card.arcane.ManaSymbols;
import org.mage.network.Client;
/**
*
@ -60,7 +63,7 @@ import org.mage.card.arcane.ManaSymbols;
public class ChatPanel extends javax.swing.JPanel {
private UUID chatId;
private Session session;
private Client client;
private final List<String> players = new ArrayList<>();
private final TableModel tableModel;
/**
@ -174,20 +177,44 @@ public class ChatPanel extends javax.swing.JPanel {
}
public void connect(UUID chatId) {
session = MageFrame.getSession();
client = MageFrame.getClient();
this.chatId = chatId;
if (session.joinChat(chatId)) {
MageFrame.addChat(chatId, this);
}
client.joinChat(chatId);
MageFrame.addChat(chatId, this);
}
public void disconnect() {
if (session != null) {
session.leaveChat(chatId);
if (client != null) {
client.leaveChat(chatId);
MageFrame.removeChat(chatId);
}
}
public void receiveMessage(ChatMessage message) {
// play the to the message connected sound
if (message.getSoundToPlay() != null) {
switch (message.getSoundToPlay()) {
case PlayerLeft:
AudioManager.playPlayerLeft();
break;
case PlayerQuitTournament:
AudioManager.playPlayerQuitTournament();
break;
case PlayerSubmittedDeck:
AudioManager.playPlayerSubmittedDeck();
break;
case PlayerWhispered:
AudioManager.playPlayerWhispered();
break;
}
}
// send start message to chat if not done yet
if (!isStartMessageDone()) {
createChatStartMessage();
}
receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), message.getColor());
}
/**
* Display message in the chat. Use different colors for timestamp, username
* and message.
@ -198,7 +225,7 @@ public class ChatPanel extends javax.swing.JPanel {
* @param messageType
* @param color Preferred color. Not used.
*/
public void receiveMessage(String username, String message, String time, MessageType messageType, MessageColor color) {
private void receiveMessage(String username, String message, String time, MessageType messageType, MessageColor color) {
StringBuilder text = new StringBuilder();
if (time != null) {
text.append(getColoredText(TIMESTAMP_COLOR, time + ": "));
@ -218,9 +245,9 @@ public class ChatPanel extends javax.swing.JPanel {
break;
default:
if (parentChatRef != null) {
userColor = parentChatRef.session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
userColor = parentChatRef.client.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
} else {
userColor = session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
userColor = client.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
}
textColor = MESSAGE_COLOR;
userSeparator = ": ";
@ -238,6 +265,35 @@ public class ChatPanel extends javax.swing.JPanel {
this.txtConversation.append(text.toString());
}
private void createChatStartMessage() {
setStartMessageDone(true);
switch (getChatType()) {
case GAME:
receiveMessage("", new StringBuilder("You may use hot keys to play faster:")
.append("<br/>Turn mousewheel up (ALT-e) - enlarge image of card the mousepointer hovers over")
.append("<br/>Turn mousewheel down (ALT-s) - enlarge original/alternate image of card the mousepointer hovers over")
.append("<br/><b>F2</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button")
.append("<br/><b>F4</b> - Skip current turn but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F5</b> - Skip to next end step but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F7</b> - Skip to next main phase but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F9</b> - Skip everything until your next turn")
.append("<br/><b>F3</b> - Undo F4/F5/F7/F9").toString(),
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
break;
case TOURNAMENT:
receiveMessage("", new StringBuilder("On this panel you can see the players, their state and the results of the games of the tournament. Also you can chat with the competitors of the tournament.").toString(),
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
break;
case TABLES:
receiveMessage("", new StringBuilder("Download card images by using the \"Images\" menu to the top right .")
.append("<br/>Download icons and symbols by using the \"Symbols\" menu to the top right.")
.append("<br/>\\list - Show a list of available chat commands.").toString(),
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
break;
}
}
private String getColoredText(String color, String text) {
StringBuilder sb = new StringBuilder();
sb.append("<font color='");
@ -470,9 +526,9 @@ public class ChatPanel extends javax.swing.JPanel {
private void txtMessageKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMessageKeyTyped
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
if (parentChatRef != null) {
parentChatRef.session.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
parentChatRef.client.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
} else {
session.sendChatMessage(chatId, this.txtMessage.getText());
client.sendChatMessage(chatId, this.txtMessage.getText());
}
this.txtMessage.setText("");
this.txtMessage.repaint();

View file

@ -3,7 +3,7 @@ package mage.client.components.ability;
import mage.client.util.ImageHelper;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.AbilityPickerView;
import org.apache.log4j.Logger;
import org.jdesktop.layout.GroupLayout;
@ -17,6 +17,7 @@ import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.List;
import org.mage.network.Client;
/**
* Dialog for choosing abilities.
@ -35,7 +36,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
private List<Object> choices;
private String message = DEFAULT_MESSAGE;
private Session session;
private Client client;
private UUID gameId;
private BackgroundPainter mwPanelPainter;
@ -78,8 +79,8 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
}
public void init(Session session, UUID gameId) {
this.session = session;
public void init(Client client, UUID gameId) {
this.client = client;
this.gameId = gameId;
}
@ -449,7 +450,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
if (id == null) {
cancel();
} else {
session.sendPlayerUUID(gameId, id);
client.sendPlayerUUID(gameId, id);
}
setVisible(false);
AbilityPicker.this.selected = true;
@ -464,7 +465,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
private void cancel() {
try {
session.sendPlayerBoolean(gameId, false);
client.sendPlayerBoolean(gameId, false);
} catch (Exception e) {
log.error("Couldn't cancel choose dialog: " + e, e);
}

View file

@ -70,10 +70,11 @@ import mage.client.util.Listener;
import mage.client.util.audio.AudioManager;
import mage.components.CardInfoPane;
import mage.game.GameException;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.CardView;
import mage.view.SimpleCardView;
import org.apache.log4j.Logger;
import org.mage.network.Client;
/**
*
@ -169,7 +170,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
this.btnExit.setVisible(false);
this.btnImport.setVisible(false);
if (!MageFrame.getSession().isTestMode()) {
if (!MageFrame.getClient().getServerState().isTestMode()) {
this.btnLoad.setVisible(false);
}
this.deckArea.showSideboard(false);
@ -179,7 +180,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
if (timeout != 0) {
countdown.start();
if (updateDeckTask == null || updateDeckTask.isDone()) {
updateDeckTask = new UpdateDeckTask(MageFrame.getSession(), tableId, deck);
updateDeckTask = new UpdateDeckTask(MageFrame.getClient(), tableId, deck);
updateDeckTask.execute();
}
}
@ -190,7 +191,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
//this.cardTableSelector.loadCards(this.bigCard);
this.btnExit.setVisible(true);
this.btnImport.setVisible(true);
if (!MageFrame.getSession().isTestMode()) {
if (!MageFrame.getClient().getServerState().isTestMode()) {
this.btnLoad.setVisible(true);
}
this.deckArea.showSideboard(true);
@ -789,7 +790,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
updateDeckTask.cancel(true);
}
if (MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists())) {
if (MageFrame.getClient().submitDeck(tableId, deck.getDeckCardLists())) {
removeDeckEditor();
}
}//GEN-LAST:event_btnSubmitActionPerformed
@ -876,12 +877,12 @@ class ImportFilter extends FileFilter {
class UpdateDeckTask extends SwingWorker<Void, Void> {
private static final Logger logger = Logger.getLogger(UpdateDeckTask.class);
private final Session session;
private final Client client;
private final UUID tableId;
private final Deck deck;
UpdateDeckTask(Session session, UUID tableId, Deck deck) {
this.session = session;
UpdateDeckTask(Client client, UUID tableId, Deck deck) {
this.client = client;
this.tableId = tableId;
this.deck = deck;
}
@ -889,7 +890,7 @@ class UpdateDeckTask extends SwingWorker<Void, Void> {
@Override
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
session.updateDeck(tableId, deck.getDeckCardLists());
client.updateDeck(tableId, deck.getDeckCardLists());
Thread.sleep(5000);
}
return null;

View file

@ -354,7 +354,7 @@ public class ConnectDialog extends MageDialog {
protected Boolean doInBackground() throws Exception {
lblStatus.setText("Connecting...");
btnConnect.setEnabled(false);
result = MageFrame.connect(connection);
result = MageFrame.getInstance().connect(connection);
return result;
}
@ -366,7 +366,7 @@ public class ConnectDialog extends MageDialog {
if (result) {
lblStatus.setText("");
connected();
MageFrame.getInstance().showGames(false);
// MageFrame.getInstance().showGames(false);
} else {
lblStatus.setText("Could not connect");
}
@ -380,7 +380,7 @@ public class ConnectDialog extends MageDialog {
} catch (TimeoutException ex) {
logger.fatal("Connection timeout: ", ex);
} finally {
MageFrame.stopConnecting();
// MageFrame.stopConnecting();
btnConnect.setEnabled(true);
}
}

View file

@ -254,7 +254,7 @@ public class FeedbackDialog extends javax.swing.JDialog {
if (email.length() > 100) {
email = email.substring(0, 100);
}
if (MageFrame.getSession().sendFeedback(title, type, message, email)) {
if (MageFrame.getClient().sendFeedback(title, type, message, email)) {
JOptionPane.showMessageDialog(null, "Feedback was sent. Thank you!", "Success", JOptionPane.INFORMATION_MESSAGE);
reset();
dialog.setVisible(false);

View file

@ -31,8 +31,9 @@ import java.util.UUID;
import javax.swing.JOptionPane;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.remote.Session;
//import mage.remote.Session;
import org.apache.log4j.Logger;
import org.mage.network.Client;
/**
*
@ -58,7 +59,7 @@ public class JoinTableDialog extends MageDialog {
this.roomId = roomId;
this.tableId = tableId;
this.isTournament = isTournament;
this.newPlayerPanel.setPlayerName(MageFrame.getSession().getUserName());
this.newPlayerPanel.setPlayerName(MageFrame.getClient().getUserName());
this.newPlayerPanel.showDeckElements(!isLimited);
this.setModal(true);
this.setLocation(100, 100);
@ -146,13 +147,13 @@ public class JoinTableDialog extends MageDialog {
}//GEN-LAST:event_btnCancelActionPerformed
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
Session session = MageFrame.getSession();
Client client = MageFrame.getClient();
try {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, txtPassword.getText());
if (isTournament) {
joined = session.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
joined = client.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
} else {
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
joined = client.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
}
} catch (Exception ex) {

View file

@ -48,10 +48,11 @@ import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.constants.SkillLevel;
import mage.game.match.MatchOptions;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.GameTypeView;
import mage.view.TableView;
import org.apache.log4j.Logger;
import org.mage.network.Client;
/**
*
@ -64,7 +65,7 @@ public class NewTableDialog extends MageDialog {
private TableView table;
private UUID playerId;
private UUID roomId;
private final Session session;
private final Client client;
private String lastSessionId;
private final List<TablePlayerPanel> players = new ArrayList<>();
private final List<String> prefPlayerTypes = new ArrayList<>();
@ -73,7 +74,7 @@ public class NewTableDialog extends MageDialog {
/** Creates new form NewTableDialog */
public NewTableDialog() {
session = MageFrame.getSession();
client = MageFrame.getClient();
lastSessionId = "";
initComponents();
player1Panel.showLevel(false);
@ -370,13 +371,13 @@ public class NewTableDialog extends MageDialog {
}
saveGameSettingsToPrefs(options, this.player1Panel.getDeckFile());
table = session.createTable(roomId, options);
table = client.createTable(roomId, options);
if (table == null) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
if (session.joinTable(
if (client.joinTable(
roomId,
table.getTableId(),
this.player1Panel.getPlayerName(),
@ -388,7 +389,7 @@ public class NewTableDialog extends MageDialog {
if (!player.getPlayerType().equals("Human")) {
if (!player.joinTable(roomId, table.getTableId())) {
// error message must be send by the server
session.removeTable(roomId, table.getTableId());
client.removeTable(roomId, table.getTableId());
table = null;
return;
}
@ -405,7 +406,7 @@ public class NewTableDialog extends MageDialog {
handleError(ex);
}
// JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
session.removeTable(roomId, table.getTableId());
client.removeTable(roomId, table.getTableId());
table = null;
}//GEN-LAST:event_btnOKActionPerformed
@ -523,11 +524,11 @@ public class NewTableDialog extends MageDialog {
public void showDialog(UUID roomId) {
this.roomId = roomId;
if (!lastSessionId.equals(MageFrame.getSession().getSessionId())) {
lastSessionId = session.getSessionId();
this.player1Panel.setPlayerName(session.getUserName());
cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes().toArray()));
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
if (!lastSessionId.equals(MageFrame.getClient().getSessionId())) {
lastSessionId = client.getSessionId();
this.player1Panel.setPlayerName(client.getUserName());
cbGameType.setModel(new DefaultComboBoxModel(client.getServerState().getGameTypes().toArray()));
cbDeckType.setModel(new DefaultComboBoxModel(client.getServerState().getDeckTypes()));
selectLimitedByDefault();
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
@ -578,7 +579,7 @@ public class NewTableDialog extends MageDialog {
String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, "Two Player Duel");
for (GameTypeView gtv : session.getGameTypes()) {
for (GameTypeView gtv : client.getServerState().getGameTypes()) {
if (gtv.getName().equals(gameTypeName)) {
cbGameType.setSelectedItem(gtv);
break;

View file

@ -55,11 +55,12 @@ import mage.game.draft.DraftOptions;
import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions;
import mage.game.tournament.TournamentOptions;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.GameTypeView;
import mage.view.TableView;
import mage.view.TournamentTypeView;
import org.apache.log4j.Logger;
import org.mage.network.Client;
/**
@ -73,7 +74,7 @@ public class NewTournamentDialog extends MageDialog {
private TableView table;
private UUID playerId;
private UUID roomId;
private final Session session;
private final Client client;
private String lastSessionId;
private final List<TournamentPlayerPanel> players = new ArrayList<>();
private final List<JComboBox> packs = new ArrayList<>();
@ -85,7 +86,7 @@ public class NewTournamentDialog extends MageDialog {
/** Creates new form NewTournamentDialog */
public NewTournamentDialog() {
initComponents();
session = MageFrame.getSession();
client = MageFrame.getClient();
lastSessionId = "";
txtName.setText("Tournament");
this.spnNumWins.setModel(new SpinnerNumberModel(2, 1, 5, 1));
@ -96,18 +97,17 @@ public class NewTournamentDialog extends MageDialog {
public void showDialog(UUID roomId) {
this.roomId = roomId;
if (!lastSessionId.equals(MageFrame.getSession().getSessionId())) {
lastSessionId = session.getSessionId();
this.player1Panel.setPlayerName(session.getUserName());
if (!lastSessionId.equals(MageFrame.getClient().getSessionId())) {
lastSessionId = client.getSessionId();
this.player1Panel.setPlayerName(client.getUserName());
this.player1Panel.showLevel(false); // no computer
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
cbTournamentType.setModel(new DefaultComboBoxModel(client.getServerState().getTournamentTypes().toArray()));
cbGameType.setModel(new DefaultComboBoxModel(session.getTournamentGameTypes().toArray()));
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
cbGameType.setModel(new DefaultComboBoxModel(client.getServerState().getTournamentGameTypes().toArray()));
cbDeckType.setModel(new DefaultComboBoxModel(client.getServerState().getDeckTypes()));
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values()));
cbDraftCube.setModel(new DefaultComboBoxModel(session.getDraftCubes()));
cbDraftCube.setModel(new DefaultComboBoxModel(client.getServerState().getDraftCubes()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
// update player types
int i=2;
@ -537,12 +537,12 @@ public class NewTournamentDialog extends MageDialog {
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
saveTournamentSettingsToPrefs(tOptions);
table = session.createTournamentTable(roomId, tOptions);
table = client.createTournamentTable(roomId, tOptions);
if (table == null) {
// message must be send by server!
return;
}
if (session.joinTournamentTable(
if (client.joinTournamentTable(
roomId,
table.getTableId(),
this.player1Panel.getPlayerName(),
@ -553,7 +553,7 @@ public class NewTournamentDialog extends MageDialog {
if (!player.getPlayerType().toString().equals("Human")) {
if (!player.joinTournamentTable(roomId, table.getTableId(), DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
// error message must be send by sever
session.removeTable(roomId, table.getTableId());
client.removeTable(roomId, table.getTableId());
table = null;
return;
}
@ -563,7 +563,7 @@ public class NewTournamentDialog extends MageDialog {
return;
}
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
session.removeTable(roomId, table.getTableId());
client.removeTable(roomId, table.getTableId());
table = null;
}//GEN-LAST:event_btnOkActionPerformed
@ -799,7 +799,7 @@ public class NewTournamentDialog extends MageDialog {
}
this.spnConstructTime.setValue(constructionTime);
String tournamentTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, "Sealed Elimination");
for (TournamentTypeView tournamentTypeView : session.getTournamentTypes()) {
for (TournamentTypeView tournamentTypeView : client.getServerState().getTournamentTypes()) {
if (tournamentTypeView.getName().equals(tournamentTypeName)) {
cbTournamentType.setSelectedItem(tournamentTypeView);
break;

View file

@ -1686,7 +1686,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
try {
MageFrame.getSession().updatePreferencesForServer(
MageFrame.getClient().updatePreferencesForServer(
getSelectedAvatar(),
dialog.showAbilityPickerForced.isSelected(),
dialog.cbAllowRequestToShowHandCards.isSelected(),
@ -2357,7 +2357,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public void mousePressed(MouseEvent e) {
if (selectedAvatarId != id) {
setSelectedId(id);
MageFrame.getSession().updatePreferencesForServer(
MageFrame.getClient().updatePreferencesForServer(
id,
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"),

View file

@ -45,10 +45,11 @@ import mage.client.chat.ChatPanel;
import mage.client.components.MageComponents;
import mage.client.components.tray.MageTray;
import mage.client.util.audio.AudioManager;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.SeatView;
import mage.view.TableView;
import org.apache.log4j.Logger;
import org.mage.network.Client;
/**
*
@ -61,14 +62,14 @@ public class TableWaitingDialog extends MageDialog {
private UUID tableId;
private UUID roomId;
private boolean isTournament;
private Session session;
private Client client;
private final TableWaitModel tableWaitModel;
private UpdateSeatsTask updateTask;
/** Creates new form TableWaitingDialog */
public TableWaitingDialog() {
session = MageFrame.getSession();
client = MageFrame.getClient();
tableWaitModel = new TableWaitModel();
initComponents();
@ -113,9 +114,9 @@ public class TableWaitingDialog extends MageDialog {
this.roomId = roomId;
this.tableId = tableId;
this.isTournament = isTournament;
session = MageFrame.getSession();
updateTask = new UpdateSeatsTask(session, roomId, tableId, this);
if (session.isTableOwner(roomId, tableId)) {
client = MageFrame.getClient();
updateTask = new UpdateSeatsTask(client, roomId, tableId, this);
if (client.isTableOwner(roomId, tableId)) {
this.btnStart.setVisible(true);
this.btnMoveDown.setVisible(true);
this.btnMoveUp.setVisible(true);
@ -124,7 +125,7 @@ public class TableWaitingDialog extends MageDialog {
this.btnMoveDown.setVisible(false);
this.btnMoveUp.setVisible(false);
}
UUID chatId = session.getTableChatId(tableId);
UUID chatId = client.getTableChatId(tableId);
if (chatId != null) {
this.chatPanel.connect(chatId);
updateTask.execute();
@ -245,12 +246,12 @@ public class TableWaitingDialog extends MageDialog {
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
if (!isTournament) {
if (session.startMatch(roomId, tableId)) {
if (client.startMatch(roomId, tableId)) {
closeDialog();
}
}
else {
if (session.startTournament(roomId, tableId)) {
if (client.startTournament(roomId, tableId)) {
closeDialog();
}
}
@ -258,7 +259,7 @@ public class TableWaitingDialog extends MageDialog {
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
try {
if (!session.leaveTable(roomId, tableId)) {
if (!client.leaveTable(roomId, tableId)) {
return; // already started, so leave no more possible
}
} catch (Exception e) {
@ -271,7 +272,7 @@ public class TableWaitingDialog extends MageDialog {
private void btnMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveDownActionPerformed
int row = this.tableSeats.getSelectedRow();
if (row < this.tableSeats.getRowCount() - 1) {
session.swapSeats(roomId, tableId, row, row + 1);
client.swapSeats(roomId, tableId, row, row + 1);
this.tableSeats.getSelectionModel().setSelectionInterval(row + 1, row + 1);
}
@ -280,7 +281,7 @@ public class TableWaitingDialog extends MageDialog {
private void btnMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveUpActionPerformed
int row = this.tableSeats.getSelectedRow();
if (row > 0) {
session.swapSeats(roomId, tableId, row, row - 1);
client.swapSeats(roomId, tableId, row, row - 1);
this.tableSeats.getSelectionModel().setSelectionInterval(row - 1, row - 1);
}
}//GEN-LAST:event_btnMoveUpActionPerformed
@ -363,7 +364,7 @@ class TableWaitModel extends AbstractTableModel {
class UpdateSeatsTask extends SwingWorker<Void, TableView> {
private final Session session;
private final Client client;
private final UUID roomId;
private final UUID tableId;
private final TableWaitingDialog dialog;
@ -371,8 +372,8 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
private static final Logger logger = Logger.getLogger(TableWaitingDialog.class);
UpdateSeatsTask(Session session, UUID roomId, UUID tableId, TableWaitingDialog dialog) {
this.session = session;
UpdateSeatsTask(Client client, UUID roomId, UUID tableId, TableWaitingDialog dialog) {
this.client = client;
this.roomId = roomId;
this.tableId = tableId;
this.dialog = dialog;
@ -381,7 +382,7 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
@Override
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
this.publish(session.getTable(roomId, tableId));
this.publish(client.getTable(roomId, tableId));
Thread.sleep(1000);
}
return null;

View file

@ -37,8 +37,9 @@ package mage.client.dialog;
import mage.client.MageFrame;
import mage.constants.PlayerAction;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.UserRequestMessage;
import org.mage.network.Client;
/**
*
@ -176,10 +177,10 @@ public class UserRequestDialog extends MageDialog {
}//GEN-LAST:event_btn3ActionPerformed
private void sendUserReplay(PlayerAction playerAction) {
Session session = MageFrame.getSession();
Client client = MageFrame.getClient();
switch(playerAction) {
case ADD_PERMISSION_TO_SEE_HAND_CARDS:
session.sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
client.sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
break;
default:
// not supported action

View file

@ -63,12 +63,13 @@ import mage.client.util.ImageHelper;
import mage.client.util.Listener;
import mage.client.util.audio.AudioManager;
import mage.client.util.gui.BufferedImageBuilder;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.CardsView;
import mage.view.DraftPickView;
import mage.view.DraftView;
import mage.view.SimpleCardView;
import mage.view.SimpleCardsView;
import org.mage.network.Client;
/**
*
@ -77,7 +78,7 @@ import mage.view.SimpleCardsView;
public class DraftPanel extends javax.swing.JPanel {
private UUID draftId;
private Session session;
private Client client;
private Timer countdown;
private int timeout;
@ -144,9 +145,9 @@ public class DraftPanel extends javax.swing.JPanel {
public synchronized void showDraft(UUID draftId) {
this.draftId = draftId;
session = MageFrame.getSession();
client = MageFrame.getClient();
MageFrame.addDraft(draftId, this);
if (!session.joinDraft(draftId)) {
if (!client.joinDraft(draftId)) {
hideDraft();
}
}
@ -270,7 +271,7 @@ public class DraftPanel extends javax.swing.JPanel {
public void event(Event event) {
if (event.getEventName().equals("pick-a-card")) {
SimpleCardView source = (SimpleCardView) event.getSource();
DraftPickView view = session.sendCardPick(draftId, source.getId(), cardsHidden);
DraftPickView view = client.sendCardPick(draftId, source.getId(), cardsHidden);
if (view != null) {
loadCardsToPickedCardsArea(view.getPicks());
draftBooster.loadBooster(emptyView, bigCard);
@ -280,7 +281,7 @@ public class DraftPanel extends javax.swing.JPanel {
}
if (event.getEventName().equals("mark-a-card")) {
SimpleCardView source = (SimpleCardView) event.getSource();
session.sendCardMark(draftId, source.getId());
client.sendCardMark(draftId, source.getId());
}
}
}
@ -764,7 +765,7 @@ public class DraftPanel extends javax.swing.JPanel {
private void btnQuitTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitTournamentActionPerformed
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to quit the tournament?", "Confirm quit tournament", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().quitDraft(draftId);
MageFrame.getClient().quitDraft(draftId);
MageFrame.removeDraft(draftId);
}
}//GEN-LAST:event_btnQuitTournamentActionPerformed

View file

@ -30,7 +30,7 @@ package mage.client.game;
import mage.client.MageFrame;
import mage.client.util.gui.GuiDisplayUtil;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.AbilityPickerView;
import javax.swing.*;
@ -40,6 +40,7 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Map.Entry;
import java.util.UUID;
import org.mage.network.Client;
/**
* ************************ U N U S E D *********************************
@ -49,15 +50,15 @@ import java.util.UUID;
*/
public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
private Session session;
private Client client;
private UUID gameId;
public AbilityPicker(String ThisIsnotUsedAnymore) {
this.addPopupMenuListener(this);
}
public void init(Session session, UUID gameId) {
this.session = session;
public void init(Client client, UUID gameId) {
this.client = client;
this.gameId = gameId;
}
@ -85,7 +86,7 @@ public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
session.sendPlayerBoolean(gameId, false);
client.sendPlayerBoolean(gameId, false);
}
private class AbilityPickerAction extends AbstractAction {
@ -99,7 +100,7 @@ public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
@Override
public void actionPerformed(ActionEvent e) {
session.sendPlayerUUID(gameId, id);
client.sendPlayerUUID(gameId, id);
setVisible(false);
}

View file

@ -49,8 +49,9 @@ import mage.client.dialog.MageDialog;
import mage.client.util.audio.AudioManager;
import mage.client.util.gui.ArrowBuilder;
import mage.constants.PlayerAction;
import mage.remote.Session;
//import mage.remote.Session;
import org.apache.log4j.Logger;
import org.mage.network.Client;
/**
*
@ -65,7 +66,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
}
private UUID gameId;
private Session session;
private Client client;
private FeedbackMode mode;
private MageDialog connectedDialog;
private ChatPanel connectedChatPanel;
@ -81,7 +82,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
public void init(UUID gameId) {
this.gameId = gameId;
session = MageFrame.getSession();
client = MageFrame.getClient();
}
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options, int messageId) {
@ -273,29 +274,29 @@ public class FeedbackPanel extends javax.swing.JPanel {
connectedDialog = null;
}
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
session.sendPlayerInteger(gameId, 0);
client.sendPlayerInteger(gameId, 0);
} else if (mode == FeedbackMode.END) {
GamePanel gamePanel = MageFrame.getGame(gameId);
if (gamePanel != null) {
gamePanel.removeGame();
}
} else {
session.sendPlayerBoolean(gameId, false);
client.sendPlayerBoolean(gameId, false);
}
//AudioManager.playButtonOk();
}//GEN-LAST:event_btnRightActionPerformed
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
session.sendPlayerBoolean(gameId, true);
client.sendPlayerBoolean(gameId, true);
AudioManager.playButtonCancel();
}//GEN-LAST:event_btnLeftActionPerformed
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
session.sendPlayerString(gameId, "special");
client.sendPlayerString(gameId, "special");
}//GEN-LAST:event_btnSpecialActionPerformed
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.UNDO, gameId, null);
client.sendPlayerAction(PlayerAction.UNDO, gameId, null);
}
public void setHelperPanel(HelperPanel helper) {

View file

@ -115,7 +115,7 @@ import static mage.constants.PhaseStep.UNTAP;
import static mage.constants.PhaseStep.UPKEEP;
import mage.constants.PlayerAction;
import mage.constants.Zone;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.AbilityPickerView;
import mage.view.CardView;
import mage.view.CardsView;
@ -127,6 +127,7 @@ import mage.view.PlayerView;
import mage.view.RevealedView;
import mage.view.SimpleCardsView;
import org.apache.log4j.Logger;
import org.mage.network.Client;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
@ -147,7 +148,7 @@ public final class GamePanel extends javax.swing.JPanel {
private final ArrayList<ShowCardsDialog> pickTarget = new ArrayList<>();
private UUID gameId;
private UUID playerId; // playerId of the player
private Session session;
private Client client;
GamePane gamePane;
private ReplayTask replayTask;
private final PickNumberDialog pickNumber;
@ -359,11 +360,11 @@ public final class GamePanel extends javax.swing.JPanel {
this.gameId = gameId;
this.gamePane = gamePane;
this.playerId = playerId;
session = MageFrame.getSession();
client = MageFrame.getClient();
MageFrame.addGame(gameId, this);
this.feedbackPanel.init(gameId);
this.feedbackPanel.clear();
this.abilityPicker.init(session, gameId);
this.abilityPicker.init(client, gameId);
this.btnConcede.setVisible(true);
this.btnStopWatching.setVisible(false);
@ -379,8 +380,8 @@ public final class GamePanel extends javax.swing.JPanel {
this.pnlReplay.setVisible(false);
this.gameChatPanel.clear();
this.gameChatPanel.connect(session.getGameChatId(gameId));
if (!session.joinGame(gameId)) {
this.gameChatPanel.connect(client.getGameChatId(gameId));
if (!client.joinGame(gameId)) {
removeGame();
} else {
AudioManager.playYourGameStarted();
@ -391,7 +392,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.gameId = gameId;
this.gamePane = gamePane;
this.playerId = null;
session = MageFrame.getSession();
client = MageFrame.getClient();
MageFrame.addGame(gameId, this);
this.feedbackPanel.init(gameId);
this.feedbackPanel.clear();
@ -411,8 +412,8 @@ public final class GamePanel extends javax.swing.JPanel {
this.pnlReplay.setVisible(false);
this.gameChatPanel.clear();
this.gameChatPanel.connect(session.getGameChatId(gameId));
if (!session.watchGame(gameId)) {
this.gameChatPanel.connect(client.getGameChatId(gameId));
if (!client.watchGame(gameId)) {
removeGame();
}
for (PlayAreaPanel panel : getPlayers().values()) {
@ -423,7 +424,7 @@ public final class GamePanel extends javax.swing.JPanel {
public synchronized void replayGame(UUID gameId) {
this.gameId = gameId;
this.playerId = null;
session = MageFrame.getSession();
client = MageFrame.getClient();
MageFrame.addGame(gameId, this);
this.feedbackPanel.init(gameId);
this.feedbackPanel.clear();
@ -433,7 +434,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.btnStopWatching.setVisible(false);
this.pnlReplay.setVisible(true);
this.gameChatPanel.clear();
if (!session.startReplay(gameId)) {
if (!client.startReplay(gameId)) {
removeGame();
}
for (PlayAreaPanel panel : getPlayers().values()) {
@ -950,10 +951,10 @@ public final class GamePanel extends javax.swing.JPanel {
public void getAmount(int min, int max, String message) {
pickNumber.showDialog(min, max, message);
if (pickNumber.isCancel()) {
session.sendPlayerBoolean(gameId, false);
client.sendPlayerBoolean(gameId, false);
}
else {
session.sendPlayerInteger(gameId, pickNumber.getAmount());
client.sendPlayerInteger(gameId, pickNumber.getAmount());
}
}
@ -963,12 +964,12 @@ public final class GamePanel extends javax.swing.JPanel {
pickChoice.showDialog(choice, objectId,choiceWindowState);
if (choice.isKeyChoice()) {
if (pickChoice.isAutoSelect()) {
session.sendPlayerString(gameId, "#" + choice.getChoiceKey());
client.sendPlayerString(gameId, "#" + choice.getChoiceKey());
} else {
session.sendPlayerString(gameId, choice.getChoiceKey());
client.sendPlayerString(gameId, choice.getChoiceKey());
}
} else {
session.sendPlayerString(gameId, choice.getChoice());
client.sendPlayerString(gameId, choice.getChoice());
}
choiceWindowState = new MageDialogState(pickChoice);
pickChoice.removeDialog();
@ -978,7 +979,7 @@ public final class GamePanel extends javax.swing.JPanel {
hideAll();
PickPileDialog pickPileDialog = new PickPileDialog();
pickPileDialog.loadCards(message, pile1, pile2, bigCard, Config.dimensions, gameId);
session.sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
client.sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
pickPileDialog.cleanUp();
pickPileDialog.removeDialog();
}
@ -1696,42 +1697,42 @@ public final class GamePanel extends javax.swing.JPanel {
private void btnConcedeActionPerformed(java.awt.event.ActionEvent evt) {
if (modalQuestion("Are you sure you want to concede?", "Confirm concede") == JOptionPane.YES_OPTION) {
session.sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
client.sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
}
}
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(true, false, false, false, false);
}
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(false, true, false, false, false);
}
private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, true, false, false);
}
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, false, true, false);
}
private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, false, false, true);
}
private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
AudioManager.playOnSkipButtonCancel();
updateSkipButtons(false, false, false, false, false);
}
@ -1762,7 +1763,7 @@ public final class GamePanel extends javax.swing.JPanel {
private void btnStopWatchingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopWatchingActionPerformed
if (modalQuestion("Are you sure you want to stop watching?", "Stop watching") == JOptionPane.YES_OPTION) {
session.stopWatching(gameId);
client.stopWatching(gameId);
this.removeGame();
}
}//GEN-LAST:event_btnStopWatchingActionPerformed
@ -1772,27 +1773,27 @@ public final class GamePanel extends javax.swing.JPanel {
replayTask.cancel(true);
}
else if (modalQuestion("Are you sure you want to stop replay?", "Stop replay") == JOptionPane.YES_OPTION) {
session.stopReplay(gameId);
client.stopReplay(gameId);
}
}//GEN-LAST:event_btnStopReplayActionPerformed
private void btnNextPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextPlayActionPerformed
session.nextPlay(gameId);
client.nextPlay(gameId);
}//GEN-LAST:event_btnNextPlayActionPerformed
private void btnPreviousPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPreviousPlayActionPerformed
session.previousPlay(gameId);
client.previousPlay(gameId);
}//GEN-LAST:event_btnPreviousPlayActionPerformed
private void btnPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayActionPerformed
if (replayTask == null || replayTask.isDone()) {
replayTask = new ReplayTask(session, gameId);
replayTask = new ReplayTask(client, gameId);
replayTask.execute();
}
}//GEN-LAST:event_btnPlayActionPerformed
private void btnSkipForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSkipForwardActionPerformed
session.skipForward(gameId, 10);
client.skipForward(gameId, 10);
}//GEN-LAST:event_btnSkipForwardActionPerformed
public void setJLayeredPane(JLayeredPane jLayeredPane) {
@ -1822,8 +1823,8 @@ public final class GamePanel extends javax.swing.JPanel {
return gameChatPanel.getText();
}
public Session getSession() {
return session;
public Client getClient() {
return client;
}
public Map<String, Card> getLoadedCards() {
@ -1898,20 +1899,20 @@ public final class GamePanel extends javax.swing.JPanel {
}
class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
private final Session session;
private final Client client;
private final UUID gameId;
private static final Logger logger = Logger.getLogger(ReplayTask.class);
ReplayTask(Session session, UUID gameId) {
this.session = session;
ReplayTask(Client client, UUID gameId) {
this.client = client;
this.gameId = gameId;
}
@Override
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
session.nextPlay(gameId);
client.nextPlay(gameId);
Thread.sleep(1000);
}
return null;

View file

@ -159,7 +159,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
}
});
@ -172,7 +172,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
}
});
@ -183,7 +183,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
}
});
@ -194,7 +194,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
}
});
menuItem = new JMenuItem("F9 - Skip everything until own next turn (stop on attack/block)");
@ -204,7 +204,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
}
});
@ -221,7 +221,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
public void actionPerformed(ActionEvent e) {
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
gamePanel.setMenuStates(manaPoolAutomatic);
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
gamePanel.getClient().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
}
});
@ -234,7 +234,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
gamePanel.getClient().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
}
});
@ -248,7 +248,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
gamePanel.getClient().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
}
});
} else {
@ -263,7 +263,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
public void actionPerformed(ActionEvent e) {
boolean requestsAllowed = ((JCheckBoxMenuItem)e.getSource()).getState();
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);
gamePanel.getClient().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON: PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
}
});
@ -276,7 +276,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
gamePanel.getClient().sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
}
});
}
@ -290,7 +290,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
@Override
public void actionPerformed(ActionEvent e) {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the game?", "Confirm concede game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
MageFrame.getClient().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
}
}
});
@ -305,7 +305,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
@Override
public void actionPerformed(ActionEvent e) {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the complete match?", "Confirm concede match", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().quitMatch(gameId);
MageFrame.getClient().quitMatch(gameId);
}
}
});
@ -343,7 +343,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
@Override
public void actionPerformed(ActionEvent e) {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to stop watching the game?", "Confirm stop watching game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
gamePanel.getSession().stopWatching(gameId);
gamePanel.getClient().stopWatching(gameId);
gamePanel.removeGame();
}
}
@ -356,7 +356,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
gamePanel.getClient().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
}
});
@ -384,7 +384,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
this.playerPanel.init(gameId, player.getPlayerId(), bigCard, priorityTime);
this.battlefieldPanel.init(gameId, bigCard);
this.gameId = gameId;
if (MageFrame.getSession().isTestMode()) {
if (MageFrame.getClient().getServerState().isTestMode()) {
this.playerId = player.getPlayerId();
this.btnCheat.setVisible(true);
}
@ -461,7 +461,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
MageFrame.getSession().cheat(gameId, playerId, DeckImporterUtil.importDeck("cheat.dck"));
MageFrame.getClient().cheat(gameId, playerId, DeckImporterUtil.importDeck("cheat.dck"));
}
public boolean isSmallMode() {

View file

@ -53,7 +53,7 @@ import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
import mage.components.ImagePanel;
import mage.constants.ManaType;
import mage.remote.Session;
//import mage.remote.Session;
import mage.utils.timer.PriorityTimer;
import mage.view.CardView;
import mage.view.ManaPoolView;
@ -73,6 +73,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import org.mage.network.Client;
/**
* Enhanced player pane.
@ -83,7 +84,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private UUID playerId;
private UUID gameId;
private Session session;
private Client client;
private PlayerView player;
private BigCard bigCard;
@ -118,8 +119,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
this.gameId = gameId;
this.playerId = playerId;
this.bigCard = bigCard;
session = MageFrame.getSession();
cheat.setVisible(session.isTestMode());
client = MageFrame.getClient();
cheat.setVisible(client.getServerState().isTestMode());
cheat.setFocusable(false);
if (priorityTime > 0) {
@ -347,7 +348,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
avatar.setObserver(new Command() {
@Override
public void execute() {
session.sendPlayerUUID(gameId, playerId);
client.sendPlayerUUID(gameId, playerId);
}
});
// timer area /small layout)
@ -467,7 +468,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
btnPlayer.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
session.sendPlayerUUID(gameId, playerId);
client.sendPlayerUUID(gameId, playerId);
}
});
@ -783,7 +784,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
private void btnManaActionPerformed(ManaType manaType) {
session.sendPlayerManaType(gameId, player.getPlayerId(), manaType);
client.sendPlayerManaType(gameId, player.getPlayerId(), manaType);
}
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
@ -804,7 +805,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
DckDeckImporter deckImporter = new DckDeckImporter();
session.cheat(gameId, playerId, deckImporter.importDeck("cheat.dck"));
client.cheat(gameId, playerId, deckImporter.importDeck("cheat.dck"));
}
public PlayerView getPlayer() {

View file

@ -15,7 +15,7 @@ import mage.client.util.gui.ArrowUtil;
import mage.client.util.gui.GuiDisplayUtil;
import mage.components.CardInfoPane;
import mage.constants.EnlargeMode;
import mage.remote.Session;
//import mage.remote.Session;
import mage.utils.ThreadUtils;
import mage.view.CardView;
import mage.view.PermanentView;
@ -35,6 +35,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.mage.network.Client;
/**
* Class that handles the callbacks from the card panels to mage to display big card
@ -57,7 +58,7 @@ public class MageActionCallback implements ActionCallback {
private JPopupMenu jPopupMenu;
private BigCard bigCard;
protected static final DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
protected static Session session = MageFrame.getSession();
protected static Client client = MageFrame.getClient();
private CardView popupCard;
private TransferData popupData;
private JComponent cardInfoPane;
@ -89,8 +90,8 @@ public class MageActionCallback implements ActionCallback {
}
public synchronized void refreshSession() {
if (session == null) {
session = MageFrame.getSession();
if (client == null) {
client = MageFrame.getClient();
}
if (cardInfoPane == null) {
cardInfoPane = Plugins.getInstance().getCardInfoPane();
@ -157,7 +158,7 @@ public class MageActionCallback implements ActionCallback {
public void run() {
ThreadUtils.sleep(300);
if (popupCard == null || !popupCard.equals(data.card) || session == null || !popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
if (popupCard == null || !popupCard.equals(data.card) || client == null || !popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
return;
}
@ -234,13 +235,13 @@ public class MageActionCallback implements ActionCallback {
this.startedDragging = false;
if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements
transferData.component.requestFocusInWindow();
defaultCallback.mouseClicked(e, transferData.gameId, session, transferData.card);
defaultCallback.mouseClicked(e, transferData.gameId, client, transferData.card);
// Closes popup & enlarged view if a card/Permanent is selected
hidePopup();
}
} else {
transferData.component.requestFocusInWindow();
defaultCallback.mouseClicked(e, transferData.gameId, session, transferData.card);
defaultCallback.mouseClicked(e, transferData.gameId, client, transferData.card);
// Closes popup & enlarged view if a card/Permanent is selected
hidePopup();
}
@ -400,7 +401,7 @@ public class MageActionCallback implements ActionCallback {
jPopupMenu.setVisible(false);
}
try {
if (session == null) {
if (client == null) {
return;
}
// set enlarged card display to visible = false

View file

@ -119,38 +119,38 @@ public class CallbackClientImpl implements CallbackClient {
break;
case "chatMessage":
{
ChatMessage message = (ChatMessage) callback.getData();
ChatPanel panel = MageFrame.getChat(callback.getObjectId());
if (panel != null) {
// play the to the message connected sound
if (message.getSoundToPlay() != null) {
switch (message.getSoundToPlay()) {
case PlayerLeft:
AudioManager.playPlayerLeft();
break;
case PlayerQuitTournament:
AudioManager.playPlayerQuitTournament();
break;
case PlayerSubmittedDeck:
AudioManager.playPlayerSubmittedDeck();
break;
case PlayerWhispered:
AudioManager.playPlayerWhispered();
break;
}
}
// send start message to chat if not done yet
if (!panel.isStartMessageDone()) {
createChatStartMessage(panel);
}
// send the message to subchat if exists and it's not a game message
if (!message.getMessageType().equals(MessageType.GAME) && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
} else {
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), message.getColor());
}
} break;
// ChatMessage message = (ChatMessage) callback.getData();
// ChatPanel panel = MageFrame.getChat(callback.getObjectId());
// if (panel != null) {
// // play the to the message connected sound
// if (message.getSoundToPlay() != null) {
// switch (message.getSoundToPlay()) {
// case PlayerLeft:
// AudioManager.playPlayerLeft();
// break;
// case PlayerQuitTournament:
// AudioManager.playPlayerQuitTournament();
// break;
// case PlayerSubmittedDeck:
// AudioManager.playPlayerSubmittedDeck();
// break;
// case PlayerWhispered:
// AudioManager.playPlayerWhispered();
// break;
// }
// }
// // send start message to chat if not done yet
// if (!panel.isStartMessageDone()) {
// createChatStartMessage(panel);
// }
// // send the message to subchat if exists and it's not a game message
// if (!message.getMessageType().equals(MessageType.GAME) && panel.getConnectedChat() != null) {
// panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
// } else {
// panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), message.getColor());
// }
//
// } break;
}
case "serverMessage":
if (callback.getData() != null) {
@ -392,38 +392,38 @@ public class CallbackClientImpl implements CallbackClient {
});
}
private void createChatStartMessage(ChatPanel chatPanel) {
chatPanel.setStartMessageDone(true);
ChatPanel usedPanel = chatPanel;
if (chatPanel.getConnectedChat() != null) {
usedPanel = chatPanel.getConnectedChat();
}
switch (usedPanel.getChatType()) {
case GAME:
usedPanel.receiveMessage("", new StringBuilder("You may use hot keys to play faster:")
.append("<br/>Turn mousewheel up (ALT-e) - enlarge image of card the mousepointer hovers over")
.append("<br/>Turn mousewheel down (ALT-s) - enlarge original/alternate image of card the mousepointer hovers over")
.append("<br/><b>F2</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button")
.append("<br/><b>F4</b> - Skip current turn but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F5</b> - Skip to next end step but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F7</b> - Skip to next main phase but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>F9</b> - Skip everything until your next turn")
.append("<br/><b>F3</b> - Undo F4/F5/F7/F9").toString(),
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
break;
case TOURNAMENT:
usedPanel.receiveMessage("", new StringBuilder("On this panel you can see the players, their state and the results of the games of the tournament. Also you can chat with the competitors of the tournament.").toString(),
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
break;
case TABLES:
usedPanel.receiveMessage("", new StringBuilder("Download card images by using the \"Images\" menu to the top right .")
.append("<br/>Download icons and symbols by using the \"Symbols\" menu to the top right.")
.append("<br/>\\list - Show a list of available chat commands.").toString(),
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
break;
}
}
// private void createChatStartMessage(ChatPanel chatPanel) {
// chatPanel.setStartMessageDone(true);
// ChatPanel usedPanel = chatPanel;
// if (chatPanel.getConnectedChat() != null) {
// usedPanel = chatPanel.getConnectedChat();
// }
// switch (usedPanel.getChatType()) {
// case GAME:
// usedPanel.receiveMessage("", new StringBuilder("You may use hot keys to play faster:")
// .append("<br/>Turn mousewheel up (ALT-e) - enlarge image of card the mousepointer hovers over")
// .append("<br/>Turn mousewheel down (ALT-s) - enlarge original/alternate image of card the mousepointer hovers over")
// .append("<br/><b>F2</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button")
// .append("<br/><b>F4</b> - Skip current turn but stop on declare attackers/blockers and something on the stack")
// .append("<br/><b>F5</b> - Skip to next end step but stop on declare attackers/blockers and something on the stack")
// .append("<br/><b>F7</b> - Skip to next main phase but stop on declare attackers/blockers and something on the stack")
// .append("<br/><b>F9</b> - Skip everything until your next turn")
// .append("<br/><b>F3</b> - Undo F4/F5/F7/F9").toString(),
// null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
// break;
// case TOURNAMENT:
// usedPanel.receiveMessage("", new StringBuilder("On this panel you can see the players, their state and the results of the games of the tournament. Also you can chat with the competitors of the tournament.").toString(),
// null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
// break;
// case TABLES:
// usedPanel.receiveMessage("", new StringBuilder("Download card images by using the \"Images\" menu to the top right .")
// .append("<br/>Download icons and symbols by using the \"Symbols\" menu to the top right.")
// .append("<br/>\\list - Show a list of available chat commands.").toString(),
// null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
// break;
//
// }
// }
private void joinedTable(UUID roomId, UUID tableId, boolean isTournament) {
try {

View file

@ -43,7 +43,8 @@ import mage.client.MageFrame;
import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.remote.Session;
import org.mage.network.Client;
//import mage.remote.Session;
/**
*
@ -53,7 +54,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
protected PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
private Session session;
private Client client;
/** Creates new form TablePlayerPanel */
public TablePlayerPanel() {
@ -62,8 +63,8 @@ public class TablePlayerPanel extends javax.swing.JPanel {
}
public void init(int playerNum, String playerType) {
session = MageFrame.getSession();
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
client = MageFrame.getClient();
cbPlayerType.setModel(new DefaultComboBoxModel(client.getServerState().getPlayerTypes()));
this.lblPlayerNum.setText("Player " + playerNum);
if (Config.defaultOtherPlayerIndex != null) {
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount()) {
@ -81,7 +82,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
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 client.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
}
return true;
}

View file

@ -62,7 +62,7 @@ public class TablesPane extends MagePane {
}
public void showTables() {
UUID roomId = MageFrame.getSession().getMainRoomId();
UUID roomId = MageFrame.getClient().getServerState().getMainRoomId();
if (roomId != null) {
this.setTitle("Tables");
tablesPanel.showTables(roomId);

View file

@ -88,12 +88,13 @@ import mage.constants.RangeOfInfluence;
import mage.constants.SkillLevel;
import mage.game.match.MatchOptions;
import mage.remote.MageRemoteException;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.MatchView;
import mage.view.RoomUsersView;
import mage.view.TableView;
import org.apache.log4j.Logger;
import org.mage.card.arcane.Util;
import org.mage.network.Client;
/**
*
@ -113,7 +114,7 @@ public class TablesPanel extends javax.swing.JPanel {
private NewTableDialog newTableDialog;
private NewTournamentDialog newTournamentDialog;
private GameChooser gameChooser;
private Session session;
private Client client;
private List<String> messages;
private int currentMessage;
private MageTableRowSorter activeTablesSorter;
@ -128,7 +129,7 @@ public class TablesPanel extends javax.swing.JPanel {
gameChooser = new GameChooser();
initComponents();
tableModel.setSession(session);
tableModel.setClient(client);
tableTables.createDefaultColumnsFromModel();
@ -174,7 +175,7 @@ public class TablesPanel extends javax.swing.JPanel {
String owner = (String)tableModel.getValueAt(modelRow, TableTableModel.COLUMN_OWNER);
switch (action) {
case "Join":
if (owner.equals(session.getUserName()) || owner.startsWith(session.getUserName() + ",")) {
if (owner.equals(client.getUserName())) {
try {
JDesktopPane desktopPane = (JDesktopPane) MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
@ -199,7 +200,7 @@ public class TablesPanel extends javax.swing.JPanel {
logger.info("Joining tournament " + tableId);
if (deckType.startsWith("Limited")) {
if (!status.endsWith("PW")) {
session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human", 1, null, "");
client.joinTournamentTable(roomId, tableId, client.getUserName(), "Human", 1, null, "");
} else {
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
}
@ -213,24 +214,24 @@ public class TablesPanel extends javax.swing.JPanel {
break;
case "Remove":
if (JOptionPane.showConfirmDialog(null, "Are you sure you want to remove table?", "Removing table", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
session.removeTable(roomId, tableId);
client.removeTable(roomId, tableId);
}
break;
case "Show":
if (isTournament) {
logger.info("Showing tournament table " + tableId);
session.watchTable(roomId, tableId);
client.watchTable(roomId, tableId);
}
break;
case "Watch":
if (!isTournament) {
logger.info("Watching table " + tableId);
session.watchTable(roomId, tableId);
client.watchTable(roomId, tableId);
}
break;
case "Replay":
logger.info("Replaying game " + gameId);
session.replayGame(gameId);
client.replayGame(gameId);
break;
}
}
@ -249,7 +250,7 @@ public class TablesPanel extends javax.swing.JPanel {
List<UUID> gameList = matchesModel.getListofGames(modelRow);
if (gameList != null && gameList.size() > 0) {
if (gameList.size() == 1) {
session.replayGame(gameList.get(0));
client.replayGame(gameList.get(0));
}
else {
gameChooser.show(gameList, MageFrame.getDesktop().getMousePosition());
@ -260,7 +261,7 @@ public class TablesPanel extends javax.swing.JPanel {
case "Show":;
if (matchesModel.isTournament(modelRow)) {
logger.info("Showing tournament table " + matchesModel.getTableId(modelRow));
session.watchTable(roomId, matchesModel.getTableId(modelRow));
client.watchTable(roomId, matchesModel.getTableId(modelRow));
}
break;
}
@ -387,18 +388,18 @@ public class TablesPanel extends javax.swing.JPanel {
}
public void startTasks() {
if (session != null) {
if (client != null) {
if (updateTablesTask == null || updateTablesTask.isDone()) {
updateTablesTask = new UpdateTablesTask(session, roomId, this);
updateTablesTask = new UpdateTablesTask(client, roomId, this);
updateTablesTask.execute();
}
if (updatePlayersTask == null || updatePlayersTask.isDone()) {
updatePlayersTask = new UpdatePlayersTask(session, roomId, this.chatPanel);
updatePlayersTask = new UpdatePlayersTask(client, roomId, this.chatPanel);
updatePlayersTask.execute();
}
if (this.btnStateFinished.isSelected()) {
if (updateMatchesTask == null || updateMatchesTask.isDone()) {
updateMatchesTask = new UpdateMatchesTask(session, roomId, this);
updateMatchesTask = new UpdateMatchesTask(client, roomId, this);
updateMatchesTask.execute();
}
}
@ -424,12 +425,12 @@ public class TablesPanel extends javax.swing.JPanel {
public void showTables(UUID roomId) {
this.roomId = roomId;
session = MageFrame.getSession();
client = MageFrame.getClient();
UUID chatRoomId = null;
if (session != null) {
btnQuickStart.setVisible(session.isTestMode());
gameChooser.init(session);
chatRoomId = session.getRoomChatId(roomId);
if (client != null) {
btnQuickStart.setVisible(client.getServerState().isTestMode());
gameChooser.init(client);
chatRoomId = client.getRoomChatId(roomId);
}
if (newTableDialog == null) {
newTableDialog = new NewTableDialog();
@ -451,7 +452,7 @@ public class TablesPanel extends javax.swing.JPanel {
} else {
hideTables();
}
tableModel.setSession(session);
tableModel.setClient(client);
reloadMessages();
@ -469,7 +470,7 @@ public class TablesPanel extends javax.swing.JPanel {
protected void reloadMessages() {
// reload server messages
List<String> serverMessages = session.getServerMessages();
List<String> serverMessages = client.getServerMessages();
synchronized (this) {
this.messages = serverMessages;
this.currentMessage = 0;
@ -1156,11 +1157,11 @@ public class TablesPanel extends javax.swing.JPanel {
options.setWinsNeeded(1);
options.setMatchTimeLimit(MatchTimeLimit.NONE);
options.setFreeMulligans(2);
table = session.createTable(roomId, options);
table = client.createTable(roomId, options);
session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"),"");
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"),"");
session.startMatch(roomId, table.getTableId());
client.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"),"");
client.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"),"");
client.startMatch(roomId, table.getTableId());
} catch (HeadlessException ex) {
handleError(ex);
}
@ -1266,7 +1267,7 @@ class TableTableModel extends AbstractTableModel {
private TableView[] tables = new TableView[0];
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");;
private Session session;
private Client client;
public void loadData(Collection<TableView> tables) throws MageRemoteException {
this.tables = tables.toArray(new TableView[0]);
@ -1308,8 +1309,8 @@ class TableTableModel extends AbstractTableModel {
return columnNames.length;
}
public void setSession(Session session) {
this.session = session;
public void setClient(Client client) {
this.client = client;
}
@Override
@ -1336,7 +1337,7 @@ class TableTableModel extends AbstractTableModel {
case WAITING:
String owner = tables[arg0].getControllerName();
if (session != null && owner.equals(session.getUserName())) {
if (client != null && owner.equals(client.getUserName())) {
return "";
}
return "Join";
@ -1350,7 +1351,7 @@ class TableTableModel extends AbstractTableModel {
return "Show";
} else {
owner = tables[arg0].getControllerName();
if (session != null && owner.equals(session.getUserName())) {
if (client != null && owner.equals(client.getUserName())) {
return "";
}
return "Watch";
@ -1403,7 +1404,7 @@ class TableTableModel extends AbstractTableModel {
class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
private final Session session;
private final Client client;
private final UUID roomId;
private final TablesPanel panel;
@ -1411,8 +1412,8 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
private int count = 0;
UpdateTablesTask(Session session, UUID roomId, TablesPanel panel) {
this.session = session;
UpdateTablesTask(Client client, UUID roomId, TablesPanel panel) {
this.client = client;
this.roomId = roomId;
this.panel = panel;
}
@ -1420,7 +1421,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
@Override
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
Collection<TableView> tables = session.getTables(roomId);
Collection<TableView> tables = client.getTables(roomId);
if (tables != null) {
this.publish(tables);
}
@ -1452,14 +1453,14 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
private final Session session;
private final Client client;
private final UUID roomId;
private final ChatPanel chat;
private static final Logger logger = Logger.getLogger(UpdatePlayersTask.class);
UpdatePlayersTask(Session session, UUID roomId, ChatPanel chat) {
this.session = session;
UpdatePlayersTask(Client client, UUID roomId, ChatPanel chat) {
this.client = client;
this.roomId = roomId;
this.chat = chat;
}
@ -1467,7 +1468,7 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
@Override
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
this.publish(session.getRoomUsers(roomId));
this.publish(client.getRoomUsers(roomId));
Thread.sleep(3000);
}
return null;
@ -1593,14 +1594,14 @@ class MatchesTableModel extends AbstractTableModel {
class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
private final Session session;
private final Client client;
private final UUID roomId;
private final TablesPanel panel;
private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);
UpdateMatchesTask(Session session, UUID roomId, TablesPanel panel) {
this.session = session;
UpdateMatchesTask(Client client, UUID roomId, TablesPanel panel) {
this.client = client;
this.roomId = roomId;
this.panel = panel;
}
@ -1608,7 +1609,7 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
@Override
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
Collection<MatchView> matches = session.getFinishedMatches(roomId);
Collection<MatchView> matches = client.getFinishedMatches(roomId);
if (matches != null) {
this.publish(matches);
}
@ -1635,10 +1636,10 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
class GameChooser extends JPopupMenu {
private Session session;
private Client client;
public void init(Session session) {
this.session = session;
public void init(Client client) {
this.client = client;
}
public void show(List<UUID> games, Point p) {
@ -1664,7 +1665,7 @@ class GameChooser extends JPopupMenu {
@Override
public void actionPerformed(ActionEvent e) {
session.replayGame(id);
client.replayGame(id);
setVisible(false);
}

View file

@ -40,7 +40,8 @@ import javax.swing.JComboBox;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.remote.Session;
import org.mage.network.Client;
//import mage.remote.Session;
/**
*
@ -48,7 +49,7 @@ import mage.remote.Session;
*/
public class TournamentPlayerPanel extends javax.swing.JPanel {
private Session session;
private Client client;
/** Creates new form TournamentPlayerPanel */
public TournamentPlayerPanel() {
@ -57,8 +58,8 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
}
public void init(int playerNum) {
session = MageFrame.getSession();
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
client = MageFrame.getClient();
cbPlayerType.setModel(new DefaultComboBoxModel(client.getServerState().getPlayerTypes()));
this.lblPlayerNum.setText("Player " + playerNum);
}
@ -68,7 +69,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
public boolean joinTournamentTable(UUID roomId, UUID tableId, DeckCardLists deckCardLists) {
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
return session.joinTournamentTable(
return client.joinTournamentTable(
roomId,
tableId,
this.txtPlayerName.getText(),

View file

@ -53,12 +53,13 @@ import mage.client.chat.ChatPanel;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.ButtonColumn;
import mage.client.util.Format;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.RoundView;
import mage.view.TournamentGameView;
import mage.view.TournamentPlayerView;
import mage.view.TournamentView;
import org.apache.log4j.Logger;
import org.mage.network.Client;
/**
*
@ -70,7 +71,7 @@ public class TournamentPanel extends javax.swing.JPanel {
private UUID tournamentId;
private boolean firstInitDone = false;
private Session session;
private Client client;
private final TournamentPlayersTableModel playersModel;
private TournamentMatchesTableModel matchesModel;
private UpdateTournamentTask updateTask;
@ -112,7 +113,7 @@ public class TournamentPanel extends javax.swing.JPanel {
// }
if (state.startsWith("Dueling") && actionText.equals("Watch")) {
logger.info("Watching game " + gameId);
session.watchTournamentTable(tableId);
client.watchTournamentTable(tableId);
}
}
};
@ -159,10 +160,10 @@ public class TournamentPanel extends javax.swing.JPanel {
public synchronized void showTournament(UUID tournamentId) {
this.tournamentId = tournamentId;
session = MageFrame.getSession();
client = MageFrame.getClient();
// MageFrame.addTournament(tournamentId, this);
UUID chatRoomId = session.getTournamentChatId(tournamentId);
if (session.joinTournament(tournamentId) && chatRoomId != null) {
UUID chatRoomId = client.getTournamentChatId(tournamentId);
if (client.joinTournament(tournamentId) && chatRoomId != null) {
this.chatPanel1.connect(chatRoomId);
startTasks();
this.setVisible(true);
@ -248,7 +249,7 @@ public class TournamentPanel extends javax.swing.JPanel {
btnQuitTournament.setVisible(false);
if (tournament.getEndTime() == null) {
for (TournamentPlayerView player : tournament.getPlayers()) {
if (player.getName().equals(session.getUserName())) {
if (player.getName().equals(client.getUserName())) {
if (!player.hasQuit()) {
btnQuitTournament.setVisible(true);
}
@ -260,9 +261,9 @@ public class TournamentPanel extends javax.swing.JPanel {
}
public void startTasks() {
if (session != null) {
if (client != null) {
if (updateTask == null || updateTask.isDone()) {
updateTask = new UpdateTournamentTask(session, tournamentId, this);
updateTask = new UpdateTournamentTask(client, tournamentId, this);
updateTask.execute();
}
}
@ -496,7 +497,7 @@ public class TournamentPanel extends javax.swing.JPanel {
private void btnQuitTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitTournamentActionPerformed
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to quit the tournament?", "Confirm quit tournament", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().quitTournament(tournamentId);
MageFrame.getClient().quitTournament(tournamentId);
}
}//GEN-LAST:event_btnQuitTournamentActionPerformed
@ -673,14 +674,14 @@ class TournamentMatchesTableModel extends AbstractTableModel {
class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
private final Session session;
private final Client client;
private final UUID tournamentId;
private final TournamentPanel panel;
private static final Logger logger = Logger.getLogger(UpdateTournamentTask.class);
UpdateTournamentTask(Session session, UUID tournamentId, TournamentPanel panel) {
this.session = session;
UpdateTournamentTask(Client client, UUID tournamentId, TournamentPanel panel) {
this.client = client;
this.tournamentId = tournamentId;
this.panel = panel;
}
@ -688,7 +689,7 @@ class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
@Override
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
this.publish(session.getTournament(tournamentId));
this.publish(client.getTournament(tournamentId));
Thread.sleep(2000);
}
return null;

View file

@ -41,8 +41,9 @@ import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.dialog.ShowCardsDialog;
import mage.client.util.Config;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.PlayerView;
import org.mage.network.Client;
/**
*
@ -52,7 +53,7 @@ public class PlayerPanel extends javax.swing.JPanel {
private UUID playerId;
private UUID gameId;
private Session session;
private Client client;
private PlayerView player;
private ShowCardsDialog graveyard;
@ -67,7 +68,7 @@ public class PlayerPanel extends javax.swing.JPanel {
this.gameId = gameId;
this.playerId = playerId;
this.bigCard = bigCard;
session = MageFrame.getSession();
client = MageFrame.getClient();
}
public void update(PlayerView player) {
@ -194,7 +195,7 @@ public class PlayerPanel extends javax.swing.JPanel {
}// </editor-fold>//GEN-END:initComponents
private void btnPlayerNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerNameActionPerformed
session.sendPlayerUUID(gameId, playerId);
client.sendPlayerUUID(gameId, playerId);
}//GEN-LAST:event_btnPlayerNameActionPerformed
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed

View file

@ -3,8 +3,9 @@ package mage.client.util;
import java.awt.event.MouseEvent;
import java.util.UUID;
import mage.remote.Session;
//import mage.remote.Session;
import mage.view.CardView;
import org.mage.network.Client;
public class DefaultActionCallback {
@ -17,12 +18,12 @@ public class DefaultActionCallback {
return INSTANCE;
}
public void mouseClicked(MouseEvent e, UUID gameId, Session session, CardView card) {
public void mouseClicked(MouseEvent e, UUID gameId, Client client, CardView card) {
if (gameId != null) {
if (card.isAbility() && card.getAbility() != null) {
session.sendPlayerUUID(gameId, card.getAbility().getId());
client.sendPlayerUUID(gameId, card.getAbility().getId());
} else {
session.sendPlayerUUID(gameId, card.getId());
client.sendPlayerUUID(gameId, card.getId());
}
}
}

View file

@ -1,17 +1,23 @@
package mage.client.game;
import java.util.UUID;
import mage.client.components.MageUI;
import mage.interfaces.MageClient;
import mage.interfaces.callback.ClientCallback;
//import mage.interfaces.MageClient;
//import mage.interfaces.callback.ClientCallback;
import mage.remote.Connection;
import mage.remote.Session;
import mage.remote.SessionImpl;
//import mage.remote.Session;
//import mage.remote.SessionImpl;
import mage.utils.MageVersion;
import org.apache.log4j.Logger;
import org.junit.Ignore;
import javax.swing.*;
import java.util.concurrent.CountDownLatch;
import mage.interfaces.ServerState;
import mage.view.ChatMessage;
import org.mage.network.Client;
import org.mage.network.interfaces.MageClient;
import org.mage.network.model.MessageType;
/**
* Test for emulating the connection from multi mage clients.
@ -39,25 +45,25 @@ public class MultiConnectTest {
private class ClientMock implements MageClient {
private Session session;
private Client client;
private final String username;
private ServerState serverState;
public ClientMock(String username) {
this.username = username;
}
public void connect() {
session = new SessionImpl(this);
client = new Client(this);
Connection connection = new Connection();
connection.setUsername(username);
connection.setHost("localhost");
connection.setPort(17171);
connection.setProxyType(Connection.ProxyType.NONE);
session.connect(connection);
client.connect(username, "localhost", 17171, version);
}
@Override
public MageVersion getVersion() {
logger.info("getVersion");
return version;
@ -69,24 +75,51 @@ public class MultiConnectTest {
connected++;
}
@Override
public void disconnected(boolean errorCall) {
logger.info("disconnected");
}
@Override
public void showMessage(String message) {
logger.info("showMessage: " + message);
}
@Override
public void showError(String message) {
logger.info("showError: " + message);
}
// @Override
// public void processCallback(ClientCallback callback) {
// logger.info("processCallback");
// }
@Override
public void processCallback(ClientCallback callback) {
logger.info("processCallback");
public void inform(String message, MessageType type) {
if (type == MessageType.ERROR) {
showError(message);
}
else {
showMessage(message);
}
}
@Override
public void receiveChatMessage(UUID chatId, ChatMessage message) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void receiveBroadcastMessage(String message) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void clientRegistered(ServerState state) {
this.serverState = state;
}
@Override
public ServerState getServerState() {
return serverState;
}
}