mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 04:22:01 -08:00
remove stored references to Client - retrieve from MageFrame instead
This commit is contained in:
parent
15480ee8d6
commit
b9df27c292
19 changed files with 132 additions and 232 deletions
|
|
@ -91,7 +91,6 @@ import mage.view.CardView;
|
|||
import mage.view.CounterView;
|
||||
import mage.view.PermanentView;
|
||||
import mage.view.StackAbilityView;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -100,7 +99,6 @@ import org.mage.network.Client;
|
|||
@SuppressWarnings("serial")
|
||||
public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener {
|
||||
|
||||
protected static Client client = MageFrame.getClient();
|
||||
protected static DefaultActionCallback callback = DefaultActionCallback.getInstance();
|
||||
|
||||
protected Point p;
|
||||
|
|
@ -383,7 +381,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
requestFocusInWindow();
|
||||
callback.mouseClicked(e, gameId, client, card);
|
||||
callback.mouseClicked(e, gameId, MageFrame.getClient(), card);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ package mage.client.chat;
|
|||
import java.awt.Color;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.swing.Icon;
|
||||
|
|
@ -58,7 +57,6 @@ import mage.view.ChatMessage.MessageType;
|
|||
import mage.view.RoomUsersView;
|
||||
import mage.view.UsersView;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -67,7 +65,6 @@ import org.mage.network.Client;
|
|||
public class ChatPanel extends javax.swing.JPanel {
|
||||
|
||||
private UUID chatId;
|
||||
private Client client;
|
||||
private final List<String> players = new ArrayList<>();
|
||||
private final UserTableModel userTableModel;
|
||||
/**
|
||||
|
|
@ -192,15 +189,14 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void connect(UUID chatId) {
|
||||
client = MageFrame.getClient();
|
||||
this.chatId = chatId;
|
||||
client.joinChat(chatId);
|
||||
MageFrame.getClient().joinChat(chatId);
|
||||
MageFrame.addChat(chatId, this);
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (client != null) {
|
||||
client.leaveChat(chatId);
|
||||
if (MageFrame.getClient() != null) {
|
||||
MageFrame.getClient().leaveChat(chatId);
|
||||
MageFrame.removeChat(chatId);
|
||||
}
|
||||
}
|
||||
|
|
@ -259,11 +255,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
userColor = USER_INFO_COLOR;
|
||||
break;
|
||||
default:
|
||||
if (parentChatRef != null) {
|
||||
userColor = parentChatRef.client.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||
} else {
|
||||
userColor = client.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||
}
|
||||
userColor = MageFrame.getClient().getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||
textColor = MESSAGE_COLOR;
|
||||
userSeparator = ": ";
|
||||
}
|
||||
|
|
@ -550,9 +542,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.client.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
|
||||
MageFrame.getClient().sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
|
||||
} else {
|
||||
client.sendChatMessage(chatId, this.txtMessage.getText());
|
||||
MageFrame.getClient().sendChatMessage(chatId, this.txtMessage.getText());
|
||||
}
|
||||
this.txtMessage.setText("");
|
||||
this.txtMessage.repaint();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import java.awt.*;
|
|||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import org.mage.network.Client;
|
||||
import mage.client.MageFrame;
|
||||
|
||||
/**
|
||||
* Dialog for choosing abilities.
|
||||
|
|
@ -35,7 +35,6 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
private List<Object> choices;
|
||||
private String message = DEFAULT_MESSAGE;
|
||||
|
||||
private Client client;
|
||||
private UUID gameId;
|
||||
|
||||
private BackgroundPainter mwPanelPainter;
|
||||
|
|
@ -78,8 +77,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
||||
}
|
||||
|
||||
public void init(Client client, UUID gameId) {
|
||||
this.client = client;
|
||||
public void init(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
|
|
@ -449,7 +447,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
if (id == null) {
|
||||
cancel();
|
||||
} else {
|
||||
client.sendPlayerUUID(gameId, id);
|
||||
MageFrame.getClient().sendPlayerUUID(gameId, id);
|
||||
}
|
||||
setVisible(false);
|
||||
AbilityPicker.this.selected = true;
|
||||
|
|
@ -464,7 +462,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
|
||||
private void cancel() {
|
||||
try {
|
||||
client.sendPlayerBoolean(gameId, false);
|
||||
MageFrame.getClient().sendPlayerBoolean(gameId, false);
|
||||
} catch (Exception e) {
|
||||
log.error("Couldn't cancel choose dialog: " + e, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import javax.swing.JOptionPane;
|
|||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.client.MageFrame;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -146,13 +145,12 @@ public class JoinTableDialog extends MageDialog {
|
|||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||
Client client = MageFrame.getClient();
|
||||
try {
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText());
|
||||
if (isTournament) {
|
||||
joined = client.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
|
||||
joined = MageFrame.getClient().joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
|
||||
} else {
|
||||
joined = client.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
|
||||
joined = MageFrame.getClient().joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ import mage.game.match.MatchOptions;
|
|||
import mage.view.GameTypeView;
|
||||
import mage.view.TableView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -64,7 +63,6 @@ public class NewTableDialog extends MageDialog {
|
|||
private TableView table;
|
||||
private UUID playerId;
|
||||
private UUID roomId;
|
||||
private final Client client;
|
||||
private String lastSessionId;
|
||||
private final List<TablePlayerPanel> players = new ArrayList<>();
|
||||
private final List<String> prefPlayerTypes = new ArrayList<>();
|
||||
|
|
@ -73,7 +71,6 @@ public class NewTableDialog extends MageDialog {
|
|||
|
||||
/** Creates new form NewTableDialog */
|
||||
public NewTableDialog() {
|
||||
client = MageFrame.getClient();
|
||||
lastSessionId = "";
|
||||
initComponents();
|
||||
player1Panel.showLevel(false);
|
||||
|
|
@ -379,13 +376,13 @@ public class NewTableDialog extends MageDialog {
|
|||
}
|
||||
saveGameSettingsToPrefs(options, this.player1Panel.getDeckFile());
|
||||
|
||||
table = client.createTable(roomId, options);
|
||||
table = MageFrame.getClient().createTable(roomId, options);
|
||||
if (table == null) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (client.joinTable(
|
||||
if (MageFrame.getClient().joinTable(
|
||||
roomId,
|
||||
table.getTableId(),
|
||||
this.player1Panel.getPlayerName(),
|
||||
|
|
@ -397,7 +394,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
|
||||
client.removeTable(roomId, table.getTableId());
|
||||
MageFrame.getClient().removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
}
|
||||
|
|
@ -414,7 +411,7 @@ public class NewTableDialog extends MageDialog {
|
|||
handleError(ex);
|
||||
}
|
||||
// JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
client.removeTable(roomId, table.getTableId());
|
||||
MageFrame.getClient().removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
}//GEN-LAST:event_btnOKActionPerformed
|
||||
|
||||
|
|
@ -533,10 +530,10 @@ public class NewTableDialog extends MageDialog {
|
|||
public void showDialog(UUID roomId) {
|
||||
this.roomId = roomId;
|
||||
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()));
|
||||
lastSessionId = MageFrame.getClient().getSessionId();
|
||||
this.player1Panel.setPlayerName(MageFrame.getClient().getUserName());
|
||||
cbGameType.setModel(new DefaultComboBoxModel(MageFrame.getClient().getServerState().getGameTypes().toArray()));
|
||||
cbDeckType.setModel(new DefaultComboBoxModel(MageFrame.getClient().getServerState().getDeckTypes()));
|
||||
selectLimitedByDefault();
|
||||
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
||||
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
|
||||
|
|
@ -587,7 +584,7 @@ public class NewTableDialog extends MageDialog {
|
|||
|
||||
|
||||
String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, "Two Player Duel");
|
||||
for (GameTypeView gtv : client.getServerState().getGameTypes()) {
|
||||
for (GameTypeView gtv : MageFrame.getClient().getServerState().getGameTypes()) {
|
||||
if (gtv.getName().equals(gameTypeName)) {
|
||||
cbGameType.setSelectedItem(gtv);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ import mage.view.GameTypeView;
|
|||
import mage.view.TableView;
|
||||
import mage.view.TournamentTypeView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.network.Client;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -78,7 +77,6 @@ public class NewTournamentDialog extends MageDialog {
|
|||
private TableView table;
|
||||
private UUID playerId;
|
||||
private UUID roomId;
|
||||
private final Client client;
|
||||
private String lastSessionId;
|
||||
private RandomPacksSelectorDialog randomPackSelector;
|
||||
private JTextArea txtRandomPacks;
|
||||
|
|
@ -92,7 +90,6 @@ public class NewTournamentDialog extends MageDialog {
|
|||
/** Creates new form NewTournamentDialog */
|
||||
public NewTournamentDialog() {
|
||||
initComponents();
|
||||
client = MageFrame.getClient();
|
||||
lastSessionId = "";
|
||||
txtName.setText("Tournament");
|
||||
this.spnNumWins.setModel(new SpinnerNumberModel(2, 1, 5, 1));
|
||||
|
|
@ -104,17 +101,17 @@ public class NewTournamentDialog extends MageDialog {
|
|||
public void showDialog(UUID roomId) {
|
||||
this.roomId = roomId;
|
||||
if (!lastSessionId.equals(MageFrame.getClient().getSessionId())) {
|
||||
lastSessionId = client.getSessionId();
|
||||
this.player1Panel.setPlayerName(client.getUserName());
|
||||
lastSessionId = MageFrame.getClient().getSessionId();
|
||||
this.player1Panel.setPlayerName(MageFrame.getClient().getUserName());
|
||||
this.player1Panel.showLevel(false); // no computer
|
||||
cbTournamentType.setModel(new DefaultComboBoxModel(client.getServerState().getTournamentTypes().toArray()));
|
||||
cbTournamentType.setModel(new DefaultComboBoxModel(MageFrame.getClient().getServerState().getTournamentTypes().toArray()));
|
||||
|
||||
cbGameType.setModel(new DefaultComboBoxModel(client.getServerState().getTournamentGameTypes().toArray()));
|
||||
cbDeckType.setModel(new DefaultComboBoxModel(client.getServerState().getDeckTypes()));
|
||||
cbGameType.setModel(new DefaultComboBoxModel(MageFrame.getClient().getServerState().getTournamentGameTypes().toArray()));
|
||||
cbDeckType.setModel(new DefaultComboBoxModel(MageFrame.getClient().getServerState().getDeckTypes()));
|
||||
|
||||
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
||||
cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values()));
|
||||
cbDraftCube.setModel(new DefaultComboBoxModel(client.getServerState().getDraftCubes()));
|
||||
cbDraftCube.setModel(new DefaultComboBoxModel(MageFrame.getClient().getServerState().getDraftCubes()));
|
||||
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
|
||||
// update player types
|
||||
int i=2;
|
||||
|
|
@ -574,12 +571,12 @@ public class NewTournamentDialog extends MageDialog {
|
|||
tOptions.getMatchOptions().setRollbackTurnsAllowed(this.chkRollbackTurnsAllowed.isSelected());
|
||||
saveTournamentSettingsToPrefs(tOptions);
|
||||
|
||||
table = client.createTournamentTable(roomId, tOptions);
|
||||
table = MageFrame.getClient().createTournamentTable(roomId, tOptions);
|
||||
if (table == null) {
|
||||
// message must be send by server!
|
||||
return;
|
||||
}
|
||||
if (client.joinTournamentTable(
|
||||
if (MageFrame.getClient().joinTournamentTable(
|
||||
roomId,
|
||||
table.getTableId(),
|
||||
this.player1Panel.getPlayerName(),
|
||||
|
|
@ -590,7 +587,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
|
||||
client.removeTable(roomId, table.getTableId());
|
||||
MageFrame.getClient().removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
}
|
||||
|
|
@ -600,7 +597,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
return;
|
||||
}
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
client.removeTable(roomId, table.getTableId());
|
||||
MageFrame.getClient().removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
|
||||
|
|
@ -906,7 +903,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
}
|
||||
this.spnConstructTime.setValue(constructionTime);
|
||||
String tournamentTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, "Sealed Elimination");
|
||||
for (TournamentTypeView tournamentTypeView : client.getServerState().getTournamentTypes()) {
|
||||
for (TournamentTypeView tournamentTypeView : MageFrame.getClient().getServerState().getTournamentTypes()) {
|
||||
if (tournamentTypeView.getName().equals(tournamentTypeName)) {
|
||||
cbTournamentType.setSelectedItem(tournamentTypeView);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ public class TableWaitingDialog extends MageDialog {
|
|||
private UUID tableId;
|
||||
private UUID roomId;
|
||||
private boolean isTournament;
|
||||
private Client client;
|
||||
private final TableWaitModel tableWaitModel;
|
||||
private UpdateSeatsTask updateTask;
|
||||
private static final int[] defaultColumnsWidth = {20, 50, 100, 100};
|
||||
|
|
@ -75,7 +74,6 @@ public class TableWaitingDialog extends MageDialog {
|
|||
*/
|
||||
public TableWaitingDialog() {
|
||||
|
||||
client = MageFrame.getClient();
|
||||
tableWaitModel = new TableWaitModel();
|
||||
|
||||
initComponents();
|
||||
|
|
@ -132,8 +130,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.isTournament = isTournament;
|
||||
client = MageFrame.getClient();
|
||||
updateTask = new UpdateSeatsTask(client, roomId, tableId, this);
|
||||
updateTask = new UpdateSeatsTask(MageFrame.getClient(), roomId, tableId, this);
|
||||
if (owner) {
|
||||
this.btnStart.setVisible(true);
|
||||
this.btnMoveDown.setVisible(true);
|
||||
|
|
@ -263,11 +260,11 @@ public class TableWaitingDialog extends MageDialog {
|
|||
|
||||
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
|
||||
if (!isTournament) {
|
||||
if (client.startMatch(roomId, tableId)) {
|
||||
if (MageFrame.getClient().startMatch(roomId, tableId)) {
|
||||
closeDialog();
|
||||
}
|
||||
} else {
|
||||
if (client.startTournament(roomId, tableId)) {
|
||||
if (MageFrame.getClient().startTournament(roomId, tableId)) {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
|
@ -275,7 +272,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
try {
|
||||
if (!client.leaveTable(roomId, tableId)) {
|
||||
if (!MageFrame.getClient().leaveTable(roomId, tableId)) {
|
||||
return; // already started, so leave no more possible
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -288,7 +285,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) {
|
||||
client.swapSeats(roomId, tableId, row, row + 1);
|
||||
MageFrame.getClient().swapSeats(roomId, tableId, row, row + 1);
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row + 1, row + 1);
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +294,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) {
|
||||
client.swapSeats(roomId, tableId, row, row - 1);
|
||||
MageFrame.getClient().swapSeats(roomId, tableId, row, row - 1);
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row - 1, row - 1);
|
||||
}
|
||||
}//GEN-LAST:event_btnMoveUpActionPerformed
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ package mage.client.dialog;
|
|||
import mage.client.MageFrame;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.view.UserRequestMessage;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -176,9 +175,8 @@ public class UserRequestDialog extends MageDialog {
|
|||
}//GEN-LAST:event_btn3ActionPerformed
|
||||
|
||||
private void sendUserReplay(PlayerAction playerAction) {
|
||||
Client client = MageFrame.getClient();
|
||||
if (client != null && playerAction != null) {
|
||||
client.sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
|
||||
if (MageFrame.getClient() != null && playerAction != null) {
|
||||
MageFrame.getClient().sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ import mage.view.DraftPickView;
|
|||
import mage.view.DraftView;
|
||||
import mage.view.SimpleCardView;
|
||||
import mage.view.SimpleCardsView;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -90,7 +89,6 @@ import org.mage.network.Client;
|
|||
public class DraftPanel extends javax.swing.JPanel {
|
||||
|
||||
private UUID draftId;
|
||||
private Client client;
|
||||
private Timer countdown;
|
||||
private int timeout;
|
||||
|
||||
|
|
@ -171,9 +169,8 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
|
||||
public synchronized void showDraft(UUID draftId) {
|
||||
this.draftId = draftId;
|
||||
client = MageFrame.getClient();
|
||||
MageFrame.addDraft(draftId, this);
|
||||
if (!client.joinDraft(draftId)) {
|
||||
if (!MageFrame.getClient().joinDraft(draftId)) {
|
||||
hideDraft();
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +319,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
public void event(Event event) {
|
||||
SimpleCardView source = (SimpleCardView) event.getSource();
|
||||
if (event.getEventName().equals("pick-a-card")) {
|
||||
DraftPickView view = client.pickCard(draftId, source.getId(), cardsHidden);
|
||||
DraftPickView view = MageFrame.getClient().pickCard(draftId, source.getId(), cardsHidden);
|
||||
if (view != null) {
|
||||
loadCardsToPickedCardsArea(view.getPicks());
|
||||
draftBooster.loadBooster(emptyView, bigCard);
|
||||
|
|
@ -331,7 +328,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
if (event.getEventName().equals("mark-a-card")) {
|
||||
client.markCard(draftId, source.getId());
|
||||
MageFrame.getClient().markCard(draftId, source.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ import mage.client.util.gui.ArrowBuilder;
|
|||
import mage.constants.Constants;
|
||||
import mage.constants.PlayerAction;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -66,7 +65,6 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private UUID gameId;
|
||||
private Client client;
|
||||
private FeedbackMode mode;
|
||||
private MageDialog connectedDialog;
|
||||
private ChatPanel connectedChatPanel;
|
||||
|
|
@ -84,7 +82,6 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
|
||||
public void init(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
client = MageFrame.getClient();
|
||||
}
|
||||
|
||||
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options) {
|
||||
|
|
@ -273,29 +270,29 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
connectedDialog = null;
|
||||
}
|
||||
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
||||
client.sendPlayerInteger(gameId, 0);
|
||||
MageFrame.getClient().sendPlayerInteger(gameId, 0);
|
||||
} else if (mode == FeedbackMode.END) {
|
||||
GamePanel gamePanel = MageFrame.getGame(gameId);
|
||||
if (gamePanel != null) {
|
||||
gamePanel.removeGame();
|
||||
}
|
||||
} else {
|
||||
client.sendPlayerBoolean(gameId, false);
|
||||
MageFrame.getClient().sendPlayerBoolean(gameId, false);
|
||||
}
|
||||
//AudioManager.playButtonOk();
|
||||
}//GEN-LAST:event_btnRightActionPerformed
|
||||
|
||||
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
||||
client.sendPlayerBoolean(gameId, true);
|
||||
MageFrame.getClient().sendPlayerBoolean(gameId, true);
|
||||
AudioManager.playButtonCancel();
|
||||
}//GEN-LAST:event_btnLeftActionPerformed
|
||||
|
||||
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
|
||||
client.sendPlayerString(gameId, "special");
|
||||
MageFrame.getClient().sendPlayerString(gameId, "special");
|
||||
}//GEN-LAST:event_btnSpecialActionPerformed
|
||||
|
||||
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
client.sendPlayerAction(PlayerAction.UNDO, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.UNDO, gameId, null);
|
||||
}
|
||||
|
||||
public void setHelperPanel(HelperPanel helper) {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ 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 Client client;
|
||||
GamePane gamePane;
|
||||
private ReplayTask replayTask;
|
||||
private final PickNumberDialog pickNumber;
|
||||
|
|
@ -401,11 +400,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.gameId = gameId;
|
||||
this.gamePane = gamePane;
|
||||
this.playerId = playerId;
|
||||
client = MageFrame.getClient();
|
||||
MageFrame.addGame(gameId, this);
|
||||
this.feedbackPanel.init(gameId);
|
||||
this.feedbackPanel.clear();
|
||||
this.abilityPicker.init(client, gameId);
|
||||
this.abilityPicker.init(gameId);
|
||||
|
||||
this.btnConcede.setVisible(true);
|
||||
this.btnStopWatching.setVisible(false);
|
||||
|
|
@ -421,7 +419,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.pnlReplay.setVisible(false);
|
||||
|
||||
this.gameChatPanel.clear();
|
||||
UUID chatId = client.joinGame(gameId);
|
||||
UUID chatId = MageFrame.getClient().joinGame(gameId);
|
||||
if (chatId == null) {
|
||||
removeGame();
|
||||
} else {
|
||||
|
|
@ -435,7 +433,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.gameId = gameId;
|
||||
this.gamePane = gamePane;
|
||||
this.playerId = null;
|
||||
client = MageFrame.getClient();
|
||||
MageFrame.addGame(gameId, this);
|
||||
this.feedbackPanel.init(gameId);
|
||||
this.feedbackPanel.clear();
|
||||
|
|
@ -469,7 +466,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
public synchronized void replayGame(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = null;
|
||||
client = MageFrame.getClient();
|
||||
MageFrame.addGame(gameId, this);
|
||||
this.feedbackPanel.init(gameId);
|
||||
this.feedbackPanel.clear();
|
||||
|
|
@ -479,7 +475,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.btnStopWatching.setVisible(false);
|
||||
this.pnlReplay.setVisible(true);
|
||||
this.gameChatPanel.clear();
|
||||
if (!client.startReplay(gameId)) {
|
||||
if (!MageFrame.getClient().startReplay(gameId)) {
|
||||
removeGame();
|
||||
}
|
||||
for (PlayAreaPanel panel : getPlayers().values()) {
|
||||
|
|
@ -1120,9 +1116,9 @@ 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()) {
|
||||
client.sendPlayerBoolean(gameId, false);
|
||||
MageFrame.getClient().sendPlayerBoolean(gameId, false);
|
||||
} else {
|
||||
client.sendPlayerInteger(gameId, pickNumber.getAmount());
|
||||
MageFrame.getClient().sendPlayerInteger(gameId, pickNumber.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1132,12 +1128,12 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
pickChoice.showDialog(choice, choiceWindowState);
|
||||
if (choice.isKeyChoice()) {
|
||||
if (pickChoice.isAutoSelect()) {
|
||||
client.sendPlayerString(gameId, "#" + choice.getChoiceKey());
|
||||
MageFrame.getClient().sendPlayerString(gameId, "#" + choice.getChoiceKey());
|
||||
} else {
|
||||
client.sendPlayerString(gameId, choice.getChoiceKey());
|
||||
MageFrame.getClient().sendPlayerString(gameId, choice.getChoiceKey());
|
||||
}
|
||||
} else {
|
||||
client.sendPlayerString(gameId, choice.getChoice());
|
||||
MageFrame.getClient().sendPlayerString(gameId, choice.getChoice());
|
||||
}
|
||||
choiceWindowState = new MageDialogState(pickChoice);
|
||||
pickChoice.removeDialog();
|
||||
|
|
@ -1147,7 +1143,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
hideAll();
|
||||
PickPileDialog pickPileDialog = new PickPileDialog();
|
||||
pickPileDialog.loadCards(message, pile1, pile2, bigCard, Config.dimensions, gameId);
|
||||
client.sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
|
||||
MageFrame.getClient().sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
|
||||
pickPileDialog.cleanUp();
|
||||
pickPileDialog.removeDialog();
|
||||
}
|
||||
|
|
@ -1865,42 +1861,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) {
|
||||
client.sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
||||
MageFrame.getClient().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) {
|
||||
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||
MageFrame.getClient().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) {
|
||||
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||
MageFrame.getClient().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) {
|
||||
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
||||
MageFrame.getClient().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) {
|
||||
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
|
||||
MageFrame.getClient().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) {
|
||||
client.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||
AudioManager.playOnSkipButtonCancel();
|
||||
updateSkipButtons(false, false, false, false, false);
|
||||
}
|
||||
|
|
@ -1931,7 +1927,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) {
|
||||
client.stopWatching(gameId);
|
||||
MageFrame.getClient().stopWatching(gameId);
|
||||
this.removeGame();
|
||||
}
|
||||
}//GEN-LAST:event_btnStopWatchingActionPerformed
|
||||
|
|
@ -1940,27 +1936,27 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
if (replayTask != null && !replayTask.isDone()) {
|
||||
replayTask.cancel(true);
|
||||
} else if (modalQuestion("Are you sure you want to stop replay?", "Stop replay") == JOptionPane.YES_OPTION) {
|
||||
client.stopReplay(gameId);
|
||||
MageFrame.getClient().stopReplay(gameId);
|
||||
}
|
||||
}//GEN-LAST:event_btnStopReplayActionPerformed
|
||||
|
||||
private void btnNextPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextPlayActionPerformed
|
||||
client.nextPlay(gameId);
|
||||
MageFrame.getClient().nextPlay(gameId);
|
||||
}//GEN-LAST:event_btnNextPlayActionPerformed
|
||||
|
||||
private void btnPreviousPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPreviousPlayActionPerformed
|
||||
client.previousPlay(gameId);
|
||||
MageFrame.getClient().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(client, gameId);
|
||||
replayTask = new ReplayTask(MageFrame.getClient(), gameId);
|
||||
replayTask.execute();
|
||||
}
|
||||
}//GEN-LAST:event_btnPlayActionPerformed
|
||||
|
||||
private void btnSkipForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSkipForwardActionPerformed
|
||||
client.skipForward(gameId, 10);
|
||||
MageFrame.getClient().skipForward(gameId, 10);
|
||||
}//GEN-LAST:event_btnSkipForwardActionPerformed
|
||||
|
||||
public void setJLayeredPane(JLayeredPane jLayeredPane) {
|
||||
|
|
@ -2019,23 +2015,23 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
switch (e.getActionCommand()) {
|
||||
case CMD_AUTO_ORDER_FIRST:
|
||||
client.sendPlayerAction(TRIGGER_AUTO_ORDER_ABILITY_FIRST, gameId, abilityId);
|
||||
MageFrame.getClient().sendPlayerAction(TRIGGER_AUTO_ORDER_ABILITY_FIRST, gameId, abilityId);
|
||||
break;
|
||||
case CMD_AUTO_ORDER_LAST:
|
||||
client.sendPlayerAction(TRIGGER_AUTO_ORDER_ABILITY_LAST, gameId, abilityId);
|
||||
MageFrame.getClient().sendPlayerAction(TRIGGER_AUTO_ORDER_ABILITY_LAST, gameId, abilityId);
|
||||
break;
|
||||
case CMD_AUTO_ORDER_NAME_FIRST:
|
||||
if (abilityRuleText != null) {
|
||||
client.sendPlayerAction(TRIGGER_AUTO_ORDER_NAME_FIRST, gameId, abilityRuleText);
|
||||
MageFrame.getClient().sendPlayerAction(TRIGGER_AUTO_ORDER_NAME_FIRST, gameId, abilityRuleText);
|
||||
}
|
||||
break;
|
||||
case CMD_AUTO_ORDER_NAME_LAST:
|
||||
if (abilityRuleText != null) {
|
||||
client.sendPlayerAction(TRIGGER_AUTO_ORDER_NAME_LAST, gameId, abilityRuleText);
|
||||
MageFrame.getClient().sendPlayerAction(TRIGGER_AUTO_ORDER_NAME_LAST, gameId, abilityRuleText);
|
||||
}
|
||||
break;
|
||||
case CMD_AUTO_ORDER_RESET_ALL:
|
||||
client.sendPlayerAction(TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -2083,10 +2079,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
return gameChatPanel.getText();
|
||||
}
|
||||
|
||||
public Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public Map<String, Card> getLoadedCards() {
|
||||
return loadedCards;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,23 +152,23 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
break;
|
||||
}
|
||||
case "F3": {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
|
||||
break;
|
||||
}
|
||||
case "F4": {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
|
||||
break;
|
||||
}
|
||||
case "F5": {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
|
||||
break;
|
||||
}
|
||||
case "F7": {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
|
||||
break;
|
||||
}
|
||||
case "F9": {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true" : "false");
|
||||
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState());
|
||||
gamePanel.getClient().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true" : "false");
|
||||
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted);
|
||||
gamePanel.getClient().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON: PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON: PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
@ -318,7 +318,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.getClient().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON: PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON: PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -341,7 +341,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int turnsToRollBack = Integer.parseInt(e.getActionCommand());
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.ROLLBACK_TURNS, gameId, turnsToRollBack);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.ROLLBACK_TURNS, gameId, turnsToRollBack);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -448,7 +448,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.getClient().stopWatching(gameId);
|
||||
MageFrame.getClient().stopWatching(gameId);
|
||||
gamePanel.removeGame();
|
||||
}
|
||||
}
|
||||
|
|
@ -461,7 +461,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getClient().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
||||
MageFrame.getClient().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -38,23 +38,13 @@ import java.awt.Dimension;
|
|||
import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.LayoutStyle.ComponentPlacement;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.LineBorder;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.importer.DckDeckImporter;
|
||||
import mage.client.MageFrame;
|
||||
|
|
@ -75,20 +65,16 @@ import mage.view.ManaPoolView;
|
|||
import mage.view.PlayerView;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import javax.swing.LayoutStyle.ComponentPlacement;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.LineBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
* Enhanced player pane.
|
||||
|
|
@ -99,7 +85,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
private Client client;
|
||||
private PlayerView player;
|
||||
|
||||
private BigCard bigCard;
|
||||
|
|
@ -134,8 +119,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
this.bigCard = bigCard;
|
||||
client = MageFrame.getClient();
|
||||
cheat.setVisible(client.getServerState().isTestMode());
|
||||
cheat.setVisible(MageFrame.getClient().getServerState().isTestMode());
|
||||
cheat.setFocusable(false);
|
||||
flagName = null;
|
||||
if (priorityTime > 0) {
|
||||
|
|
@ -357,7 +341,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
avatar.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
client.sendPlayerUUID(gameId, playerId);
|
||||
MageFrame.getClient().sendPlayerUUID(gameId, playerId);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -485,7 +469,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
btnPlayer.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
client.sendPlayerUUID(gameId, playerId);
|
||||
MageFrame.getClient().sendPlayerUUID(gameId, playerId);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -801,7 +785,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private void btnManaActionPerformed(ManaType manaType) {
|
||||
client.sendPlayerManaType(gameId, player.getPlayerId(), manaType);
|
||||
MageFrame.getClient().sendPlayerManaType(gameId, player.getPlayerId(), manaType);
|
||||
}
|
||||
|
||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
|
@ -822,7 +806,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
|
||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
|
||||
DckDeckImporter deckImporter = new DckDeckImporter();
|
||||
client.cheat(gameId, playerId, deckImporter.importDeck("cheat.dck"));
|
||||
MageFrame.getClient().cheat(gameId, playerId, deckImporter.importDeck("cheat.dck"));
|
||||
}
|
||||
|
||||
public PlayerView getPlayer() {
|
||||
|
|
|
|||
|
|
@ -3,20 +3,12 @@ package mage.client.plugins.adapters;
|
|||
import java.awt.Component;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
|
@ -46,18 +38,14 @@ import org.jdesktop.swingx.JXPanel;
|
|||
import org.mage.card.arcane.CardPanel;
|
||||
import org.mage.plugins.card.images.ImageCache;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
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
|
||||
|
|
@ -81,7 +69,6 @@ public class MageActionCallback implements ActionCallback {
|
|||
private JPopupMenu jPopupMenu;
|
||||
private BigCard bigCard;
|
||||
protected static final DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
|
||||
protected static Client client = MageFrame.getClient();
|
||||
private CardView tooltipCard;
|
||||
private TransferData popupData;
|
||||
private JComponent cardInfoPane;
|
||||
|
|
@ -115,9 +102,6 @@ public class MageActionCallback implements ActionCallback {
|
|||
}
|
||||
|
||||
public synchronized void refreshSession() {
|
||||
if (client == null) {
|
||||
client = MageFrame.getClient();
|
||||
}
|
||||
if (cardInfoPane == null) {
|
||||
cardInfoPane = Plugins.getInstance().getCardInfoPane();
|
||||
}
|
||||
|
|
@ -183,7 +167,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
public void run() {
|
||||
ThreadUtils.sleep(300);
|
||||
|
||||
if (tooltipCard == null || !tooltipCard.equals(data.card) || client == null || !popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||
if (tooltipCard == null || !tooltipCard.equals(data.card) || !popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -262,14 +246,14 @@ 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, client, transferData.card);
|
||||
defaultCallback.mouseClicked(e, transferData.gameId, MageFrame.getClient(), transferData.card);
|
||||
// Closes popup & enlarged view if a card/Permanent is selected
|
||||
hideTooltipPopup();
|
||||
}
|
||||
e.consume();
|
||||
} else {
|
||||
transferData.component.requestFocusInWindow();
|
||||
defaultCallback.mouseClicked(e, transferData.gameId, client, transferData.card);
|
||||
defaultCallback.mouseClicked(e, transferData.gameId, MageFrame.getClient(), transferData.card);
|
||||
// Closes popup & enlarged view if a card/Permanent is selected
|
||||
hideTooltipPopup();
|
||||
e.consume();
|
||||
|
|
@ -434,7 +418,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
jPopupMenu.setVisible(false);
|
||||
}
|
||||
try {
|
||||
if (client == null) {
|
||||
if (MageFrame.getClient() == null) {
|
||||
return;
|
||||
}
|
||||
// set enlarged card display to visible = false
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import mage.client.MageFrame;
|
|||
import mage.client.util.Config;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -53,7 +52,6 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
|||
|
||||
protected PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
|
||||
|
||||
private Client client;
|
||||
|
||||
/** Creates new form TablePlayerPanel */
|
||||
public TablePlayerPanel() {
|
||||
|
|
@ -62,8 +60,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void init(int playerNum, String playerType) {
|
||||
client = MageFrame.getClient();
|
||||
cbPlayerType.setModel(new DefaultComboBoxModel(client.getServerState().getPlayerTypes()));
|
||||
cbPlayerType.setModel(new DefaultComboBoxModel(MageFrame.getClient().getServerState().getPlayerTypes()));
|
||||
this.lblPlayerNum.setText("Player " + playerNum);
|
||||
if (Config.defaultOtherPlayerIndex != null) {
|
||||
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount()) {
|
||||
|
|
@ -81,7 +78,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 client.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
|
||||
return MageFrame.getClient().joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ import mage.constants.SkillLevel;
|
|||
import mage.game.match.MatchOptions;
|
||||
import mage.remote.MageRemoteException;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.RoomUsersView;
|
||||
import mage.view.RoomView;
|
||||
import mage.view.TableView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -111,7 +110,6 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
private NewTableDialog newTableDialog;
|
||||
private NewTournamentDialog newTournamentDialog;
|
||||
private GameChooser gameChooser;
|
||||
private Client client;
|
||||
private List<String> messages;
|
||||
private int currentMessage;
|
||||
private MageTableRowSorter activeTablesSorter;
|
||||
|
|
@ -130,7 +128,6 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
gameChooser = new GameChooser();
|
||||
|
||||
initComponents();
|
||||
tableModel.setClient(client);
|
||||
|
||||
tableTables.createDefaultColumnsFromModel();
|
||||
|
||||
|
|
@ -175,7 +172,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
String owner = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_OWNER);
|
||||
switch (action) {
|
||||
case "Join":
|
||||
if (owner.equals(client.getUserName())) {
|
||||
if (owner.equals(MageFrame.getClient().getUserName())) {
|
||||
try {
|
||||
JDesktopPane desktopPane = (JDesktopPane) MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
||||
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
|
||||
|
|
@ -200,7 +197,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
logger.info("Joining tournament " + tableId);
|
||||
if (deckType.startsWith("Limited")) {
|
||||
if (!status.endsWith("PW")) {
|
||||
client.joinTournamentTable(roomId, tableId, client.getUserName(), "Human", 1, null, "");
|
||||
MageFrame.getClient().joinTournamentTable(roomId, tableId, MageFrame.getClient().getUserName(), "Human", 1, null, "");
|
||||
} else {
|
||||
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
|
||||
}
|
||||
|
|
@ -214,24 +211,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) {
|
||||
client.removeTable(roomId, tableId);
|
||||
MageFrame.getClient().removeTable(roomId, tableId);
|
||||
}
|
||||
break;
|
||||
case "Show":
|
||||
if (isTournament) {
|
||||
logger.info("Showing tournament table " + tableId);
|
||||
client.watchTable(roomId, tableId);
|
||||
MageFrame.getClient().watchTable(roomId, tableId);
|
||||
}
|
||||
break;
|
||||
case "Watch":
|
||||
if (!isTournament) {
|
||||
logger.info("Watching table " + tableId);
|
||||
client.watchTable(roomId, tableId);
|
||||
MageFrame.getClient().watchTable(roomId, tableId);
|
||||
}
|
||||
break;
|
||||
case "Replay":
|
||||
logger.info("Replaying game " + gameId);
|
||||
client.replayGame(gameId);
|
||||
MageFrame.getClient().replayGame(gameId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -248,7 +245,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
List<UUID> gameList = matchesModel.getListofGames(modelRow);
|
||||
if (gameList != null && gameList.size() > 0) {
|
||||
if (gameList.size() == 1) {
|
||||
client.replayGame(gameList.get(0));
|
||||
MageFrame.getClient().replayGame(gameList.get(0));
|
||||
} else {
|
||||
gameChooser.show(gameList, MageFrame.getDesktop().getMousePosition());
|
||||
}
|
||||
|
|
@ -258,7 +255,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
case "Show":;
|
||||
if (matchesModel.isTournament(modelRow)) {
|
||||
logger.info("Showing tournament table " + matchesModel.getTableId(modelRow));
|
||||
client.watchTable(roomId, matchesModel.getTableId(modelRow));
|
||||
MageFrame.getClient().watchTable(roomId, matchesModel.getTableId(modelRow));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -369,9 +366,9 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void startTasks() {
|
||||
if (client != null) {
|
||||
if (MageFrame.getClient() != null) {
|
||||
if (updateRoomTask == null || updateRoomTask.isDone()) {
|
||||
updateRoomTask = new UpdateRoomTask(client, roomId, this, this.chatPanel);
|
||||
updateRoomTask = new UpdateRoomTask(MageFrame.getClient(), roomId, this, this.chatPanel);
|
||||
updateRoomTask.execute();
|
||||
}
|
||||
}
|
||||
|
|
@ -385,12 +382,10 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
|
||||
public void showTables(UUID roomId) {
|
||||
this.roomId = roomId;
|
||||
client = MageFrame.getClient();
|
||||
UUID chatRoomId = null;
|
||||
if (client != null) {
|
||||
btnQuickStart.setVisible(client.getServerState().isTestMode());
|
||||
gameChooser.init(client);
|
||||
chatRoomId = client.getRoomChatId(roomId);
|
||||
if (MageFrame.getClient() != null) {
|
||||
btnQuickStart.setVisible(MageFrame.getClient().getServerState().isTestMode());
|
||||
chatRoomId = MageFrame.getClient().getRoomChatId(roomId);
|
||||
}
|
||||
if (newTableDialog == null) {
|
||||
newTableDialog = new NewTableDialog();
|
||||
|
|
@ -412,7 +407,6 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
} else {
|
||||
hideTables();
|
||||
}
|
||||
tableModel.setClient(client);
|
||||
|
||||
reloadMessages();
|
||||
|
||||
|
|
@ -430,7 +424,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
|
||||
protected void reloadMessages() {
|
||||
// reload server messages
|
||||
List<String> serverMessages = client.getServerMessages();
|
||||
List<String> serverMessages = MageFrame.getClient().getServerMessages();
|
||||
synchronized (this) {
|
||||
this.messages = serverMessages;
|
||||
this.currentMessage = 0;
|
||||
|
|
@ -1119,11 +1113,11 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
options.setFreeMulligans(2);
|
||||
options.setSkillLevel(SkillLevel.CASUAL);
|
||||
options.setRollbackTurnsAllowed(true);
|
||||
table = client.createTable(roomId, options);
|
||||
table = MageFrame.getClient().createTable(roomId, options);
|
||||
|
||||
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());
|
||||
MageFrame.getClient().joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"),"");
|
||||
MageFrame.getClient().joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"),"");
|
||||
MageFrame.getClient().startMatch(roomId, table.getTableId());
|
||||
} catch (HeadlessException ex) {
|
||||
handleError(ex);
|
||||
}
|
||||
|
|
@ -1228,7 +1222,6 @@ class TableTableModel extends AbstractTableModel {
|
|||
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
|
||||
;
|
||||
|
||||
private Client client;
|
||||
|
||||
public void loadData(Collection<TableView> tables) throws MageRemoteException {
|
||||
this.tables = tables.toArray(new TableView[0]);
|
||||
|
|
@ -1245,10 +1238,6 @@ class TableTableModel extends AbstractTableModel {
|
|||
return columnNames.length;
|
||||
}
|
||||
|
||||
public void setClient(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
switch (arg1) {
|
||||
|
|
@ -1273,7 +1262,7 @@ class TableTableModel extends AbstractTableModel {
|
|||
|
||||
case WAITING:
|
||||
String owner = tables[arg0].getControllerName();
|
||||
if (client != null && owner.equals(client.getUserName())) {
|
||||
if (MageFrame.getClient() != null && owner.equals(MageFrame.getClient().getUserName())) {
|
||||
return "";
|
||||
}
|
||||
return "Join";
|
||||
|
|
@ -1287,7 +1276,7 @@ class TableTableModel extends AbstractTableModel {
|
|||
return "Show";
|
||||
} else {
|
||||
owner = tables[arg0].getControllerName();
|
||||
if (client != null && owner.equals(client.getUserName())) {
|
||||
if (MageFrame.getClient() != null && owner.equals(MageFrame.getClient().getUserName())) {
|
||||
return "";
|
||||
}
|
||||
return "Watch";
|
||||
|
|
@ -1495,12 +1484,6 @@ class MatchesTableModel extends AbstractTableModel {
|
|||
|
||||
class GameChooser extends JPopupMenu {
|
||||
|
||||
private Client client;
|
||||
|
||||
public void init(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public void show(List<UUID> games, Point p) {
|
||||
if (p == null) {
|
||||
return;
|
||||
|
|
@ -1524,7 +1507,7 @@ class GameChooser extends JPopupMenu {
|
|||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
client.replayGame(id);
|
||||
MageFrame.getClient().replayGame(id);
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ import java.util.UUID;
|
|||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.client.MageFrame;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -48,7 +46,6 @@ import org.mage.network.Client;
|
|||
*/
|
||||
public class TournamentPlayerPanel extends javax.swing.JPanel {
|
||||
|
||||
private Client client;
|
||||
|
||||
/** Creates new form TournamentPlayerPanel */
|
||||
public TournamentPlayerPanel() {
|
||||
|
|
@ -57,8 +54,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void init(int playerNum) {
|
||||
client = MageFrame.getClient();
|
||||
cbPlayerType.setModel(new DefaultComboBoxModel(client.getServerState().getPlayerTypes()));
|
||||
cbPlayerType.setModel(new DefaultComboBoxModel(MageFrame.getClient().getServerState().getPlayerTypes()));
|
||||
this.lblPlayerNum.setText("Player " + playerNum);
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +64,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
|
|||
|
||||
public boolean joinTournamentTable(UUID roomId, UUID tableId, DeckCardLists deckCardLists) {
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
return client.joinTournamentTable(
|
||||
return MageFrame.getClient().joinTournamentTable(
|
||||
roomId,
|
||||
tableId,
|
||||
this.txtPlayerName.getText(),
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
|
||||
private UUID tournamentId;
|
||||
private boolean firstInitDone = false;
|
||||
private Client client;
|
||||
private final TournamentPlayersTableModel playersModel;
|
||||
private TournamentMatchesTableModel matchesModel;
|
||||
private UpdateTournamentTask updateTask;
|
||||
|
|
@ -124,7 +123,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
// }
|
||||
if (state.startsWith("Dueling") && actionText.equals("Watch")) {
|
||||
logger.info("Watching game " + gameId);
|
||||
client.watchTournamentTable(tableId);
|
||||
MageFrame.getClient().watchTournamentTable(tableId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -172,10 +171,9 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
|
||||
public synchronized void showTournament(UUID tournamentId) {
|
||||
this.tournamentId = tournamentId;
|
||||
client = MageFrame.getClient();
|
||||
// MageFrame.addTournament(tournamentId, this);
|
||||
UUID chatRoomId = client.getTournamentChatId(tournamentId);
|
||||
if (client.joinTournament(tournamentId) && chatRoomId != null) {
|
||||
UUID chatRoomId = MageFrame.getClient().getTournamentChatId(tournamentId);
|
||||
if (MageFrame.getClient().joinTournament(tournamentId) && chatRoomId != null) {
|
||||
this.chatPanel1.connect(chatRoomId);
|
||||
startTasks();
|
||||
this.setVisible(true);
|
||||
|
|
@ -263,7 +261,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
btnQuitTournament.setVisible(false);
|
||||
if (tournament.getEndTime() == null) {
|
||||
for (TournamentPlayerView player : tournament.getPlayers()) {
|
||||
if (player.getName().equals(client.getUserName())) {
|
||||
if (player.getName().equals(MageFrame.getClient().getUserName())) {
|
||||
if (!player.hasQuit()) {
|
||||
btnQuitTournament.setVisible(true);
|
||||
}
|
||||
|
|
@ -275,9 +273,9 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void startTasks() {
|
||||
if (client != null) {
|
||||
if (MageFrame.getClient() != null) {
|
||||
if (updateTask == null || updateTask.isDone()) {
|
||||
updateTask = new UpdateTournamentTask(client, tournamentId, this);
|
||||
updateTask = new UpdateTournamentTask(MageFrame.getClient(), tournamentId, this);
|
||||
updateTask.execute();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ import mage.client.cards.BigCard;
|
|||
import mage.client.dialog.ShowCardsDialog;
|
||||
import mage.client.util.Config;
|
||||
import mage.view.PlayerView;
|
||||
import org.mage.network.Client;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -51,7 +50,6 @@ public class PlayerPanel extends javax.swing.JPanel {
|
|||
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
private Client client;
|
||||
private PlayerView player;
|
||||
|
||||
private ShowCardsDialog graveyard;
|
||||
|
|
@ -68,7 +66,6 @@ public class PlayerPanel extends javax.swing.JPanel {
|
|||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
this.bigCard = bigCard;
|
||||
client = MageFrame.getClient();
|
||||
}
|
||||
|
||||
public void update(PlayerView player) {
|
||||
|
|
@ -193,7 +190,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
|
||||
client.sendPlayerUUID(gameId, playerId);
|
||||
MageFrame.getClient().sendPlayerUUID(gameId, playerId);
|
||||
}//GEN-LAST:event_btnPlayerNameActionPerformed
|
||||
|
||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue