mirror of
https://github.com/correl/mage.git
synced 2025-01-13 19:11:33 +00:00
Merge pull request #3058 from ingmargoudt/client_callback_enums
Client callback enums
This commit is contained in:
commit
90b43b5838
15 changed files with 229 additions and 196 deletions
|
@ -4,6 +4,7 @@ import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.util.IgnoreList;
|
import mage.client.util.IgnoreList;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.view.ChatMessage;
|
import mage.view.ChatMessage;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
@ -58,7 +59,7 @@ public final class LocalCommands {
|
||||||
|
|
||||||
private static void displayLocalCommandResponse(UUID chatId, String response) {
|
private static void displayLocalCommandResponse(UUID chatId, String response) {
|
||||||
final String text = new StringBuilder().append("<font color=yellow>").append(response).append("</font>").toString();
|
final String text = new StringBuilder().append("<font color=yellow>").append(response).append("</font>").toString();
|
||||||
ClientCallback chatMessage = new ClientCallback("chatMessage", chatId,
|
ClientCallback chatMessage = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage("", text, timeFormatter.format(new Date()), ChatMessage.MessageColor.BLUE));
|
new ChatMessage("", text, timeFormatter.format(new Date()), ChatMessage.MessageColor.BLUE));
|
||||||
MageFrame.getInstance().processCallback(chatMessage);
|
MageFrame.getInstance().processCallback(chatMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.remote;
|
package mage.client.remote;
|
||||||
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
|
@ -49,19 +44,15 @@ import mage.client.util.object.SaveObjectUtil;
|
||||||
import mage.interfaces.callback.CallbackClient;
|
import mage.interfaces.callback.CallbackClient;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.utils.CompressUtil;
|
import mage.utils.CompressUtil;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.*;
|
||||||
import mage.view.ChatMessage;
|
|
||||||
import mage.view.ChatMessage.MessageType;
|
import mage.view.ChatMessage.MessageType;
|
||||||
import mage.view.DeckView;
|
|
||||||
import mage.view.DraftClientMessage;
|
|
||||||
import mage.view.DraftView;
|
|
||||||
import mage.view.GameClientMessage;
|
|
||||||
import mage.view.GameEndView;
|
|
||||||
import mage.view.GameView;
|
|
||||||
import mage.view.TableClientMessage;
|
|
||||||
import mage.view.UserRequestMessage;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -79,38 +70,38 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void processCallback(final ClientCallback callback) {
|
public synchronized void processCallback(final ClientCallback callback) {
|
||||||
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
|
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod().toString());
|
||||||
callback.setData(CompressUtil.decompress(callback.getData()));
|
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
try {
|
try {
|
||||||
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
|
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
|
||||||
switch (callback.getMethod()) {
|
switch (callback.getMethod()) {
|
||||||
case "startGame": {
|
case START_GAME: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
GameManager.instance.setCurrentPlayerUUID(message.getPlayerId());
|
GameManager.instance.setCurrentPlayerUUID(message.getPlayerId());
|
||||||
gameStarted(message.getGameId(), message.getPlayerId());
|
gameStarted(message.getGameId(), message.getPlayerId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "startTournament": {
|
case START_TOURNAMENT: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
tournamentStarted(message.getGameId(), message.getPlayerId());
|
tournamentStarted(message.getGameId(), message.getPlayerId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "startDraft": {
|
case START_DRAFT: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
draftStarted(message.getGameId(), message.getPlayerId());
|
draftStarted(message.getGameId(), message.getPlayerId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "replayGame":
|
case REPLAY_GAME:
|
||||||
replayGame(callback.getObjectId());
|
replayGame(callback.getObjectId());
|
||||||
break;
|
break;
|
||||||
case "showTournament":
|
case SHOW_TOURNAMENT:
|
||||||
showTournament(callback.getObjectId());
|
showTournament(callback.getObjectId());
|
||||||
break;
|
break;
|
||||||
case "watchGame":
|
case WATCHGAME:
|
||||||
watchGame(callback.getObjectId());
|
watchGame(callback.getObjectId());
|
||||||
break;
|
break;
|
||||||
case "chatMessage": {
|
case CHATMESSAGE: {
|
||||||
ChatMessage message = (ChatMessage) callback.getData();
|
ChatMessage message = (ChatMessage) callback.getData();
|
||||||
|
|
||||||
// Drop messages from ignored users
|
// Drop messages from ignored users
|
||||||
|
@ -154,7 +145,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "serverMessage":
|
case SERVER_MESSAGE:
|
||||||
if (callback.getData() != null) {
|
if (callback.getData() != null) {
|
||||||
ChatMessage message = (ChatMessage) callback.getData();
|
ChatMessage message = (ChatMessage) callback.getData();
|
||||||
if (message.getColor() == ChatMessage.MessageColor.RED) {
|
if (message.getColor() == ChatMessage.MessageColor.RED) {
|
||||||
|
@ -164,50 +155,50 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "joinedTable": {
|
case JOINED_TABLE: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "replayInit": {
|
case REPLAY_INIT: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.init((GameView) callback.getData());
|
panel.init((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "replayDone": {
|
case REPLAY_DONE: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "replayUpdate": {
|
case REPLAY_UPDATE: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.updateGame((GameView) callback.getData());
|
panel.updateGame((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameInit": {
|
case GAME_INIT: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.init((GameView) callback.getData());
|
panel.init((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameOver": {
|
case GAME_OVER: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameError":
|
case GAME_ERROR:
|
||||||
frame.showErrorDialog("Game Error", (String) callback.getData());
|
frame.showErrorDialog("Game Error", (String) callback.getData());
|
||||||
break;
|
break;
|
||||||
case "gameAsk": {
|
case GAME_ASK: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -215,7 +206,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameTarget": // e.g. Pick triggered ability
|
case GAME_TARGET: // e.g. Pick triggered ability
|
||||||
{
|
{
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
|
@ -225,7 +216,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameSelect": {
|
case GAME_SELECT: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -233,14 +224,14 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameChooseAbility": {
|
case GAME_CHOOSE_ABILITY: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
panel.pickAbility((AbilityPickerView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameChoosePile": {
|
case GAME_CHOOSE_PILE: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -248,7 +239,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameChooseChoice": {
|
case GAME_CHOOSE_CHOICE: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
|
|
||||||
|
@ -257,7 +248,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gamePlayMana": {
|
case GAME_PLAY_MANA: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -265,7 +256,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gamePlayXMana": {
|
case GAME_PLAY_XMANA: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -273,7 +264,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameSelectAmount": {
|
case GAME_GET_AMOUNT: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -281,23 +272,23 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameUpdate": {
|
case GAME_UPDATE: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.updateGame((GameView) callback.getData());
|
panel.updateGame((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "endGameInfo":
|
case END_GAME_INFO:
|
||||||
MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
|
MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
|
||||||
break;
|
break;
|
||||||
case "showUserMessage":
|
case SHOW_USERMESSAGE:
|
||||||
List<String> messageData = (List<String>) callback.getData();
|
List<String> messageData = (List<String>) callback.getData();
|
||||||
if (messageData.size() == 2) {
|
if (messageData.size() == 2) {
|
||||||
JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
|
JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "gameInform":
|
case GAME_INFORM:
|
||||||
if (callback.getMessageId() > gameInformMessageId) {
|
if (callback.getMessageId() > gameInformMessageId) {
|
||||||
{
|
{
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
|
@ -313,7 +304,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
gameInformMessageId = messageId;
|
gameInformMessageId = messageId;
|
||||||
break;
|
break;
|
||||||
case "gameInformPersonal": {
|
case GAME_INFORM_PERSONAL: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -322,7 +313,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "sideboard": {
|
case SIDEBOARD: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
DeckView deckView = message.getDeck();
|
DeckView deckView = message.getDeck();
|
||||||
Deck deck = DeckUtil.construct(deckView);
|
Deck deck = DeckUtil.construct(deckView);
|
||||||
|
@ -333,17 +324,17 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "construct": {
|
case CONSTRUCT: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
DeckView deckView = message.getDeck();
|
DeckView deckView = message.getDeck();
|
||||||
Deck deck = DeckUtil.construct(deckView);
|
Deck deck = DeckUtil.construct(deckView);
|
||||||
construct(deck, message.getTableId(), message.getTime());
|
construct(deck, message.getTableId(), message.getTime());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "draftOver":
|
case DRAFT_OVER:
|
||||||
MageFrame.removeDraft(callback.getObjectId());
|
MageFrame.removeDraft(callback.getObjectId());
|
||||||
break;
|
break;
|
||||||
case "draftPick": {
|
case DRAFT_PICK: {
|
||||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -351,14 +342,14 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "draftUpdate": {
|
case DRAFT_UPDATE: {
|
||||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.updateDraft((DraftView) callback.getData());
|
panel.updateDraft((DraftView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "draftInform": // if (callback.getMessageId() > messageId) {
|
case DRAFT_INFORM: // if (callback.getMessageId() > messageId) {
|
||||||
{
|
{
|
||||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||||
}
|
}
|
||||||
|
@ -366,7 +357,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
// logger.warn("message out of sequence - ignoring");
|
// logger.warn("message out of sequence - ignoring");
|
||||||
// }
|
// }
|
||||||
break;
|
break;
|
||||||
case "draftInit": {
|
case DRAFT_INIT: {
|
||||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
@ -374,9 +365,9 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "tournamentInit":
|
case TOURNAMENT_INIT:
|
||||||
break;
|
break;
|
||||||
case "userRequestDialog":
|
case USER_REQUEST_DIALOG:
|
||||||
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
|
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,18 +39,18 @@ public class ClientCallback implements Serializable {
|
||||||
|
|
||||||
private UUID objectId;
|
private UUID objectId;
|
||||||
private Object data;
|
private Object data;
|
||||||
private String method;
|
private ClientCallbackMethod method;
|
||||||
private int messageId;
|
private int messageId;
|
||||||
|
|
||||||
public ClientCallback() {}
|
public ClientCallback() {}
|
||||||
|
|
||||||
public ClientCallback(String method, UUID objectId, Object data) {
|
public ClientCallback(ClientCallbackMethod method, UUID objectId, Object data) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.objectId = objectId;
|
this.objectId = objectId;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientCallback(String method, UUID objectId) {
|
public ClientCallback(ClientCallbackMethod method, UUID objectId) {
|
||||||
this(method, objectId, null);
|
this(method, objectId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ public class ClientCallback implements Serializable {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMethod() {
|
public ClientCallbackMethod getMethod() {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethod(String method) {
|
public void setMethod(ClientCallbackMethod method) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package mage.interfaces.callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by IGOUDT on 4-4-2017.
|
||||||
|
*/
|
||||||
|
public enum ClientCallbackMethod {
|
||||||
|
|
||||||
|
CHATMESSAGE("chatMessage"),
|
||||||
|
TOURNAMENT_INIT("tournamentInit"),
|
||||||
|
TOURNAMENT_UPDATE("tournamentUpdate"),
|
||||||
|
TOURNAMENT_OVER("tournamentOver"),
|
||||||
|
JOINED_TABLE("joinedTable"),
|
||||||
|
START_DRAFT("startDraft"),
|
||||||
|
START_TOURNAMENT("startTournament"),
|
||||||
|
SIDEBOARD("sideboard"),
|
||||||
|
CONSTRUCT("construct"),
|
||||||
|
SHOW_USERMESSAGE("showUserMessage"),
|
||||||
|
WATCHGAME("watchGame"),
|
||||||
|
REPLAY_GAME("replayGame"),
|
||||||
|
START_GAME("startGame"),
|
||||||
|
SHOW_TOURNAMENT("showTournament"),
|
||||||
|
SHOW_GAME_END_DIALOG("showGameEndDialog"),
|
||||||
|
SERVER_MESSAGE("serverMessage"),
|
||||||
|
GAME_INIT("gameInit"),
|
||||||
|
GAME_OVER("gameOver"),
|
||||||
|
GAME_INFORM("gameInform"),
|
||||||
|
GAME_INFORM_PERSONAL("gameInformPersonal"),
|
||||||
|
GAME_ERROR("gameError"),
|
||||||
|
GAME_UPDATE("gameUpdate"),
|
||||||
|
DRAFT_OVER("draftOver"),
|
||||||
|
REPLAY_DONE("replayDone"),
|
||||||
|
USER_REQUEST_DIALOG("userRequestDialog"),
|
||||||
|
REPLAY_UPDATE("replayUpdate"),
|
||||||
|
REPLAY_INIT("replayInit"),
|
||||||
|
END_GAME_INFO("endGameInfo"),
|
||||||
|
GAME_TARGET("gameTarget"),
|
||||||
|
GAME_CHOOSE_ABILITY("gameChooseAbility"),
|
||||||
|
GAME_CHOOSE_PILE("gameChoosePile"),
|
||||||
|
GAME_CHOOSE_CHOICE("gameChooseChoice"), GAME_ASK("gameAsk"), GAME_SELECT("gameSelect"), GAME_PLAY_MANA("gamePlayMana"), GAME_PLAY_XMANA("gamePlayXMana"), GAME_GET_AMOUNT("gameSelectAmount"), DRAFT_INIT("draftInit"), DRAFT_INFORM("draftInform"), DRAFT_PICK("draftPick"), DRAFT_UPDATE("draftUpdate");
|
||||||
|
|
||||||
|
String value;
|
||||||
|
|
||||||
|
ClientCallbackMethod(String value){
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.view.ChatMessage;
|
import mage.view.ChatMessage;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.ChatMessage.MessageType;
|
import mage.view.ChatMessage.MessageType;
|
||||||
|
@ -84,30 +85,9 @@ public class ChatSession {
|
||||||
clients.remove(userId);
|
clients.remove(userId);
|
||||||
logger.debug(userName + '(' + reason.toString() + ')' + " removed from chatId " + chatId);
|
logger.debug(userName + '(' + reason.toString() + ')' + " removed from chatId " + chatId);
|
||||||
}
|
}
|
||||||
String message;
|
String message = reason.getMessage();
|
||||||
switch (reason) {
|
|
||||||
case Disconnected:
|
if (!message.isEmpty()) {
|
||||||
message = " has left XMage";
|
|
||||||
break;
|
|
||||||
case LostConnection:
|
|
||||||
message = " has lost connection";
|
|
||||||
break;
|
|
||||||
case SessionExpired:
|
|
||||||
message = " session expired";
|
|
||||||
break;
|
|
||||||
case AdminDisconnect:
|
|
||||||
message = " was disconnected by the Admin";
|
|
||||||
break;
|
|
||||||
case ConnectingOtherInstance:
|
|
||||||
message = " reconnected and replaced still active old session";
|
|
||||||
break;
|
|
||||||
case CleaningUp:
|
|
||||||
message = null;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
message = " left (" + reason.toString() + ')';
|
|
||||||
}
|
|
||||||
if (message != null) {
|
|
||||||
broadcast(null, userName + message, MessageColor.BLUE, true, MessageType.STATUS, null);
|
broadcast(null, userName + message, MessageColor.BLUE, true, MessageType.STATUS, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +98,7 @@ public class ChatSession {
|
||||||
|
|
||||||
public boolean broadcastInfoToUser(User toUser, String message) {
|
public boolean broadcastInfoToUser(User toUser, String message) {
|
||||||
if (clients.containsKey(toUser.getId())) {
|
if (clients.containsKey(toUser.getId())) {
|
||||||
toUser.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(null, message, timeFormatter.format(new Date()), MessageColor.BLUE, MessageType.USER_INFO, null)));
|
toUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId, new ChatMessage(null, message, timeFormatter.format(new Date()), MessageColor.BLUE, MessageType.USER_INFO, null)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -126,10 +106,10 @@ public class ChatSession {
|
||||||
|
|
||||||
public boolean broadcastWhisperToUser(User fromUser, User toUser, String message) {
|
public boolean broadcastWhisperToUser(User fromUser, User toUser, String message) {
|
||||||
if (clients.containsKey(toUser.getId())) {
|
if (clients.containsKey(toUser.getId())) {
|
||||||
toUser.fireCallback(new ClientCallback("chatMessage", chatId,
|
toUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage(fromUser.getName(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER_FROM, SoundToPlay.PlayerWhispered)));
|
new ChatMessage(fromUser.getName(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER_FROM, SoundToPlay.PlayerWhispered)));
|
||||||
if (clients.containsKey(fromUser.getId())) {
|
if (clients.containsKey(fromUser.getId())) {
|
||||||
fromUser.fireCallback(new ClientCallback("chatMessage", chatId,
|
fromUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage(toUser.getName(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER_TO, null)));
|
new ChatMessage(toUser.getName(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER_TO, null)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +120,7 @@ public class ChatSession {
|
||||||
public void broadcast(String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) {
|
public void broadcast(String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) {
|
||||||
if (!message.isEmpty()) {
|
if (!message.isEmpty()) {
|
||||||
HashSet<UUID> clientsToRemove = new HashSet<>();
|
HashSet<UUID> clientsToRemove = new HashSet<>();
|
||||||
ClientCallback clientCallback = new ClientCallback("chatMessage", chatId, new ChatMessage(userName, message, (withTime ? timeFormatter.format(new Date()) : ""), color, messageType, soundToPlay));
|
ClientCallback clientCallback = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId, new ChatMessage(userName, message, (withTime ? timeFormatter.format(new Date()) : ""), color, messageType, soundToPlay));
|
||||||
for (UUID userId : clients.keySet()) {
|
for (UUID userId : clients.keySet()) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
|
|
|
@ -6,11 +6,20 @@ package mage.server;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum DisconnectReason {
|
public enum DisconnectReason {
|
||||||
LostConnection,
|
LostConnection(" has lost connection"),
|
||||||
Disconnected,
|
Disconnected(" has left XMage"),
|
||||||
CleaningUp,
|
CleaningUp(" [cleaning up]"),
|
||||||
ConnectingOtherInstance,
|
ConnectingOtherInstance(" reconnected and replaced still active old session"),
|
||||||
AdminDisconnect,
|
AdminDisconnect(" was disconnected by the Admin"),
|
||||||
SessionExpired,
|
SessionExpired(" session expired"),
|
||||||
Undefined
|
Undefined("");
|
||||||
|
|
||||||
|
String message;
|
||||||
|
DisconnectReason(String message){
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage(){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ import mage.interfaces.ActionWithResult;
|
||||||
import mage.interfaces.MageServer;
|
import mage.interfaces.MageServer;
|
||||||
import mage.interfaces.ServerState;
|
import mage.interfaces.ServerState;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.PlayerType;
|
import mage.players.PlayerType;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.remote.MageVersionException;
|
import mage.remote.MageVersionException;
|
||||||
|
@ -1172,9 +1173,9 @@ public class MageServerImpl implements MageServer {
|
||||||
execute("sendBroadcastMessage", sessionId, () -> {
|
execute("sendBroadcastMessage", sessionId, () -> {
|
||||||
for (User user : UserManager.instance.getUsers()) {
|
for (User user : UserManager.instance.getUsers()) {
|
||||||
if (message.toLowerCase(Locale.ENGLISH).startsWith("warn")) {
|
if (message.toLowerCase(Locale.ENGLISH).startsWith("warn")) {
|
||||||
user.fireCallback(new ClientCallback("serverMessage", null, new ChatMessage("SERVER", message, null, MessageColor.RED)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.SERVER_MESSAGE, null, new ChatMessage("SERVER", message, null, MessageColor.RED)));
|
||||||
} else {
|
} else {
|
||||||
user.fireCallback(new ClientCallback("serverMessage", null, new ChatMessage("SERVER", message, null, MessageColor.BLUE)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.SERVER_MESSAGE, null, new ChatMessage("SERVER", message, null, MessageColor.BLUE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
|
@ -30,6 +30,7 @@ package mage.server;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.constants.Constants;
|
import mage.constants.Constants;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.players.net.UserGroup;
|
import mage.players.net.UserGroup;
|
||||||
import mage.server.game.GamesRoom;
|
import mage.server.game.GamesRoom;
|
||||||
|
@ -423,14 +424,14 @@ public class Session {
|
||||||
List<String> messageData = new LinkedList<>();
|
List<String> messageData = new LinkedList<>();
|
||||||
messageData.add("Error while connecting to server");
|
messageData.add("Error while connecting to server");
|
||||||
messageData.add(message);
|
messageData.add(message);
|
||||||
fireCallback(new ClientCallback("showUserMessage", null, messageData));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendInfoMessageToClient(String message) {
|
public void sendInfoMessageToClient(String message) {
|
||||||
List<String> messageData = new LinkedList<>();
|
List<String> messageData = new LinkedList<>();
|
||||||
messageData.add("Information about connecting to the server");
|
messageData.add("Information about connecting to the server");
|
||||||
messageData.add(message);
|
messageData.add(message);
|
||||||
fireCallback(new ClientCallback("showUserMessage", null, messageData));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Throwable getBasicCause(Throwable cause) {
|
public static Throwable getBasicCause(Throwable cause) {
|
||||||
|
|
|
@ -27,10 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
@ -38,6 +34,7 @@ import mage.game.Table;
|
||||||
import mage.game.result.ResultProtos;
|
import mage.game.result.ResultProtos;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.server.draft.DraftSession;
|
import mage.server.draft.DraftSession;
|
||||||
import mage.server.game.GameManager;
|
import mage.server.game.GameManager;
|
||||||
|
@ -54,6 +51,11 @@ import mage.server.util.SystemUtil;
|
||||||
import mage.view.TableClientMessage;
|
import mage.view.TableClientMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -247,52 +249,52 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccJoinedTable(final UUID roomId, final UUID tableId, boolean isTournament) {
|
public void ccJoinedTable(final UUID roomId, final UUID tableId, boolean isTournament) {
|
||||||
fireCallback(new ClientCallback("joinedTable", tableId, new TableClientMessage(roomId, tableId, isTournament)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.JOINED_TABLE, tableId, new TableClientMessage(roomId, tableId, isTournament)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccGameStarted(final UUID gameId, final UUID playerId) {
|
public void ccGameStarted(final UUID gameId, final UUID playerId) {
|
||||||
fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.START_GAME, gameId, new TableClientMessage(gameId, playerId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccDraftStarted(final UUID draftId, final UUID playerId) {
|
public void ccDraftStarted(final UUID draftId, final UUID playerId) {
|
||||||
fireCallback(new ClientCallback("startDraft", draftId, new TableClientMessage(draftId, playerId)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.START_DRAFT, draftId, new TableClientMessage(draftId, playerId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccTournamentStarted(final UUID tournamentId, final UUID playerId) {
|
public void ccTournamentStarted(final UUID tournamentId, final UUID playerId) {
|
||||||
fireCallback(new ClientCallback("startTournament", tournamentId, new TableClientMessage(tournamentId, playerId)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.START_TOURNAMENT, tournamentId, new TableClientMessage(tournamentId, playerId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccSideboard(final Deck deck, final UUID tableId, final int time, boolean limited) {
|
public void ccSideboard(final Deck deck, final UUID tableId, final int time, boolean limited) {
|
||||||
fireCallback(new ClientCallback("sideboard", tableId, new TableClientMessage(deck, tableId, time, limited)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SIDEBOARD, tableId, new TableClientMessage(deck, tableId, time, limited)));
|
||||||
sideboarding.put(tableId, deck);
|
sideboarding.put(tableId, deck);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccConstruct(final Deck deck, final UUID tableId, final int time) {
|
public void ccConstruct(final Deck deck, final UUID tableId, final int time) {
|
||||||
fireCallback(new ClientCallback("construct", tableId, new TableClientMessage(deck, tableId, time)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.CONSTRUCT, tableId, new TableClientMessage(deck, tableId, time)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccShowTournament(final UUID tournamentId) {
|
public void ccShowTournament(final UUID tournamentId) {
|
||||||
fireCallback(new ClientCallback("showTournament", tournamentId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_TOURNAMENT, tournamentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccShowGameEndDialog(final UUID gameId) {
|
public void ccShowGameEndDialog(final UUID gameId) {
|
||||||
fireCallback(new ClientCallback("showGameEndDialog", gameId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_GAME_END_DIALOG, gameId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showUserMessage(final String titel, String message) {
|
public void showUserMessage(final String titel, String message) {
|
||||||
List<String> messageData = new LinkedList<>();
|
List<String> messageData = new LinkedList<>();
|
||||||
messageData.add(titel);
|
messageData.add(titel);
|
||||||
messageData.add(message);
|
messageData.add(message);
|
||||||
fireCallback(new ClientCallback("showUserMessage", null, messageData));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ccWatchGame(final UUID gameId) {
|
public boolean ccWatchGame(final UUID gameId) {
|
||||||
fireCallback(new ClientCallback("watchGame", gameId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.WATCHGAME, gameId));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccReplayGame(final UUID gameId) {
|
public void ccReplayGame(final UUID gameId) {
|
||||||
fireCallback(new ClientCallback("replayGame", gameId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_GAME, gameId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayerUUID(final UUID gameId, final UUID data) {
|
public void sendPlayerUUID(final UUID gameId, final UUID data) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ package mage.server.draft;
|
||||||
|
|
||||||
import mage.game.draft.Draft;
|
import mage.game.draft.Draft;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
|
@ -75,7 +76,7 @@ public class DraftSession {
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
if (futureTimeout != null && !futureTimeout.isDone()) {
|
if (futureTimeout != null && !futureTimeout.isDone()) {
|
||||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||||
user.get().fireCallback(new ClientCallback("draftInit", draft.getId(), new DraftClientMessage(getDraftPickView(remaining))));
|
user.get().fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_INIT, draft.getId(), new DraftClientMessage(getDraftPickView(remaining))));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +89,7 @@ public class DraftSession {
|
||||||
UserManager.instance
|
UserManager.instance
|
||||||
.getUser(userId).
|
.getUser(userId).
|
||||||
ifPresent(user -> user.fireCallback(
|
ifPresent(user -> user.fireCallback(
|
||||||
new ClientCallback("draftUpdate", draft.getId(), getDraftView())));
|
new ClientCallback(ClientCallbackMethod.DRAFT_UPDATE, draft.getId(), getDraftView())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ public class DraftSession {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance
|
UserManager.instance
|
||||||
.getUser(userId)
|
.getUser(userId)
|
||||||
.ifPresent(user -> user.fireCallback(new ClientCallback("draftInform", draft.getId(), new DraftClientMessage(getDraftView(), message))));
|
.ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_INFORM, draft.getId(), new DraftClientMessage(getDraftView(), message))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -107,7 +108,7 @@ public class DraftSession {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance
|
UserManager.instance
|
||||||
.getUser(userId)
|
.getUser(userId)
|
||||||
.ifPresent(user -> user.fireCallback(new ClientCallback("draftOver", draft.getId())));
|
.ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_OVER, draft.getId())));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,7 @@ public class DraftSession {
|
||||||
setupTimeout(timeout);
|
setupTimeout(timeout);
|
||||||
UserManager.instance
|
UserManager.instance
|
||||||
.getUser(userId)
|
.getUser(userId)
|
||||||
.ifPresent(user -> user.fireCallback(new ClientCallback("draftPick", draft.getId(), new DraftClientMessage(getDraftPickView(timeout)))));
|
.ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_PICK, draft.getId(), new DraftClientMessage(getDraftPickView(timeout)))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import mage.constants.PlayerAction;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.Table;
|
import mage.game.Table;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
|
@ -69,7 +70,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
|
|
||||||
public void ask(final String question, final Map<String, Serializable> options) {
|
public void ask(final String question, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameAsk", game.getId(), new GameClientMessage(getGameView(), question, options)))
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_TARGET, game.getId(), new GameClientMessage(getGameView(), question, options)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void target(final String question, final CardsView cardView, final Set<UUID> targets, final boolean required, final Map<String, Serializable> options) {
|
public void target(final String question, final CardsView cardView, final Set<UUID> targets, final boolean required, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
user.fireCallback(new ClientCallback("gameTarget", game.getId(), new GameClientMessage(getGameView(), question, cardView, targets, required, options)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_TARGET, game.getId(), new GameClientMessage(getGameView(), question, cardView, targets, required, options)));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,14 +86,14 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
|
|
||||||
public void select(final String message, final Map<String, Serializable> options) {
|
public void select(final String message, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameSelect", game.getId(), new GameClientMessage(getGameView(), message, options))));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_SELECT, game.getId(), new GameClientMessage(getGameView(), message, options))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chooseAbility(final AbilityPickerView abilities) {
|
public void chooseAbility(final AbilityPickerView abilities) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gameChooseAbility", game.getId(), abilities)));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_ABILITY, game.getId(), abilities)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,7 +101,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void choosePile(final String message, final CardsView pile1, final CardsView pile2) {
|
public void choosePile(final String message, final CardsView pile1, final CardsView pile2) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gameChoosePile", game.getId(), new GameClientMessage(message, pile1, pile2))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_PILE, game.getId(), new GameClientMessage(message, pile1, pile2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -108,7 +109,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void chooseChoice(final Choice choice) {
|
public void chooseChoice(final Choice choice) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gameChooseChoice", game.getId(), new GameClientMessage(choice))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_CHOICE, game.getId(), new GameClientMessage(choice))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,14 +117,14 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void playMana(final String message, final Map<String, Serializable> options) {
|
public void playMana(final String message, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(getGameView(), message, options))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_MANA, game.getId(), new GameClientMessage(getGameView(), message, options))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playXMana(final String message) {
|
public void playXMana(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gamePlayXMana", game.getId(), new GameClientMessage(getGameView(), message))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_XMANA, game.getId(), new GameClientMessage(getGameView(), message))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,14 +132,14 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void getAmount(final String message, final int min, final int max) {
|
public void getAmount(final String message, final int min, final int max) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
user.fireCallback(new ClientCallback("gameSelectAmount", game.getId(), new GameClientMessage(message, min, max)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_GET_AMOUNT, game.getId(), new GameClientMessage(message, min, max)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endGameInfo(Table table) {
|
public void endGameInfo(Table table) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("endGameInfo", game.getId(), getGameEndView(playerId, table))));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.END_GAME_INFO, game.getId(), getGameEndView(playerId, table))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +166,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
userRequestMessage.setGameId(game.getId());
|
userRequestMessage.setGameId(game.getId());
|
||||||
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_ROLLBACK_TURN);
|
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_ROLLBACK_TURN);
|
||||||
userRequestMessage.setButton2("Deny", PlayerAction.DENY_PERMISSON_TO_ROLLBACK_TURN);
|
userRequestMessage.setButton2("Deny", PlayerAction.DENY_PERMISSON_TO_ROLLBACK_TURN);
|
||||||
requestedUser.get().fireCallback(new ClientCallback("userRequestDialog", game.getId(), userRequestMessage));
|
requestedUser.get().fireCallback(new ClientCallback(ClientCallbackMethod.USER_REQUEST_DIALOG, game.getId(), userRequestMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +184,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
userRequestMessage.setGameId(game.getId());
|
userRequestMessage.setGameId(game.getId());
|
||||||
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_SEE_HAND_CARDS);
|
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_SEE_HAND_CARDS);
|
||||||
userRequestMessage.setButton2("Reject", null);
|
userRequestMessage.setButton2("Reject", null);
|
||||||
user.get().fireCallback(new ClientCallback("userRequestDialog", game.getId(), userRequestMessage));
|
user.get().fireCallback(new ClientCallback(ClientCallbackMethod.USER_REQUEST_DIALOG, game.getId(), userRequestMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,10 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.Table;
|
import mage.game.Table;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
|
@ -45,6 +41,11 @@ import mage.view.GameView;
|
||||||
import mage.view.SimpleCardsView;
|
import mage.view.SimpleCardsView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +68,7 @@ public class GameSessionWatcher {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
user.get().fireCallback(new ClientCallback("gameInit", game.getId(), getGameView()));
|
user.get().fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INIT, game.getId(), getGameView()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,21 +77,21 @@ public class GameSessionWatcher {
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameUpdate", game.getId(), getGameView())));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_UPDATE, game.getId(), getGameView())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inform(final String message) {
|
public void inform(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameInform", game.getId(), new GameClientMessage(getGameView(), message))));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM, game.getId(), new GameClientMessage(getGameView(), message))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void informPersonal(final String message) {
|
public void informPersonal(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameInformPersonal", game.getId(), new GameClientMessage(getGameView(), message))));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM_PERSONAL, game.getId(), new GameClientMessage(getGameView(), message))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +100,7 @@ public class GameSessionWatcher {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
user.removeGameWatchInfo(game.getId());
|
user.removeGameWatchInfo(game.getId());
|
||||||
user.fireCallback(new ClientCallback("gameOver", game.getId(), message));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_OVER, game.getId(), message));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +114,7 @@ public class GameSessionWatcher {
|
||||||
|
|
||||||
public void gameError(final String message) {
|
public void gameError(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameError", game.getId(), message)));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ERROR, game.getId(), message)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.GameState;
|
import mage.game.GameState;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
import mage.view.GameView;
|
import mage.view.GameView;
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ public class ReplaySession implements GameCallback {
|
||||||
public void replay() {
|
public void replay() {
|
||||||
replay.start();
|
replay.start();
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame(), null, null))));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_INIT, replay.getGame().getId(), new GameView(replay.next(), replay.getGame(), null, null))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ public class ReplaySession implements GameCallback {
|
||||||
@Override
|
@Override
|
||||||
public void gameResult(final String result) {
|
public void gameResult(final String result) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_DONE, replay.getGame().getId(), result)));
|
||||||
|
|
||||||
ReplayManager.instance.endReplay(replay.getGame().getId(), userId);
|
ReplayManager.instance.endReplay(replay.getGame().getId(), userId);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +89,7 @@ public class ReplaySession implements GameCallback {
|
||||||
gameResult("game ended");
|
gameResult("game ended");
|
||||||
} else {
|
} else {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game, null, null))));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_UPDATE, replay.getGame().getId(), new GameView(state, game, null, null))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ package mage.server.tournament;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
|
@ -69,7 +70,7 @@ public class TournamentSession {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
user.get().fireCallback(new ClientCallback("tournamentInit", tournament.getId(), getTournamentView()));
|
user.get().fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_INIT, tournament.getId(), getTournamentView()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +80,7 @@ public class TournamentSession {
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("tournamentUpdate", tournament.getId(), getTournamentView())));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_UPDATE, tournament.getId(), getTournamentView())));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +88,7 @@ public class TournamentSession {
|
||||||
public void gameOver(final String message) {
|
public void gameOver(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("tournamentOver", tournament.getId(), message)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_OVER, tournament.getId(), message)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,58 +35,55 @@ public class LoadCallbackClient implements CallbackClient {
|
||||||
log.info(callback.getMethod());
|
log.info(callback.getMethod());
|
||||||
callback.setData(CompressUtil.decompress(callback.getData()));
|
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||||
switch (callback.getMethod()) {
|
switch (callback.getMethod()) {
|
||||||
case "startGame":
|
case START_GAME: {
|
||||||
{
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
gameId = message.getGameId();
|
||||||
gameId = message.getGameId();
|
playerId = message.getPlayerId();
|
||||||
playerId = message.getPlayerId();
|
session.joinGame(message.getGameId());
|
||||||
session.joinGame(message.getGameId());
|
startControlThread();
|
||||||
startControlThread();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "gameInform":
|
|
||||||
{
|
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
|
||||||
log.info("Inform: " + message.getMessage());
|
|
||||||
gameView = message.getGameView();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "gameInit":
|
|
||||||
break;
|
break;
|
||||||
case "gameTarget":
|
}
|
||||||
{
|
case GAME_INFORM: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
log.info("Target: " + message.getMessage());
|
log.info("Inform: " + message.getMessage());
|
||||||
switch (message.getMessage()) {
|
gameView = message.getGameView();
|
||||||
case "Select a starting player":
|
break;
|
||||||
session.sendPlayerUUID(gameId, playerId);
|
}
|
||||||
break;
|
case GAME_INIT:
|
||||||
case "Select a card to discard":
|
break;
|
||||||
log.info("hand size: " + gameView.getHand().size());
|
case GAME_TARGET: {
|
||||||
SimpleCardView card = gameView.getHand().values().iterator().next();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
session.sendPlayerUUID(gameId, card.getId());
|
log.info("Target: " + message.getMessage());
|
||||||
break;
|
switch (message.getMessage()) {
|
||||||
}
|
case "Select a starting player":
|
||||||
break;
|
session.sendPlayerUUID(gameId, playerId);
|
||||||
|
break;
|
||||||
|
case "Select a card to discard":
|
||||||
|
log.info("hand size: " + gameView.getHand().size());
|
||||||
|
SimpleCardView card = gameView.getHand().values().iterator().next();
|
||||||
|
session.sendPlayerUUID(gameId, card.getId());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case "gameAsk":
|
break;
|
||||||
{
|
}
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
case GAME_ASK: {
|
||||||
log.info("Ask: " + message.getMessage());
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
if (message.getMessage().equals("Do you want to take a mulligan?")) {
|
log.info("Ask: " + message.getMessage());
|
||||||
session.sendPlayerBoolean(gameId, false);
|
if (message.getMessage().equals("Do you want to take a mulligan?")) {
|
||||||
} break;
|
session.sendPlayerBoolean(gameId, false);
|
||||||
}
|
}
|
||||||
case "gameSelect":
|
break;
|
||||||
{
|
}
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
case GAME_SELECT: {
|
||||||
log.info("Select: " + message.getMessage());
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
if (LoadPhaseManager.getInstance().isSkip(message.getGameView(), message.getMessage(), playerId)) {
|
log.info("Select: " + message.getMessage());
|
||||||
log.info("Skipped: " + message.getMessage());
|
if (LoadPhaseManager.getInstance().isSkip(message.getGameView(), message.getMessage(), playerId)) {
|
||||||
session.sendPlayerBoolean(gameId, false);
|
log.info("Skipped: " + message.getMessage());
|
||||||
} break;
|
session.sendPlayerBoolean(gameId, false);
|
||||||
}
|
}
|
||||||
case "gameOver":
|
break;
|
||||||
|
}
|
||||||
|
case GAME_OVER:
|
||||||
log.info("Game over");
|
log.info("Game over");
|
||||||
gameOver = true;
|
gameOver = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue