mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00: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.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog for choosing abilities.
|
* GUI: Dialog for choosing abilities (list)
|
||||||
*
|
*
|
||||||
* @author nantuko, JayDi85
|
* @author nantuko, JayDi85
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.apache.log4j.Logger;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
@ -38,6 +39,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
private MageDialog connectedDialog;
|
private MageDialog connectedDialog;
|
||||||
private ChatPanelBasic connectedChatPanel;
|
private ChatPanelBasic connectedChatPanel;
|
||||||
private int lastMessageId;
|
private int lastMessageId;
|
||||||
|
private Map<String, Serializable> lastOptions = new HashMap<>();
|
||||||
|
|
||||||
private static final ScheduledExecutorService WORKER = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService WORKER = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
|
||||||
|
@ -63,7 +65,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
private void setGUISize() {
|
private void setGUISize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options,
|
public void prepareFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options,
|
||||||
int messageId, boolean gameNeedUserFeedback, TurnPhase gameTurnPhase) {
|
int messageId, boolean gameNeedUserFeedback, TurnPhase gameTurnPhase) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (messageId < this.lastMessageId) {
|
if (messageId < this.lastMessageId) {
|
||||||
|
@ -72,13 +74,16 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.lastMessageId = messageId;
|
this.lastMessageId = messageId;
|
||||||
|
this.lastOptions = options;
|
||||||
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.helper.setBasicMessage(message);
|
this.helper.setBasicMessage(message);
|
||||||
this.helper.setOriginalId(null); // reference to the feedback causing ability
|
this.helper.setOriginalId(null); // reference to the feedback causing ability
|
||||||
String lblText = addAdditionalText(message, options);
|
String lblText = addAdditionalText(message, options);
|
||||||
this.helper.setTextArea(lblText);
|
this.helper.setTextArea(lblText);
|
||||||
|
|
||||||
this.mode = mode;
|
|
||||||
switch (this.mode) {
|
switch (this.mode) {
|
||||||
case INFORM:
|
case INFORM:
|
||||||
setButtonState("", "", mode);
|
setButtonState("", "", mode);
|
||||||
|
@ -113,7 +118,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
requestFocusIfPossible();
|
requestFocusIfPossible();
|
||||||
handleOptions(options);
|
updateOptions(options);
|
||||||
|
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
this.repaint();
|
this.repaint();
|
||||||
|
@ -167,29 +172,35 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
WORKER.schedule(task, 8, TimeUnit.SECONDS);
|
WORKER.schedule(task, 8, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleOptions(Map<String, Serializable> options) {
|
public void updateOptions(Map<String, Serializable> options) {
|
||||||
// clear already opened dialog (second request)
|
this.lastOptions = options;
|
||||||
if (connectedDialog != null) {
|
|
||||||
connectedDialog.removeDialog();
|
|
||||||
connectedDialog = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options != null) {
|
if (this.lastOptions != null) {
|
||||||
if (options.containsKey("UI.left.btn.text")) {
|
if (this.lastOptions.containsKey("UI.left.btn.text")) {
|
||||||
String text = (String) options.get("UI.left.btn.text");
|
String text = (String) this.lastOptions.get("UI.left.btn.text");
|
||||||
this.btnLeft.setText(text);
|
this.btnLeft.setText(text);
|
||||||
this.helper.setLeft(text, !text.isEmpty());
|
this.helper.setLeft(text, !text.isEmpty());
|
||||||
}
|
}
|
||||||
if (options.containsKey("UI.right.btn.text")) {
|
if (this.lastOptions.containsKey("UI.right.btn.text")) {
|
||||||
String text = (String) options.get("UI.right.btn.text");
|
String text = (String) this.lastOptions.get("UI.right.btn.text");
|
||||||
this.btnRight.setText(text);
|
this.btnRight.setText(text);
|
||||||
this.helper.setRight(text, !text.isEmpty());
|
this.helper.setRight(text, !text.isEmpty());
|
||||||
}
|
}
|
||||||
if (options.containsKey("dialog")) {
|
updateConnectedDialog((MageDialog) this.lastOptions.getOrDefault("dialog", null));
|
||||||
connectedDialog = (MageDialog) options.get("dialog");
|
this.helper.autoSizeButtonsAndFeedbackState();
|
||||||
|
} else {
|
||||||
|
updateConnectedDialog(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.helper.autoSizeButtonsAndFeedbackState();
|
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
|
private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed
|
||||||
if (connectedDialog != null) {
|
updateConnectedDialog(null);
|
||||||
connectedDialog.removeDialog();
|
|
||||||
connectedDialog = null;
|
|
||||||
}
|
|
||||||
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
||||||
SessionHandler.sendPlayerInteger(gameId, 0);
|
SessionHandler.sendPlayerInteger(gameId, 0);
|
||||||
} else if (mode == FeedbackMode.END) {
|
} else if (mode == FeedbackMode.END) {
|
||||||
|
|
|
@ -274,8 +274,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
windowDialog.removeDialog();
|
windowDialog.removeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearPickTargetDialogs();
|
clearPickDialogs();
|
||||||
clearPickPileDialogs();
|
|
||||||
|
|
||||||
Plugins.instance.getActionCallback().hideOpenComponents();
|
Plugins.instance.getActionCallback().hideOpenComponents();
|
||||||
try {
|
try {
|
||||||
|
@ -288,18 +287,41 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.bigCard = null;
|
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() {
|
private void clearPickTargetDialogs() {
|
||||||
for (ShowCardsDialog pickTargetDialog : this.pickTarget) {
|
for (ShowCardsDialog dialog : this.pickTarget) {
|
||||||
pickTargetDialog.cleanUp();
|
dialog.cleanUp();
|
||||||
pickTargetDialog.removeDialog();
|
dialog.removeDialog();
|
||||||
}
|
}
|
||||||
this.pickTarget.clear();
|
this.pickTarget.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearPickPileDialogs() {
|
private void clearPickPileDialogs() {
|
||||||
for (PickPileDialog pickPileDialog : this.pickPile) {
|
for (PickPileDialog dialog : this.pickPile) {
|
||||||
pickPileDialog.cleanUp();
|
dialog.cleanUp();
|
||||||
pickPileDialog.removeDialog();
|
dialog.removeDialog();
|
||||||
}
|
}
|
||||||
this.pickPile.clear();
|
this.pickPile.clear();
|
||||||
}
|
}
|
||||||
|
@ -929,6 +951,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
feedbackPanel.disableUndo();
|
feedbackPanel.disableUndo();
|
||||||
|
feedbackPanel.updateOptions(lastGameData.options);
|
||||||
|
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
this.repaint();
|
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) {
|
public void ask(String question, GameView gameView, int messageId, Map<String, Serializable> options) {
|
||||||
updateGame(gameView, false, options, null);
|
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) {
|
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 options
|
||||||
* @param messageId
|
* @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;
|
PopUpMenuType popupMenuType = null;
|
||||||
if (options != null) {
|
if (lastGameData.options != null) {
|
||||||
if (options.containsKey("queryType")) {
|
if (options.containsKey("queryType")) {
|
||||||
PlayerQueryEvent.QueryType needType = (PlayerQueryEvent.QueryType) options.get("queryType");
|
PlayerQueryEvent.QueryType needType = (PlayerQueryEvent.QueryType) lastGameData.options.get("queryType");
|
||||||
switch (needType) {
|
switch (needType) {
|
||||||
case PICK_ABILITY:
|
case PICK_ABILITY:
|
||||||
popupMenuType = PopUpMenuType.TRIGGER_ORDER;
|
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 = lastGameData.options == null ? new HashMap<>() : lastGameData.options;
|
||||||
|
|
||||||
Map<String, Serializable> options0 = options == null ? new HashMap<>() : options;
|
|
||||||
ShowCardsDialog dialog = null;
|
ShowCardsDialog dialog = null;
|
||||||
if (cardsView != null && !cardsView.isEmpty()) {
|
if (cardsView != null && !cardsView.isEmpty()) {
|
||||||
// clear old dialogs before the new
|
dialog = prepareCardsDialog(message, cardsView, required, options0, popupMenuType);
|
||||||
clearPickTargetDialogs();
|
|
||||||
dialog = showCards(message, cardsView, required, options0, popupMenuType);
|
|
||||||
options0.put("dialog", dialog);
|
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) {
|
if (dialog != null) {
|
||||||
this.pickTarget.add(dialog);
|
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) {
|
public void inform(String information, GameView gameView, int messageId) {
|
||||||
updateGame(gameView);
|
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) {
|
public void endMessage(GameView gameView, Map<String, Serializable> options, String message, int messageId) {
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.END, message, false, null, messageId, true, null);
|
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);
|
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);
|
this.abilityPicker.setVisible(false);
|
||||||
|
|
||||||
holdingPriority = 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"),
|
PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
updateGame(gameView, true, options, null);
|
|
||||||
|
|
||||||
boolean controllingPlayer = false;
|
boolean controllingPlayer = false;
|
||||||
for (PlayerView playerView : gameView.getPlayers()) {
|
for (PlayerView playerView : gameView.getPlayers()) {
|
||||||
if (playerView.getPlayerId().equals(playerId)) {
|
if (playerView.getPlayerId().equals(playerId)) {
|
||||||
|
@ -1675,8 +1705,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
Map<String, Serializable> panelOptions = new HashMap<>();
|
Map<String, Serializable> panelOptions = new HashMap<>();
|
||||||
if (options != null) {
|
if (lastGameData.options != null) {
|
||||||
panelOptions.putAll(options);
|
panelOptions.putAll(lastGameData.options);
|
||||||
}
|
}
|
||||||
panelOptions.put("your_turn", true);
|
panelOptions.put("your_turn", true);
|
||||||
String activePlayerText;
|
String activePlayerText;
|
||||||
|
@ -1690,39 +1720,45 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
priorityPlayerText = " / priority " + gameView.getPriorityPlayerName();
|
priorityPlayerText = " / priority " + gameView.getPriorityPlayerName();
|
||||||
}
|
}
|
||||||
String messageToDisplay = message + FeedbackPanel.getSmallText(activePlayerText + " / " + gameView.getStep().toString() + priorityPlayerText);
|
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);
|
updateGame(gameView, true, options, null);
|
||||||
|
hideAll();
|
||||||
DialogManager.getManager(gameId).fadeOut();
|
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) {
|
public void playXMana(GameView gameView, Map<String, Serializable> options, String message, int messageId) {
|
||||||
updateGame(gameView, true, null, null);
|
updateGame(gameView, true, options, null);
|
||||||
|
hideAll();
|
||||||
DialogManager.getManager(gameId).fadeOut();
|
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) {
|
public void replayMessage(String message) {
|
||||||
//TODO: implement this
|
//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();
|
hideAll();
|
||||||
DialogManager.getManager(gameId).fadeOut();
|
DialogManager.getManager(gameId).fadeOut();
|
||||||
|
|
||||||
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
|
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideAll() {
|
private void hideAll() {
|
||||||
|
hidePickDialogs();
|
||||||
this.abilityPicker.setVisible(false);
|
this.abilityPicker.setVisible(false);
|
||||||
ActionCallback callback = Plugins.instance.getActionCallback();
|
ActionCallback callback = Plugins.instance.getActionCallback();
|
||||||
((MageActionCallback) callback).hideGameUpdate(gameId);
|
((MageActionCallback) callback).hideGameUpdate(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShowCardsDialog showCards(String title, CardsView cards, boolean required, Map<String, Serializable> options, PopUpMenuType popupMenuType) {
|
private ShowCardsDialog prepareCardsDialog(String title, CardsView cards, boolean required, Map<String, Serializable> options, PopUpMenuType popupMenuType) {
|
||||||
hideAll();
|
|
||||||
ShowCardsDialog showCards = new ShowCardsDialog();
|
ShowCardsDialog showCards = new ShowCardsDialog();
|
||||||
JPopupMenu popupMenu = null;
|
JPopupMenu popupMenu = null;
|
||||||
if (PopUpMenuType.TRIGGER_ORDER == popupMenuType) {
|
if (PopUpMenuType.TRIGGER_ORDER == popupMenuType) {
|
||||||
|
@ -1732,7 +1768,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
return showCards;
|
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);
|
pickNumber.showDialog(min, max, message);
|
||||||
if (pickNumber.isCancel()) {
|
if (pickNumber.isCancel()) {
|
||||||
SessionHandler.sendPlayerBoolean(gameId, false);
|
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) {
|
public void getMultiAmount(List<String> messages, GameView gameView, Map<String, Serializable> options, int min, int max) {
|
||||||
pickMultiNumber.showDialog(messages, min, max, options);
|
updateGame(gameView, false, options, null);
|
||||||
|
hideAll();
|
||||||
|
DialogManager.getManager(gameId).fadeOut();
|
||||||
|
|
||||||
|
pickMultiNumber.showDialog(messages, min, max, lastGameData.options);
|
||||||
SessionHandler.sendPlayerString(gameId, pickMultiNumber.getMultiAmount());
|
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();
|
hideAll();
|
||||||
|
DialogManager.getManager(gameId).fadeOut();
|
||||||
|
|
||||||
// TODO: remember last choices and search incremental for same events?
|
// TODO: remember last choices and search incremental for same events?
|
||||||
PickChoiceDialog pickChoice = new PickChoiceDialog();
|
PickChoiceDialog pickChoice = new PickChoiceDialog();
|
||||||
pickChoice.showDialog(choice, null, objectId, choiceWindowState, bigCard);
|
pickChoice.showDialog(choice, null, objectId, choiceWindowState, bigCard);
|
||||||
|
@ -1769,8 +1816,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pickChoice.removeDialog();
|
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();
|
hideAll();
|
||||||
|
DialogManager.getManager(gameId).fadeOut();
|
||||||
|
|
||||||
// remove old dialogs before the new
|
// remove old dialogs before the new
|
||||||
clearPickPileDialogs();
|
clearPickPileDialogs();
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
case REPLAY_DONE: {
|
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(null, null, (String) callback.getData(), callback.getMessageId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -180,16 +180,17 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_OVER: {
|
case GAME_OVER: {
|
||||||
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
Session session = SessionHandler.getSession();
|
Session session = SessionHandler.getSession();
|
||||||
if (session.isJsonLogActive()) {
|
if (session.isJsonLogActive()) {
|
||||||
appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
|
UUID gameId = callback.getObjectId();
|
||||||
ActionData actionData = appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
|
appendJsonEvent("GAME_OVER", callback.getObjectId(), message);
|
||||||
String logFileName = "game-" + actionData.gameId + ".json";
|
String logFileName = "game-" + gameId + ".json";
|
||||||
S3Uploader.upload(logFileName, actionData.gameId.toString());
|
S3Uploader.upload(logFileName, gameId.toString());
|
||||||
}
|
}
|
||||||
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
panel.endMessage(message.getGameView(), message.getOptions(), message.getMessage(), callback.getMessageId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -209,35 +210,34 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_TARGET: // 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());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
appendJsonEvent("GAME_TARGET", callback.getObjectId(), message);
|
appendJsonEvent("GAME_TARGET", callback.getObjectId(), message);
|
||||||
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(),
|
panel.pickTarget(message.getGameView(), message.getOptions(), message.getMessage(),
|
||||||
message.getTargets(), message.isFlag(), message.getOptions(), callback.getMessageId());
|
message.getCardsView1(), message.getTargets(), message.isFlag(), callback.getMessageId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_SELECT: {
|
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) {
|
||||||
appendJsonEvent("GAME_SELECT", callback.getObjectId(), message);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_CHOOSE_ABILITY: {
|
case GAME_CHOOSE_ABILITY: {
|
||||||
|
AbilityPickerView abilityPickerView = (AbilityPickerView) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
appendJsonEvent("GAME_CHOOSE_ABILITY", callback.getObjectId(), callback.getData());
|
appendJsonEvent("GAME_CHOOSE_ABILITY", callback.getObjectId(), callback.getData());
|
||||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
panel.pickAbility(abilityPickerView.getGameView(), null, abilityPickerView);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -247,19 +247,17 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
appendJsonEvent("GAME_CHOOSE_PILE", callback.getObjectId(), message);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_CHOOSE_CHOICE: {
|
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());
|
||||||
|
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
appendJsonEvent("GAME_CHOOSE_CHOICE", callback.getObjectId(), message);
|
appendJsonEvent("GAME_CHOOSE_CHOICE", callback.getObjectId(), message);
|
||||||
panel.getChoice(message.getChoice(), callback.getObjectId());
|
panel.getChoice(message.getGameView(), message.getOptions(), message.getChoice(), callback.getObjectId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -269,53 +267,48 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
appendJsonEvent("GAME_PLAY_MANA", callback.getObjectId(), message);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_PLAY_XMANA: {
|
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) {
|
||||||
appendJsonEvent("GAME_PLAY_XMANA", callback.getObjectId(), message);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_GET_AMOUNT: {
|
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) {
|
||||||
appendJsonEvent("GAME_GET_AMOUNT", callback.getObjectId(), message);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_GET_MULTI_AMOUNT: {
|
case GAME_GET_MULTI_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) {
|
||||||
appendJsonEvent("GAME_GET_MULTI_AMOUNT", callback.getObjectId(), message);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GAME_UPDATE: {
|
case GAME_UPDATE: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
|
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
appendJsonEvent("GAME_UPDATE", callback.getObjectId(), callback.getData());
|
appendJsonEvent("GAME_UPDATE", callback.getObjectId(), callback.getData());
|
||||||
|
panel.updateGame((GameView) callback.getData(), true, null, null); // update after undo wtf?!
|
||||||
panel.updateGame((GameView) callback.getData(), true, null, null); // update after undo
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -325,6 +318,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
// uses for client side only (example: update after scrollbars support)
|
// uses for client side only (example: update after scrollbars support)
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
logger.info("redraw");
|
||||||
panel.updateGame();
|
panel.updateGame();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,9 +17,11 @@ public class AbilityPickerView implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Map<UUID, String> choices = new LinkedHashMap<>();
|
private Map<UUID, String> choices = new LinkedHashMap<>();
|
||||||
private String message = null;
|
private String message;
|
||||||
|
private GameView gameView;
|
||||||
|
|
||||||
public AbilityPickerView(String objectName, List<? extends Ability> abilities, String message) {
|
public AbilityPickerView(GameView gameView, String objectName, List<? extends Ability> abilities, String message) {
|
||||||
|
this.gameView = gameView;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
@ -44,6 +46,12 @@ public class AbilityPickerView implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbilityPickerView(GameView gameView, Map<UUID, String> modes, String message) {
|
||||||
|
this.gameView = gameView;
|
||||||
|
this.choices = modes;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
private String getAbilityRules(Ability ability, String objectName) {
|
private String getAbilityRules(Ability ability, String objectName) {
|
||||||
String rule = ability.getRule(objectName);
|
String rule = ability.getRule(objectName);
|
||||||
if (rule.isEmpty()) {
|
if (rule.isEmpty()) {
|
||||||
|
@ -55,11 +63,6 @@ public class AbilityPickerView implements Serializable {
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbilityPickerView(Map<UUID, String> modes, String message) {
|
|
||||||
this.choices = modes;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<UUID, String> getChoices() {
|
public Map<UUID, String> getChoices() {
|
||||||
return choices;
|
return choices;
|
||||||
}
|
}
|
||||||
|
@ -67,4 +70,8 @@ public class AbilityPickerView implements Serializable {
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameView getGameView() {
|
||||||
|
return gameView;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class GameClientMessage implements Serializable {
|
||||||
@Expose
|
@Expose
|
||||||
private GameView gameView;
|
private GameView gameView;
|
||||||
@Expose
|
@Expose
|
||||||
private CardsView cardsView;
|
private CardsView cardsView1;
|
||||||
@Expose
|
@Expose
|
||||||
private CardsView cardsView2;
|
private CardsView cardsView2;
|
||||||
@Expose
|
@Expose
|
||||||
|
@ -32,8 +32,6 @@ public class GameClientMessage implements Serializable {
|
||||||
@Expose
|
@Expose
|
||||||
private boolean flag;
|
private boolean flag;
|
||||||
@Expose
|
@Expose
|
||||||
private String[] strings;
|
|
||||||
@Expose
|
|
||||||
private Set<UUID> targets;
|
private Set<UUID> targets;
|
||||||
@Expose
|
@Expose
|
||||||
private int min;
|
private int min;
|
||||||
|
@ -46,64 +44,53 @@ public class GameClientMessage implements Serializable {
|
||||||
@Expose
|
@Expose
|
||||||
private List<String> messages;
|
private List<String> messages;
|
||||||
|
|
||||||
public GameClientMessage(GameView gameView) {
|
public GameClientMessage(GameView gameView, Map<String, Serializable> options) {
|
||||||
this.gameView = gameView;
|
this.gameView = gameView;
|
||||||
}
|
|
||||||
|
|
||||||
public GameClientMessage(GameView gameView, String message) {
|
|
||||||
this.gameView = gameView;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameClientMessage(GameView gameView, String message, Map<String, Serializable> options) {
|
|
||||||
this.gameView = gameView;
|
|
||||||
this.message = message;
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required) {
|
public GameClientMessage(GameView gameView, Map<String, Serializable> options, String message) {
|
||||||
this.gameView = gameView;
|
this.gameView = gameView;
|
||||||
this.message = question;
|
this.options = options;
|
||||||
this.cardsView = cardView;
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameClientMessage(GameView gameView, Map<String, Serializable> options, String message, CardsView cardsView1, Set<UUID> targets, boolean required) {
|
||||||
|
this.gameView = gameView;
|
||||||
|
this.options = options;
|
||||||
|
this.message = message;
|
||||||
|
this.cardsView1 = cardsView1;
|
||||||
this.targets = targets;
|
this.targets = targets;
|
||||||
this.flag = required;
|
this.flag = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
public GameClientMessage(GameView gameView, Map<String, Serializable> options, String message, int min, int max) {
|
||||||
this(gameView, question, cardView, targets, required);
|
this.gameView = gameView;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
|
||||||
|
|
||||||
public GameClientMessage(String[] choices, String message) {
|
|
||||||
this.strings = choices;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameClientMessage(String message, int min, int max) {
|
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameClientMessage(String message, CardsView pile1, CardsView pile2) {
|
public GameClientMessage(GameView gameView, Map<String, Serializable> options, String message, CardsView pile1, CardsView pile2) {
|
||||||
|
this.gameView = gameView;
|
||||||
|
this.options = options;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.cardsView = pile1;
|
this.cardsView1 = pile1;
|
||||||
this.cardsView2 = pile2;
|
this.cardsView2 = pile2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameClientMessage(CardsView cardView, String name) {
|
public GameClientMessage(GameView gameView, Map<String, Serializable> options, List<String> messages, int min, int max) {
|
||||||
this.cardsView = cardView;
|
this.gameView = gameView;
|
||||||
this.message = name;
|
this.options = options;
|
||||||
}
|
|
||||||
|
|
||||||
public GameClientMessage(List<String> messages, int min, int max, Map<String, Serializable> options) {
|
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.options = options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameClientMessage(Choice choice) {
|
public GameClientMessage(GameView gameView, Map<String, Serializable> options, Choice choice) {
|
||||||
|
this.gameView = gameView;
|
||||||
|
this.options = options;
|
||||||
this.choice = choice;
|
this.choice = choice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +98,12 @@ public class GameClientMessage implements Serializable {
|
||||||
return gameView;
|
return gameView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardsView getCardsView() {
|
public CardsView getCardsView1() {
|
||||||
return cardsView;
|
return cardsView1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardsView getCardsView2() {
|
||||||
|
return cardsView2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
|
@ -123,22 +114,10 @@ public class GameClientMessage implements Serializable {
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getStrings() {
|
|
||||||
return strings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<UUID> getTargets() {
|
public Set<UUID> getTargets() {
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardsView getPile1() {
|
|
||||||
return cardsView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CardsView getPile2() {
|
|
||||||
return cardsView2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMin() {
|
public int getMin() {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
|
@ -810,7 +810,7 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void chooseAbility(UUID playerId, final String objectName, final List<? extends Ability> choices, String message) throws MageException {
|
private synchronized void chooseAbility(UUID playerId, final String objectName, final List<? extends Ability> choices, String message) throws MageException {
|
||||||
perform(playerId, playerId1 -> getGameSession(playerId1).chooseAbility(new AbilityPickerView(objectName, choices, message)));
|
perform(playerId, playerId1 -> getGameSession(playerId1).chooseAbility(new AbilityPickerView(getGameView(playerId), objectName, choices, message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void choosePile(UUID playerId, final String message, final List<? extends Card> pile1, final List<? extends Card> pile2) throws MageException {
|
private synchronized void choosePile(UUID playerId, final String message, final List<? extends Card> pile1, final List<? extends Card> pile2) throws MageException {
|
||||||
|
@ -818,7 +818,7 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void chooseMode(UUID playerId, final Map<UUID, String> modes, final String message) throws MageException {
|
private synchronized void chooseMode(UUID playerId, final Map<UUID, String> modes, final String message) throws MageException {
|
||||||
perform(playerId, playerId1 -> getGameSession(playerId1).chooseAbility(new AbilityPickerView(modes, message)));
|
perform(playerId, playerId1 -> getGameSession(playerId1).chooseAbility(new AbilityPickerView(getGameView(playerId), modes, message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void chooseChoice(UUID playerId, final Choice choice) throws MageException {
|
private synchronized void chooseChoice(UUID playerId, final Choice choice) throws MageException {
|
||||||
|
|
|
@ -47,7 +47,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.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ASK, game.getId(), new GameClientMessage(getGameView(), question, options)))
|
userManager.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ASK, game.getId(), new GameClientMessage(getGameView(), options, question)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,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.getUser(userId).ifPresent(user -> {
|
userManager.getUser(userId).ifPresent(user -> {
|
||||||
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_TARGET, game.getId(), new GameClientMessage(getGameView(), question, cardView, targets, required, options)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_TARGET, game.getId(), new GameClientMessage(getGameView(), options, question, cardView, targets, required)));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ 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.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_SELECT, game.getId(), new GameClientMessage(getGameView(), message, options))));
|
userManager.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_SELECT, game.getId(), new GameClientMessage(getGameView(), options, message))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,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.getUser(userId).ifPresent(user
|
userManager.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_PILE, game.getId(), new GameClientMessage(message, pile1, pile2))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_PILE, game.getId(), new GameClientMessage(getGameView(), null, message, pile1, pile2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void chooseChoice(final Choice choice) {
|
public void chooseChoice(final Choice choice) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
userManager.getUser(userId).ifPresent(user
|
userManager.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_CHOICE, game.getId(), new GameClientMessage(choice))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_CHOICE, game.getId(), new GameClientMessage(getGameView(), null, choice))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,14 +94,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.getUser(userId).ifPresent(user
|
userManager.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_MANA, game.getId(), new GameClientMessage(getGameView(), message, options))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_MANA, game.getId(), new GameClientMessage(getGameView(), options, message))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playXMana(final String message) {
|
public void playXMana(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
userManager.getUser(userId).ifPresent(user
|
userManager.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_XMANA, game.getId(), new GameClientMessage(getGameView(), message))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_XMANA, game.getId(), new GameClientMessage(getGameView(), null, message))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ 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.getUser(userId).ifPresent(user -> {
|
userManager.getUser(userId).ifPresent(user -> {
|
||||||
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_GET_AMOUNT, game.getId(), new GameClientMessage(message, min, max)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_GET_AMOUNT, game.getId(), new GameClientMessage(getGameView(), null, message, min, max)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void getMultiAmount(final List<String> messages, final int min, final int max, final Map<String, Serializable> options) {
|
public void getMultiAmount(final List<String> messages, final int min, final int max, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
userManager.getUser(userId).ifPresent(user
|
userManager.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_GET_MULTI_AMOUNT, game.getId(), new GameClientMessage(messages, min, max, options))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_GET_MULTI_AMOUNT, game.getId(), new GameClientMessage(getGameView(), options, messages, min, max))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,14 +58,14 @@ public class GameSessionWatcher {
|
||||||
|
|
||||||
public void inform(final String message) {
|
public void inform(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
userManager.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM, game.getId(), new GameClientMessage(getGameView(), message))));
|
userManager.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM, game.getId(), new GameClientMessage(getGameView(), null, message))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void informPersonal(final String message) {
|
public void informPersonal(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
userManager.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM_PERSONAL, game.getId(), new GameClientMessage(getGameView(), message))));
|
userManager.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM_PERSONAL, game.getId(), new GameClientMessage(getGameView(), null, message))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class GameSessionWatcher {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
userManager.getUser(userId).ifPresent(user -> {
|
userManager.getUser(userId).ifPresent(user -> {
|
||||||
user.removeGameWatchInfo(game.getId());
|
user.removeGameWatchInfo(game.getId());
|
||||||
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_OVER, game.getId(), message));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_OVER, game.getId(), new GameClientMessage(getGameView(), null, message)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,6 @@ public class GameSessionWatcher {
|
||||||
public void gameError(final String message) {
|
public void gameError(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
userManager.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ERROR, game.getId(), message)));
|
userManager.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ERROR, game.getId(), message)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import mage.cards.repository.CardRepository;
|
||||||
import mage.game.permanent.PermanentCard;
|
import mage.game.permanent.PermanentCard;
|
||||||
import mage.game.permanent.PermanentImpl;
|
import mage.game.permanent.PermanentImpl;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.AbilityPickerView;
|
||||||
|
import mage.view.GameView;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
@ -16,13 +17,17 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
*/
|
*/
|
||||||
public class AbilityPickerTest extends CardTestPlayerBase {
|
public class AbilityPickerTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
private GameView prepareGameView() {
|
||||||
|
return new GameView(currentGame.getState(), currentGame, playerA.getId(), null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_PickerChoices_FusedSpells() {
|
public void test_PickerChoices_FusedSpells() {
|
||||||
// must be 3 spells for choices
|
// must be 3 spells for choices
|
||||||
Abilities<Ability> abilities = getAbilitiesFromCard("Armed // Dangerous");
|
Abilities<Ability> abilities = getAbilitiesFromCard("Armed // Dangerous");
|
||||||
Assert.assertEquals(3, abilities.size());
|
Assert.assertEquals(3, abilities.size());
|
||||||
|
|
||||||
AbilityPickerView view = new AbilityPickerView("test name", abilities, "test message");
|
AbilityPickerView view = new AbilityPickerView(prepareGameView(), "test name", abilities, "test message");
|
||||||
Assert.assertEquals(3, view.getChoices().size());
|
Assert.assertEquals(3, view.getChoices().size());
|
||||||
view.getChoices().values().forEach(c -> {
|
view.getChoices().values().forEach(c -> {
|
||||||
Assert.assertTrue("Must start with Cast text, but found: " + c, c.contains("Cast "));
|
Assert.assertTrue("Must start with Cast text, but found: " + c, c.contains("Cast "));
|
||||||
|
@ -35,7 +40,7 @@ public class AbilityPickerTest extends CardTestPlayerBase {
|
||||||
Abilities<Ability> abilities = getAbilitiesFromCard("Foulmire Knight");
|
Abilities<Ability> abilities = getAbilitiesFromCard("Foulmire Knight");
|
||||||
Assert.assertEquals(3, abilities.size());
|
Assert.assertEquals(3, abilities.size());
|
||||||
|
|
||||||
AbilityPickerView view = new AbilityPickerView("test name", abilities, "test message");
|
AbilityPickerView view = new AbilityPickerView(prepareGameView(), "test name", abilities, "test message");
|
||||||
Assert.assertEquals(3, view.getChoices().size());
|
Assert.assertEquals(3, view.getChoices().size());
|
||||||
view.getChoices().values().forEach(c -> {
|
view.getChoices().values().forEach(c -> {
|
||||||
if (c.contains("Deathtouch")) {
|
if (c.contains("Deathtouch")) {
|
||||||
|
@ -51,7 +56,7 @@ public class AbilityPickerTest extends CardTestPlayerBase {
|
||||||
Abilities<Ability> abilities = getAbilitiesFromCard("Dimir Cluestone");
|
Abilities<Ability> abilities = getAbilitiesFromCard("Dimir Cluestone");
|
||||||
Assert.assertEquals(4, abilities.size());
|
Assert.assertEquals(4, abilities.size());
|
||||||
|
|
||||||
AbilityPickerView view = new AbilityPickerView("test name", abilities, "test message");
|
AbilityPickerView view = new AbilityPickerView(prepareGameView(), "test name", abilities, "test message");
|
||||||
Assert.assertEquals(4, view.getChoices().size());
|
Assert.assertEquals(4, view.getChoices().size());
|
||||||
int castCount = 0;
|
int castCount = 0;
|
||||||
int abilsCount = 0;
|
int abilsCount = 0;
|
||||||
|
@ -72,7 +77,7 @@ public class AbilityPickerTest extends CardTestPlayerBase {
|
||||||
Abilities<Ability> abilities = getAbilitiesFromCard("Cling to Dust");
|
Abilities<Ability> abilities = getAbilitiesFromCard("Cling to Dust");
|
||||||
Assert.assertEquals(2, abilities.size());
|
Assert.assertEquals(2, abilities.size());
|
||||||
|
|
||||||
AbilityPickerView view = new AbilityPickerView("test name", abilities, "test message");
|
AbilityPickerView view = new AbilityPickerView(prepareGameView(), "test name", abilities, "test message");
|
||||||
Assert.assertEquals(2, view.getChoices().size());
|
Assert.assertEquals(2, view.getChoices().size());
|
||||||
view.getChoices().values().forEach(c -> {
|
view.getChoices().values().forEach(c -> {
|
||||||
Assert.assertTrue("Must start with Cast text, but found: " + c, c.contains("Cast "));
|
Assert.assertTrue("Must start with Cast text, but found: " + c, c.contains("Cast "));
|
||||||
|
|
Loading…
Reference in a new issue