mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
GUI related improves:
* GUI: fixed that choose triggers/piles dialog doesn't close correctly before cast mode choose (#8225); * GUI: fixed that some choose dialogs doesn't update battlefield state (example: choose amount, choose mana); * Game: fixed duplicated json logs at the game's end;
This commit is contained in:
parent
f31781e4a4
commit
46081d9185
11 changed files with 212 additions and 171 deletions
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Dialog for choosing abilities.
|
||||
* GUI: Dialog for choosing abilities (list)
|
||||
*
|
||||
* @author nantuko, JayDi85
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.apache.log4j.Logger;
|
|||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
|
|
@ -38,6 +39,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
private MageDialog connectedDialog;
|
||||
private ChatPanelBasic connectedChatPanel;
|
||||
private int lastMessageId;
|
||||
private Map<String, Serializable> lastOptions = new HashMap<>();
|
||||
|
||||
private static final ScheduledExecutorService WORKER = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
|
|
@ -63,8 +65,8 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
private void setGUISize() {
|
||||
}
|
||||
|
||||
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options,
|
||||
int messageId, boolean gameNeedUserFeedback, TurnPhase gameTurnPhase) {
|
||||
public void prepareFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options,
|
||||
int messageId, boolean gameNeedUserFeedback, TurnPhase gameTurnPhase) {
|
||||
synchronized (this) {
|
||||
if (messageId < this.lastMessageId) {
|
||||
// if too many warning messages here then look at GAME_REDRAW_GUI event logic
|
||||
|
|
@ -72,13 +74,16 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
return;
|
||||
}
|
||||
this.lastMessageId = messageId;
|
||||
this.lastOptions = options;
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
this.helper.setBasicMessage(message);
|
||||
this.helper.setOriginalId(null); // reference to the feedback causing ability
|
||||
String lblText = addAdditionalText(message, options);
|
||||
this.helper.setTextArea(lblText);
|
||||
|
||||
this.mode = mode;
|
||||
|
||||
switch (this.mode) {
|
||||
case INFORM:
|
||||
setButtonState("", "", mode);
|
||||
|
|
@ -113,7 +118,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
requestFocusIfPossible();
|
||||
handleOptions(options);
|
||||
updateOptions(options);
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
|
|
@ -167,29 +172,35 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
WORKER.schedule(task, 8, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void handleOptions(Map<String, Serializable> options) {
|
||||
// clear already opened dialog (second request)
|
||||
if (connectedDialog != null) {
|
||||
connectedDialog.removeDialog();
|
||||
connectedDialog = null;
|
||||
}
|
||||
public void updateOptions(Map<String, Serializable> options) {
|
||||
this.lastOptions = options;
|
||||
|
||||
if (options != null) {
|
||||
if (options.containsKey("UI.left.btn.text")) {
|
||||
String text = (String) options.get("UI.left.btn.text");
|
||||
if (this.lastOptions != null) {
|
||||
if (this.lastOptions.containsKey("UI.left.btn.text")) {
|
||||
String text = (String) this.lastOptions.get("UI.left.btn.text");
|
||||
this.btnLeft.setText(text);
|
||||
this.helper.setLeft(text, !text.isEmpty());
|
||||
}
|
||||
if (options.containsKey("UI.right.btn.text")) {
|
||||
String text = (String) options.get("UI.right.btn.text");
|
||||
if (this.lastOptions.containsKey("UI.right.btn.text")) {
|
||||
String text = (String) this.lastOptions.get("UI.right.btn.text");
|
||||
this.btnRight.setText(text);
|
||||
this.helper.setRight(text, !text.isEmpty());
|
||||
}
|
||||
if (options.containsKey("dialog")) {
|
||||
connectedDialog = (MageDialog) options.get("dialog");
|
||||
}
|
||||
|
||||
updateConnectedDialog((MageDialog) this.lastOptions.getOrDefault("dialog", null));
|
||||
this.helper.autoSizeButtonsAndFeedbackState();
|
||||
} else {
|
||||
updateConnectedDialog(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConnectedDialog(MageDialog newDialog) {
|
||||
if (this.connectedDialog != null && this.connectedDialog != newDialog) {
|
||||
// remove old
|
||||
this.connectedDialog.removeDialog();
|
||||
}
|
||||
this.connectedDialog = newDialog;
|
||||
if (this.connectedDialog != null) {
|
||||
this.connectedDialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244,10 +255,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed
|
||||
if (connectedDialog != null) {
|
||||
connectedDialog.removeDialog();
|
||||
connectedDialog = null;
|
||||
}
|
||||
updateConnectedDialog(null);
|
||||
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
||||
SessionHandler.sendPlayerInteger(gameId, 0);
|
||||
} else if (mode == FeedbackMode.END) {
|
||||
|
|
|
|||
|
|
@ -274,8 +274,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
windowDialog.removeDialog();
|
||||
}
|
||||
|
||||
clearPickTargetDialogs();
|
||||
clearPickPileDialogs();
|
||||
clearPickDialogs();
|
||||
|
||||
Plugins.instance.getActionCallback().hideOpenComponents();
|
||||
try {
|
||||
|
|
@ -288,18 +287,41 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.bigCard = null;
|
||||
}
|
||||
|
||||
private void hidePickDialogs() {
|
||||
// temporary hide opened dialog on redraw/update
|
||||
|
||||
//try {
|
||||
// pick target
|
||||
for (ShowCardsDialog dialog : this.pickTarget) {
|
||||
dialog.setVisible(false);
|
||||
}
|
||||
// pick pile
|
||||
for (PickPileDialog dialog : this.pickPile) {
|
||||
dialog.setVisible(false);
|
||||
}
|
||||
//} catch (PropertyVetoException e) {
|
||||
// logger.error("Couldn't close pick dialog", e);
|
||||
//}
|
||||
}
|
||||
|
||||
private void clearPickDialogs() {
|
||||
// remove dialogs forever on clean or full update
|
||||
clearPickTargetDialogs();
|
||||
clearPickPileDialogs();
|
||||
}
|
||||
|
||||
private void clearPickTargetDialogs() {
|
||||
for (ShowCardsDialog pickTargetDialog : this.pickTarget) {
|
||||
pickTargetDialog.cleanUp();
|
||||
pickTargetDialog.removeDialog();
|
||||
for (ShowCardsDialog dialog : this.pickTarget) {
|
||||
dialog.cleanUp();
|
||||
dialog.removeDialog();
|
||||
}
|
||||
this.pickTarget.clear();
|
||||
}
|
||||
|
||||
private void clearPickPileDialogs() {
|
||||
for (PickPileDialog pickPileDialog : this.pickPile) {
|
||||
pickPileDialog.cleanUp();
|
||||
pickPileDialog.removeDialog();
|
||||
for (PickPileDialog dialog : this.pickPile) {
|
||||
dialog.cleanUp();
|
||||
dialog.removeDialog();
|
||||
}
|
||||
this.pickPile.clear();
|
||||
}
|
||||
|
|
@ -929,6 +951,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
feedbackPanel.disableUndo();
|
||||
feedbackPanel.updateOptions(lastGameData.options);
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
|
|
@ -1344,7 +1367,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
public void ask(String question, GameView gameView, int messageId, Map<String, Serializable> options) {
|
||||
updateGame(gameView, false, options, null);
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, false, options, messageId, true, gameView.getPhase());
|
||||
this.feedbackPanel.prepareFeedback(FeedbackMode.QUESTION, question, false, options, messageId, true, gameView.getPhase());
|
||||
}
|
||||
|
||||
private void keepLastGameData(GameView game, boolean showPlayable, Map<String, Serializable> options, Set<UUID> targets) {
|
||||
|
|
@ -1604,11 +1627,16 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
* @param options
|
||||
* @param messageId
|
||||
*/
|
||||
public void pickTarget(String message, CardsView cardsView, GameView gameView, Set<UUID> targets, boolean required, Map<String, Serializable> options, int messageId) {
|
||||
public void pickTarget(GameView gameView, Map<String, Serializable> options, String message, CardsView cardsView, Set<UUID> targets, boolean required, int messageId) {
|
||||
updateGame(gameView, false, options, targets);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
clearPickTargetDialogs();
|
||||
|
||||
PopUpMenuType popupMenuType = null;
|
||||
if (options != null) {
|
||||
if (lastGameData.options != null) {
|
||||
if (options.containsKey("queryType")) {
|
||||
PlayerQueryEvent.QueryType needType = (PlayerQueryEvent.QueryType) options.get("queryType");
|
||||
PlayerQueryEvent.QueryType needType = (PlayerQueryEvent.QueryType) lastGameData.options.get("queryType");
|
||||
switch (needType) {
|
||||
case PICK_ABILITY:
|
||||
popupMenuType = PopUpMenuType.TRIGGER_ORDER;
|
||||
|
|
@ -1622,17 +1650,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
updateGame(gameView, false, options, targets);
|
||||
|
||||
Map<String, Serializable> options0 = options == null ? new HashMap<>() : options;
|
||||
Map<String, Serializable> options0 = lastGameData.options == null ? new HashMap<>() : lastGameData.options;
|
||||
ShowCardsDialog dialog = null;
|
||||
if (cardsView != null && !cardsView.isEmpty()) {
|
||||
// clear old dialogs before the new
|
||||
clearPickTargetDialogs();
|
||||
dialog = showCards(message, cardsView, required, options0, popupMenuType);
|
||||
dialog = prepareCardsDialog(message, cardsView, required, options0, popupMenuType);
|
||||
options0.put("dialog", dialog);
|
||||
}
|
||||
this.feedbackPanel.getFeedback(required ? FeedbackMode.INFORM : FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId, true, gameView.getPhase());
|
||||
this.feedbackPanel.prepareFeedback(required ? FeedbackMode.INFORM : FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId, true, gameView.getPhase());
|
||||
if (dialog != null) {
|
||||
this.pickTarget.add(dialog);
|
||||
}
|
||||
|
|
@ -1640,15 +1664,23 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
public void inform(String information, GameView gameView, int messageId) {
|
||||
updateGame(gameView);
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.INFORM, information, gameView.getSpecial(), null, messageId, false, gameView.getPhase());
|
||||
this.feedbackPanel.prepareFeedback(FeedbackMode.INFORM, information, gameView.getSpecial(), null, messageId, false, gameView.getPhase());
|
||||
}
|
||||
|
||||
public void endMessage(String message, int messageId) {
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.END, message, false, null, messageId, true, null);
|
||||
public void endMessage(GameView gameView, Map<String, Serializable> options, String message, int messageId) {
|
||||
updateGame(gameView, false, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
|
||||
this.feedbackPanel.prepareFeedback(FeedbackMode.END, message, false, null, messageId, true, null);
|
||||
ArrowBuilder.getBuilder().removeAllArrows(gameId);
|
||||
}
|
||||
|
||||
public void select(String message, GameView gameView, int messageId, Map<String, Serializable> options) {
|
||||
public void select(GameView gameView, Map<String, Serializable> options, String message, int messageId) {
|
||||
updateGame(gameView, true, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
|
||||
this.abilityPicker.setVisible(false);
|
||||
|
||||
holdingPriority = false;
|
||||
|
|
@ -1659,8 +1691,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"),
|
||||
false);
|
||||
|
||||
updateGame(gameView, true, options, null);
|
||||
|
||||
boolean controllingPlayer = false;
|
||||
for (PlayerView playerView : gameView.getPlayers()) {
|
||||
if (playerView.getPlayerId().equals(playerId)) {
|
||||
|
|
@ -1675,8 +1705,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
}
|
||||
Map<String, Serializable> panelOptions = new HashMap<>();
|
||||
if (options != null) {
|
||||
panelOptions.putAll(options);
|
||||
if (lastGameData.options != null) {
|
||||
panelOptions.putAll(lastGameData.options);
|
||||
}
|
||||
panelOptions.put("your_turn", true);
|
||||
String activePlayerText;
|
||||
|
|
@ -1690,39 +1720,45 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
priorityPlayerText = " / priority " + gameView.getPriorityPlayerName();
|
||||
}
|
||||
String messageToDisplay = message + FeedbackPanel.getSmallText(activePlayerText + " / " + gameView.getStep().toString() + priorityPlayerText);
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId, true, gameView.getPhase());
|
||||
this.feedbackPanel.prepareFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId, true, gameView.getPhase());
|
||||
}
|
||||
|
||||
public void playMana(String message, GameView gameView, Map<String, Serializable> options, int messageId) {
|
||||
public void playMana(GameView gameView, Map<String, Serializable> options, String message, int messageId) {
|
||||
updateGame(gameView, true, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), options, messageId, true, gameView.getPhase());
|
||||
|
||||
this.feedbackPanel.prepareFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), options, messageId, true, gameView.getPhase());
|
||||
}
|
||||
|
||||
public void playXMana(String message, GameView gameView, int messageId) {
|
||||
updateGame(gameView, true, null, null);
|
||||
public void playXMana(GameView gameView, Map<String, Serializable> options, String message, int messageId) {
|
||||
updateGame(gameView, true, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null, messageId, true, gameView.getPhase());
|
||||
|
||||
this.feedbackPanel.prepareFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null, messageId, true, gameView.getPhase());
|
||||
}
|
||||
|
||||
public void replayMessage(String message) {
|
||||
//TODO: implement this
|
||||
}
|
||||
|
||||
public void pickAbility(AbilityPickerView choices) {
|
||||
public void pickAbility(GameView gameView, Map<String, Serializable> options, AbilityPickerView choices) {
|
||||
updateGame(gameView, false, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
|
||||
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
|
||||
}
|
||||
|
||||
private void hideAll() {
|
||||
hidePickDialogs();
|
||||
this.abilityPicker.setVisible(false);
|
||||
ActionCallback callback = Plugins.instance.getActionCallback();
|
||||
((MageActionCallback) callback).hideGameUpdate(gameId);
|
||||
}
|
||||
|
||||
private ShowCardsDialog showCards(String title, CardsView cards, boolean required, Map<String, Serializable> options, PopUpMenuType popupMenuType) {
|
||||
hideAll();
|
||||
private ShowCardsDialog prepareCardsDialog(String title, CardsView cards, boolean required, Map<String, Serializable> options, PopUpMenuType popupMenuType) {
|
||||
ShowCardsDialog showCards = new ShowCardsDialog();
|
||||
JPopupMenu popupMenu = null;
|
||||
if (PopUpMenuType.TRIGGER_ORDER == popupMenuType) {
|
||||
|
|
@ -1732,7 +1768,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
return showCards;
|
||||
}
|
||||
|
||||
public void getAmount(int min, int max, String message) {
|
||||
public void getAmount(GameView gameView, Map<String, Serializable> options, int min, int max, String message) {
|
||||
updateGame(gameView, false, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
|
||||
pickNumber.showDialog(min, max, message);
|
||||
if (pickNumber.isCancel()) {
|
||||
SessionHandler.sendPlayerBoolean(gameId, false);
|
||||
|
|
@ -1741,13 +1781,20 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public void getMultiAmount(List<String> messages, int min, int max, Map<String, Serializable> options) {
|
||||
pickMultiNumber.showDialog(messages, min, max, options);
|
||||
public void getMultiAmount(List<String> messages, GameView gameView, Map<String, Serializable> options, int min, int max) {
|
||||
updateGame(gameView, false, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
|
||||
pickMultiNumber.showDialog(messages, min, max, lastGameData.options);
|
||||
SessionHandler.sendPlayerString(gameId, pickMultiNumber.getMultiAmount());
|
||||
}
|
||||
|
||||
public void getChoice(Choice choice, UUID objectId) {
|
||||
public void getChoice(GameView gameView, Map<String, Serializable> options, Choice choice, UUID objectId) {
|
||||
updateGame(gameView, false, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
|
||||
// TODO: remember last choices and search incremental for same events?
|
||||
PickChoiceDialog pickChoice = new PickChoiceDialog();
|
||||
pickChoice.showDialog(choice, null, objectId, choiceWindowState, bigCard);
|
||||
|
|
@ -1769,8 +1816,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
pickChoice.removeDialog();
|
||||
}
|
||||
|
||||
public void pickPile(String message, CardsView pile1, CardsView pile2) {
|
||||
public void pickPile(GameView gameView, Map<String, Serializable> options, String message, CardsView pile1, CardsView pile2) {
|
||||
updateGame(gameView, false, options, null);
|
||||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
|
||||
// remove old dialogs before the new
|
||||
clearPickPileDialogs();
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
case REPLAY_DONE: {
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
||||
panel.endMessage(null, null, (String) callback.getData(), callback.getMessageId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -180,16 +180,17 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
|
||||
case GAME_OVER: {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
Session session = SessionHandler.getSession();
|
||||
if (session.isJsonLogActive()) {
|
||||
appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
|
||||
ActionData actionData = appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
|
||||
String logFileName = "game-" + actionData.gameId + ".json";
|
||||
S3Uploader.upload(logFileName, actionData.gameId.toString());
|
||||
UUID gameId = callback.getObjectId();
|
||||
appendJsonEvent("GAME_OVER", callback.getObjectId(), message);
|
||||
String logFileName = "game-" + gameId + ".json";
|
||||
S3Uploader.upload(logFileName, gameId.toString());
|
||||
}
|
||||
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
||||
panel.endMessage(message.getGameView(), message.getOptions(), message.getMessage(), callback.getMessageId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -209,35 +210,34 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
break;
|
||||
}
|
||||
|
||||
case GAME_TARGET: // e.g. Pick triggered ability
|
||||
{
|
||||
case GAME_TARGET: {
|
||||
// e.g. Pick triggered ability
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_TARGET", callback.getObjectId(), message);
|
||||
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(),
|
||||
message.getTargets(), message.isFlag(), message.getOptions(), callback.getMessageId());
|
||||
panel.pickTarget(message.getGameView(), message.getOptions(), message.getMessage(),
|
||||
message.getCardsView1(), message.getTargets(), message.isFlag(), callback.getMessageId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_SELECT: {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_SELECT", callback.getObjectId(), message);
|
||||
panel.select(message.getMessage(), message.getGameView(), callback.getMessageId(), message.getOptions());
|
||||
panel.select(message.getGameView(), message.getOptions(), message.getMessage(), callback.getMessageId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_CHOOSE_ABILITY: {
|
||||
AbilityPickerView abilityPickerView = (AbilityPickerView) callback.getData();
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_CHOOSE_ABILITY", callback.getObjectId(), callback.getData());
|
||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
||||
panel.pickAbility(abilityPickerView.getGameView(), null, abilityPickerView);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -247,19 +247,17 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_CHOOSE_PILE", callback.getObjectId(), message);
|
||||
panel.pickPile(message.getMessage(), message.getPile1(), message.getPile2());
|
||||
panel.pickPile(message.getGameView(), message.getOptions(), message.getMessage(), message.getCardsView1(), message.getCardsView2());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_CHOOSE_CHOICE: {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_CHOOSE_CHOICE", callback.getObjectId(), message);
|
||||
panel.getChoice(message.getChoice(), callback.getObjectId());
|
||||
panel.getChoice(message.getGameView(), message.getOptions(), message.getChoice(), callback.getObjectId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -269,53 +267,48 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_PLAY_MANA", callback.getObjectId(), message);
|
||||
panel.playMana(message.getMessage(), message.getGameView(), message.getOptions(), callback.getMessageId());
|
||||
panel.playMana(message.getGameView(), message.getOptions(), message.getMessage(), callback.getMessageId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_PLAY_XMANA: {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_PLAY_XMANA", callback.getObjectId(), message);
|
||||
panel.playXMana(message.getMessage(), message.getGameView(), callback.getMessageId());
|
||||
panel.playXMana(message.getGameView(), message.getOptions(), message.getMessage(), callback.getMessageId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_GET_AMOUNT: {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_GET_AMOUNT", callback.getObjectId(), message);
|
||||
|
||||
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
|
||||
panel.getAmount(message.getGameView(), message.getOptions(), message.getMin(), message.getMax(), message.getMessage());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_GET_MULTI_AMOUNT: {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_GET_MULTI_AMOUNT", callback.getObjectId(), message);
|
||||
|
||||
panel.getMultiAmount(message.getMessages(), message.getMin(), message.getMax(), message.getOptions());
|
||||
panel.getMultiAmount(message.getMessages(), message.getGameView(), message.getOptions(), message.getMin(), message.getMax());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GAME_UPDATE: {
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_UPDATE", callback.getObjectId(), callback.getData());
|
||||
|
||||
panel.updateGame((GameView) callback.getData(), true, null, null); // update after undo
|
||||
panel.updateGame((GameView) callback.getData(), true, null, null); // update after undo wtf?!
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -325,6 +318,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
// uses for client side only (example: update after scrollbars support)
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
logger.info("redraw");
|
||||
panel.updateGame();
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue