mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
and more refactoring
This commit is contained in:
parent
27da366eea
commit
1ff7f4ba5c
7 changed files with 237 additions and 410 deletions
|
|
@ -25,53 +25,53 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.client.remote;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.draft.DraftPanel;
|
||||
import mage.client.game.GamePanel;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.object.SaveObjectUtil;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.DraftClientMessage;
|
||||
import mage.view.DraftView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.TableClientMessage;
|
||||
import mage.view.UserRequestMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CallbackClientImpl implements CallbackClient {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CallbackClientImpl.class);
|
||||
private final MageFrame frame;
|
||||
private int messageId = 0;
|
||||
private int gameInformMessageId = 0;
|
||||
|
||||
public CallbackClientImpl(MageFrame frame) {
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void processCallback(final ClientCallback callback) {
|
||||
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
|
||||
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
|
||||
switch (callback.getMethod()) {
|
||||
//package mage.client.remote;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.UUID;
|
||||
//import javax.swing.JOptionPane;
|
||||
//import javax.swing.SwingUtilities;
|
||||
//import mage.client.MageFrame;
|
||||
//import mage.client.draft.DraftPanel;
|
||||
//import mage.client.game.GamePanel;
|
||||
//import mage.client.util.audio.AudioManager;
|
||||
//import mage.client.util.object.SaveObjectUtil;
|
||||
//import mage.interfaces.callback.CallbackClient;
|
||||
//import mage.interfaces.callback.ClientCallback;
|
||||
//import mage.utils.CompressUtil;
|
||||
//import mage.view.ChatMessage;
|
||||
//import mage.view.DraftClientMessage;
|
||||
//import mage.view.DraftView;
|
||||
//import mage.view.GameView;
|
||||
//import mage.view.TableClientMessage;
|
||||
//import mage.view.UserRequestMessage;
|
||||
//import org.apache.log4j.Logger;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author BetaSteward_at_googlemail.com
|
||||
// */
|
||||
//public class CallbackClientImpl implements CallbackClient {
|
||||
//
|
||||
// private static final Logger logger = Logger.getLogger(CallbackClientImpl.class);
|
||||
// private final MageFrame frame;
|
||||
// private int messageId = 0;
|
||||
// private int gameInformMessageId = 0;
|
||||
//
|
||||
// public CallbackClientImpl(MageFrame frame) {
|
||||
// this.frame = frame;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public synchronized void processCallback(final ClientCallback callback) {
|
||||
// SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
|
||||
// callback.setData(CompressUtil.decompress(callback.getData()));
|
||||
// SwingUtilities.invokeLater(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// try {
|
||||
// logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
|
||||
// switch (callback.getMethod()) {
|
||||
// case "startGame":
|
||||
// {
|
||||
// TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
|
|
@ -79,27 +79,27 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
// gameStarted(message.getGameId(), message.getPlayerId());
|
||||
// break;
|
||||
// }
|
||||
case "startTournament":
|
||||
{
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
tournamentStarted(message.getGameId(), message.getPlayerId());
|
||||
break;
|
||||
}
|
||||
case "startDraft":
|
||||
{
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
draftStarted(message.getGameId(), message.getPlayerId());
|
||||
break;
|
||||
}
|
||||
case "replayGame":
|
||||
replayGame(callback.getObjectId());
|
||||
break;
|
||||
case "showTournament":
|
||||
showTournament(callback.getObjectId());
|
||||
break;
|
||||
case "watchGame":
|
||||
watchGame(callback.getObjectId());
|
||||
break;
|
||||
// case "startTournament":
|
||||
// {
|
||||
// TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
// tournamentStarted(message.getGameId(), message.getPlayerId());
|
||||
// break;
|
||||
// }
|
||||
// case "startDraft":
|
||||
// {
|
||||
// TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
// draftStarted(message.getGameId(), message.getPlayerId());
|
||||
// break;
|
||||
// }
|
||||
// case "replayGame":
|
||||
// replayGame(callback.getObjectId());
|
||||
// break;
|
||||
// case "showTournament":
|
||||
// showTournament(callback.getObjectId());
|
||||
// break;
|
||||
// case "watchGame":
|
||||
// watchGame(callback.getObjectId());
|
||||
// break;
|
||||
// case "chatMessage":
|
||||
// {
|
||||
// ChatMessage message = (ChatMessage) callback.getData();
|
||||
|
|
@ -135,42 +135,42 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
//
|
||||
// } break;
|
||||
// }
|
||||
case "serverMessage":
|
||||
if (callback.getData() != null) {
|
||||
ChatMessage message = (ChatMessage) callback.getData();
|
||||
if (message.getColor().equals(ChatMessage.MessageColor.RED)) {
|
||||
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.WARNING_MESSAGE);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
} break;
|
||||
// case "serverMessage":
|
||||
// if (callback.getData() != null) {
|
||||
// ChatMessage message = (ChatMessage) callback.getData();
|
||||
// if (message.getColor().equals(ChatMessage.MessageColor.RED)) {
|
||||
// JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.WARNING_MESSAGE);
|
||||
// } else {
|
||||
// JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.INFORMATION_MESSAGE);
|
||||
// }
|
||||
// } break;
|
||||
// case "joinedTable":
|
||||
// {
|
||||
// TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
// joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
||||
// break;
|
||||
// }
|
||||
case "replayInit":
|
||||
{
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.init((GameView) callback.getData());
|
||||
} break;
|
||||
}
|
||||
case "replayDone":
|
||||
{
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.endMessage((String) callback.getData());
|
||||
} break;
|
||||
}
|
||||
case "replayUpdate":
|
||||
{
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.updateGame((GameView) callback.getData());
|
||||
} break;
|
||||
}
|
||||
// case "replayInit":
|
||||
// {
|
||||
// GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
// if (panel != null) {
|
||||
// panel.init((GameView) callback.getData());
|
||||
// } break;
|
||||
// }
|
||||
// case "replayDone":
|
||||
// {
|
||||
// GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
// if (panel != null) {
|
||||
// panel.endMessage((String) callback.getData());
|
||||
// } break;
|
||||
// }
|
||||
// case "replayUpdate":
|
||||
// {
|
||||
// GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
// if (panel != null) {
|
||||
// panel.updateGame((GameView) callback.getData());
|
||||
// } break;
|
||||
// }
|
||||
// case "gameInit":
|
||||
// {
|
||||
// GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
|
|
@ -274,11 +274,11 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
// case "endGameInfo":
|
||||
// MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
|
||||
// break;
|
||||
case "showUserMessage":
|
||||
List<String> messageData = (List<String>) callback.getData();
|
||||
if (messageData.size() == 2) {
|
||||
JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
|
||||
} break;
|
||||
// case "showUserMessage":
|
||||
// List<String> messageData = (List<String>) callback.getData();
|
||||
// if (messageData.size() == 2) {
|
||||
// JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
|
||||
// } break;
|
||||
// case "gameInform":
|
||||
// if (callback.getMessageId() > gameInformMessageId) {
|
||||
// {
|
||||
|
|
@ -323,58 +323,58 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
// construct(deck, message.getTableId(), message.getTime());
|
||||
// break;
|
||||
// }
|
||||
case "draftOver":
|
||||
MageFrame.removeDraft(callback.getObjectId());
|
||||
break;
|
||||
case "draftPick":
|
||||
{
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.loadBooster(message.getDraftPickView());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "draftUpdate":
|
||||
{
|
||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.updateDraft((DraftView) callback.getData());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "draftInform":
|
||||
// case "draftOver":
|
||||
// MageFrame.removeDraft(callback.getObjectId());
|
||||
// break;
|
||||
// case "draftPick":
|
||||
// {
|
||||
// DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
// DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||
// if (panel != null) {
|
||||
// panel.loadBooster(message.getDraftPickView());
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case "draftUpdate":
|
||||
// {
|
||||
// DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||
// if (panel != null) {
|
||||
// panel.updateDraft((DraftView) callback.getData());
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case "draftInform":
|
||||
// if (callback.getMessageId() > messageId) {
|
||||
{
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
}
|
||||
// {
|
||||
// DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
// }
|
||||
// } else {
|
||||
// logger.warn("message out of sequence - ignoring");
|
||||
// }
|
||||
break;
|
||||
case "draftInit":
|
||||
{
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.loadBooster(message.getDraftPickView());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "tournamentInit":
|
||||
break;
|
||||
case "userRequestDialog":
|
||||
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
|
||||
break;
|
||||
}
|
||||
messageId = callback.getMessageId();
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// break;
|
||||
// case "draftInit":
|
||||
// {
|
||||
// DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
// DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||
// if (panel != null) {
|
||||
// panel.loadBooster(message.getDraftPickView());
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case "tournamentInit":
|
||||
// break;
|
||||
// case "userRequestDialog":
|
||||
// frame.showUserRequestDialog((UserRequestMessage) callback.getData());
|
||||
// break;
|
||||
// }
|
||||
// messageId = callback.getMessageId();
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private void createChatStartMessage(ChatPanel chatPanel) {
|
||||
// chatPanel.setStartMessageDone(true);
|
||||
// ChatPanel usedPanel = chatPanel;
|
||||
|
|
@ -428,58 +428,58 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
// Plugins.getInstance().addGamesPlayed();
|
||||
// }
|
||||
// }
|
||||
|
||||
protected void draftStarted(UUID draftId, UUID playerId) {
|
||||
try {
|
||||
frame.showDraft(draftId);
|
||||
logger.info("Draft " + draftId + " started for player " + playerId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void tournamentStarted(UUID tournamentId, UUID playerId) {
|
||||
try {
|
||||
frame.showTournament(tournamentId);
|
||||
AudioManager.playTournamentStarted();
|
||||
logger.info("Tournament " + tournamentId + " started for player " + playerId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the tournament info panel for a tournament
|
||||
*
|
||||
* @param tournamentId
|
||||
*/
|
||||
protected void showTournament(UUID tournamentId) {
|
||||
try {
|
||||
frame.showTournament(tournamentId);
|
||||
logger.info("Showing tournament " + tournamentId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void watchGame(UUID gameId) {
|
||||
try {
|
||||
frame.watchGame(gameId);
|
||||
logger.info("Watching game " + gameId);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void replayGame(UUID gameId) {
|
||||
try {
|
||||
frame.replayGame(gameId);
|
||||
logger.info("Replaying game");
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// protected void draftStarted(UUID draftId, UUID playerId) {
|
||||
// try {
|
||||
// frame.showDraft(draftId);
|
||||
// logger.info("Draft " + draftId + " started for player " + playerId);
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected void tournamentStarted(UUID tournamentId, UUID playerId) {
|
||||
// try {
|
||||
// frame.showTournament(tournamentId);
|
||||
// AudioManager.playTournamentStarted();
|
||||
// logger.info("Tournament " + tournamentId + " started for player " + playerId);
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Shows the tournament info panel for a tournament
|
||||
// *
|
||||
// * @param tournamentId
|
||||
// */
|
||||
// protected void showTournament(UUID tournamentId) {
|
||||
// try {
|
||||
// frame.showTournament(tournamentId);
|
||||
// logger.info("Showing tournament " + tournamentId);
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected void watchGame(UUID gameId) {
|
||||
// try {
|
||||
// frame.watchGame(gameId);
|
||||
// logger.info("Watching game " + gameId);
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected void replayGame(UUID gameId) {
|
||||
// try {
|
||||
// frame.replayGame(gameId);
|
||||
// logger.info("Replaying game");
|
||||
// } catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected void sideboard(Deck deck, UUID tableId, int time) {
|
||||
// frame.showDeckEditor(DeckEditorMode.SIDEBOARDING, deck, tableId, time);
|
||||
// }
|
||||
|
|
@ -488,8 +488,8 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
// frame.showDeckEditor(DeckEditorMode.LIMITED_BUILDING, deck, tableId, time);
|
||||
// }
|
||||
|
||||
private void handleException(Exception ex) {
|
||||
logger.fatal("Client error\n", ex);
|
||||
// private void handleException(Exception ex) {
|
||||
// logger.fatal("Client error\n", ex);
|
||||
// frame.showError("Error: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.view;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class DraftClientMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private DraftView draftView;
|
||||
private DraftPickView draftPickView;
|
||||
private String message;
|
||||
|
||||
public DraftClientMessage(DraftView draftView) {
|
||||
this.draftView = draftView;
|
||||
}
|
||||
|
||||
public DraftClientMessage(DraftPickView draftPickView) {
|
||||
this.draftPickView = draftPickView;
|
||||
}
|
||||
|
||||
public DraftClientMessage(DraftView draftView, String message) {
|
||||
this.message = message;
|
||||
this.draftView = draftView;
|
||||
}
|
||||
|
||||
public DraftPickView getDraftPickView() {
|
||||
return draftPickView;
|
||||
}
|
||||
|
||||
public DraftView getDraftView() {
|
||||
return draftView;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.view;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
import mage.cards.decks.Deck;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TableClientMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private DeckView deck;
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID gameId;
|
||||
private UUID playerId;
|
||||
private int time;
|
||||
private boolean flag = false;
|
||||
|
||||
public TableClientMessage(Deck deck, UUID tableId, int time) {
|
||||
this.deck = new DeckView(deck);
|
||||
this.tableId = tableId;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public TableClientMessage(Deck deck, UUID tableId, int time, boolean flag) {
|
||||
this.deck = new DeckView(deck);
|
||||
this.tableId = tableId;
|
||||
this.time = time;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public TableClientMessage(UUID gameId, UUID playerId) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public TableClientMessage(UUID roomId, UUID tableId, boolean flag) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public DeckView getDeck() {
|
||||
return deck;
|
||||
}
|
||||
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
public UUID getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public UUID getGameId() {
|
||||
return gameId;
|
||||
}
|
||||
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public boolean getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package org.mage.network;
|
||||
|
||||
import org.mage.network.messages.callback.ConstructCallback;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
|
|
@ -30,12 +29,11 @@ import mage.view.AbilityPickerView;
|
|||
import mage.view.CardsView;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.DeckView;
|
||||
import mage.view.DraftClientMessage;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.DraftView;
|
||||
import mage.view.GameClientMessage;
|
||||
import mage.view.GameEndView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.TableClientMessage;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserRequestMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -49,6 +47,7 @@ import org.mage.network.interfaces.MageServer;
|
|||
import org.mage.network.messages.MessageType;
|
||||
import org.mage.network.messages.PingMessage;
|
||||
import org.mage.network.messages.callback.ChatMessageCallback;
|
||||
import org.mage.network.messages.callback.ConstructCallback;
|
||||
import org.mage.network.messages.callback.GameAskCallback;
|
||||
import org.mage.network.messages.callback.GameChooseAbilityCallback;
|
||||
import org.mage.network.messages.callback.GameChooseChoiceCallback;
|
||||
|
|
@ -305,11 +304,11 @@ public class Server {
|
|||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
public void startDraft(String sessionId, UUID draftId, TableClientMessage tableClientMessage) {
|
||||
public void startDraft(String sessionId, UUID draftId, UUID playerId) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
public void draftInit(String sessionId, UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
public void draftInit(String sessionId, UUID draftId, DraftPickView draftPickView) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +316,7 @@ public class Server {
|
|||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
public void draftInform(String sessionId, UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
public void draftInform(String sessionId, UUID draftId, DraftView draftView, String message) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +324,7 @@ public class Server {
|
|||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
public void draftPick(String sessionId, UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
public void draftPick(String sessionId, UUID draftId, DraftPickView draftPickView) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
|
|
@ -341,7 +340,7 @@ public class Server {
|
|||
ch.writeAndFlush(new ConstructCallback(tableId, deck, time)).addListener(WriteListener.getInstance());
|
||||
}
|
||||
|
||||
public void startTournament(String sessionId, UUID tournamentId, TableClientMessage tableClientMessage) {
|
||||
public void startTournament(String sessionId, UUID tournamentId, UUID playerId) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,13 +74,12 @@ import mage.view.CardsView;
|
|||
import mage.view.ChatMessage;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
import mage.view.DeckView;
|
||||
import mage.view.DraftClientMessage;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.DraftView;
|
||||
import mage.view.GameClientMessage;
|
||||
import mage.view.GameEndView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.RoomView;
|
||||
import mage.view.TableClientMessage;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserDataView;
|
||||
|
|
@ -1267,28 +1266,28 @@ public class ServerMain implements MageServer {
|
|||
server.gameError(sessionId, gameId, message);
|
||||
}
|
||||
|
||||
public void startDraft(String sessionId, UUID draftId, TableClientMessage tableClientMessage) {
|
||||
server.startDraft(sessionId, draftId, tableClientMessage);
|
||||
public void startDraft(String sessionId, UUID draftId, UUID playerId) {
|
||||
server.startDraft(sessionId, draftId, playerId);
|
||||
}
|
||||
|
||||
public void draftInit(String sessionId, UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
server.draftInit(sessionId, draftId, draftClientMessage);
|
||||
public void draftInit(String sessionId, UUID draftId, DraftPickView draftPickView) {
|
||||
server.draftInit(sessionId, draftId, draftPickView);
|
||||
}
|
||||
|
||||
public void draftUpdate(String sessionId, UUID draftId, DraftView draftView) {
|
||||
server.draftUpdate(sessionId, draftId, draftView);
|
||||
}
|
||||
|
||||
public void draftInform(String sessionId, UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
server.draftInform(sessionId, draftId, draftClientMessage);
|
||||
public void draftInform(String sessionId, UUID draftId, DraftView draftView, String message) {
|
||||
server.draftInform(sessionId, draftId, draftView, message);
|
||||
}
|
||||
|
||||
public void draftOver(String sessionId, UUID draftId) {
|
||||
server.draftOver(sessionId, draftId);
|
||||
}
|
||||
|
||||
public void draftPick(String sessionId, UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
server.draftPick(sessionId, draftId, draftClientMessage);
|
||||
public void draftPick(String sessionId, UUID draftId, DraftPickView draftPickView) {
|
||||
server.draftPick(sessionId, draftId, draftPickView);
|
||||
}
|
||||
|
||||
public void sideboard(String sessionId, UUID tableId, DeckView deck, int time, boolean limited) {
|
||||
|
|
@ -1299,8 +1298,8 @@ public class ServerMain implements MageServer {
|
|||
server.construct(sessionId, tableId, deck, time);
|
||||
}
|
||||
|
||||
public void startTournament(String sessionId, UUID tournamentId, TableClientMessage tableClientMessage) {
|
||||
server.startTournament(sessionId, tournamentId, tableClientMessage);
|
||||
public void startTournament(String sessionId, UUID tournamentId, UUID playerId) {
|
||||
server.startTournament(sessionId, tournamentId, playerId);
|
||||
}
|
||||
|
||||
public void showTournament(String sessionId, UUID tournamentId) {
|
||||
|
|
|
|||
|
|
@ -57,12 +57,11 @@ import mage.view.AbilityPickerView;
|
|||
import mage.view.CardsView;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.DeckView;
|
||||
import mage.view.DraftClientMessage;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.DraftView;
|
||||
import mage.view.GameClientMessage;
|
||||
import mage.view.GameEndView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.TableClientMessage;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserRequestMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -289,7 +288,7 @@ public class User {
|
|||
}
|
||||
|
||||
public void tournamentStarted(final UUID tournamentId, final UUID playerId) {
|
||||
ServerMain.getInstance().startTournament(sessionId, tournamentId, new TableClientMessage(tournamentId, playerId));
|
||||
ServerMain.getInstance().startTournament(sessionId, tournamentId, playerId);
|
||||
}
|
||||
|
||||
public void showTournament(final UUID tournamentId) {
|
||||
|
|
@ -313,27 +312,27 @@ public class User {
|
|||
}
|
||||
|
||||
public void draftStarted(final UUID draftId, final UUID playerId) {
|
||||
ServerMain.getInstance().startDraft(sessionId, draftId, new TableClientMessage(draftId, playerId));
|
||||
ServerMain.getInstance().startDraft(sessionId, draftId, playerId);
|
||||
}
|
||||
|
||||
public void draftInit(UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
ServerMain.getInstance().draftInit(sessionId, draftId, draftClientMessage);
|
||||
public void draftInit(UUID draftId, DraftPickView view) {
|
||||
ServerMain.getInstance().draftInit(sessionId, draftId, view);
|
||||
}
|
||||
|
||||
public void draftUpdate(UUID draftId, DraftView draftView) {
|
||||
ServerMain.getInstance().draftUpdate(sessionId, draftId, draftView);
|
||||
}
|
||||
|
||||
public void draftInform(UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
ServerMain.getInstance().draftInform(sessionId, draftId, draftClientMessage);
|
||||
public void draftInform(UUID draftId, DraftView view, String message) {
|
||||
ServerMain.getInstance().draftInform(sessionId, draftId, view, message);
|
||||
}
|
||||
|
||||
public void draftOver(UUID draftId) {
|
||||
ServerMain.getInstance().draftOver(sessionId, draftId);
|
||||
}
|
||||
|
||||
public void draftPick(UUID draftId, DraftClientMessage draftClientMessage) {
|
||||
ServerMain.getInstance().draftPick(sessionId, draftId, draftClientMessage);
|
||||
public void draftPick(UUID draftId, DraftPickView view) {
|
||||
ServerMain.getInstance().draftPick(sessionId, draftId, view);
|
||||
}
|
||||
|
||||
public void chatMessage(UUID chatId, ChatMessage chatMessage) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ import mage.game.draft.Draft;
|
|||
import mage.server.User;
|
||||
import mage.server.UserManager;
|
||||
import mage.server.util.ThreadExecutor;
|
||||
import mage.view.DraftClientMessage;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.DraftView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -73,7 +72,7 @@ public class DraftSession {
|
|||
if (user != null) {
|
||||
if (futureTimeout != null && !futureTimeout.isDone()) {
|
||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||
user.draftInit(draft.getId(), new DraftClientMessage(getDraftPickView(remaining)));
|
||||
user.draftInit(draft.getId(), getDraftPickView(remaining));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -96,7 +95,7 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
user.draftInform(draft.getId(), new DraftClientMessage(getDraftView(), message));
|
||||
user.draftInform(draft.getId(), getDraftView(), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +114,7 @@ public class DraftSession {
|
|||
setupTimeout(timeout);
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
user.draftPick(draft.getId(), new DraftClientMessage(getDraftPickView(timeout)));
|
||||
user.draftPick(draft.getId(), getDraftPickView(timeout));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue