mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
Fixed remembering self-referential choices (#12167)
* Fixed remembering self-referential choices * Rename filtered message to auto answer message * Always use auto answer message
This commit is contained in:
parent
40143c648f
commit
42906f519b
4 changed files with 26 additions and 6 deletions
|
|
@ -89,6 +89,12 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
// allows yes/no auto-answers for ability related
|
// allows yes/no auto-answers for ability related
|
||||||
this.helper.setOriginalId((UUID) options.get(ORIGINAL_ID));
|
this.helper.setOriginalId((UUID) options.get(ORIGINAL_ID));
|
||||||
}
|
}
|
||||||
|
if (options != null && options.containsKey(AUTO_ANSWER_MESSAGE)) {
|
||||||
|
// Uses a filtered message for remembering choice if the original message contains a self-reference
|
||||||
|
this.helper.setAutoAnswerMessage((String) options.get(AUTO_ANSWER_MESSAGE));
|
||||||
|
} else {
|
||||||
|
this.helper.setAutoAnswerMessage(message);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CONFIRM:
|
case CONFIRM:
|
||||||
setButtonState("OK", "Cancel", mode);
|
setButtonState("OK", "Cancel", mode);
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ public class HelperPanel extends JPanel {
|
||||||
// originalId of feedback causing ability
|
// originalId of feedback causing ability
|
||||||
private UUID originalId;
|
private UUID originalId;
|
||||||
private String message;
|
private String message;
|
||||||
|
private String autoAnswerMessage; // Filtered version of message which is used for remembering answers to text
|
||||||
|
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
private boolean gameNeedFeedback = false;
|
private boolean gameNeedFeedback = false;
|
||||||
|
|
@ -462,6 +463,10 @@ public class HelperPanel extends JPanel {
|
||||||
this.dialogTextArea.setText(message, this.getWidth());
|
this.dialogTextArea.setText(message, this.getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAutoAnswerMessage(String autoAnswerMessage) {
|
||||||
|
this.autoAnswerMessage = autoAnswerMessage;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTextArea(String message) {
|
public void setTextArea(String message) {
|
||||||
this.dialogTextArea.setText(message, this.getWidth());
|
this.dialogTextArea.setText(message, this.getWidth());
|
||||||
}
|
}
|
||||||
|
|
@ -523,19 +528,23 @@ public class HelperPanel extends JPanel {
|
||||||
public void handleAutoAnswerPopupMenuEvent(ActionEvent e) {
|
public void handleAutoAnswerPopupMenuEvent(ActionEvent e) {
|
||||||
switch (e.getActionCommand()) {
|
switch (e.getActionCommand()) {
|
||||||
case CMD_AUTO_ANSWER_ID_YES:
|
case CMD_AUTO_ANSWER_ID_YES:
|
||||||
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_YES, gameId, originalId.toString() + '#' + message);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_YES, gameId,
|
||||||
|
originalId.toString() + '#' + autoAnswerMessage);
|
||||||
clickButton(btnLeft);
|
clickButton(btnLeft);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ANSWER_ID_NO:
|
case CMD_AUTO_ANSWER_ID_NO:
|
||||||
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_NO, gameId, originalId.toString() + '#' + message);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_NO, gameId,
|
||||||
|
originalId.toString() + '#' + autoAnswerMessage);
|
||||||
clickButton(btnRight);
|
clickButton(btnRight);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ANSWER_NAME_YES:
|
case CMD_AUTO_ANSWER_NAME_YES:
|
||||||
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_TEXT_YES, gameId, message);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_TEXT_YES, gameId,
|
||||||
|
autoAnswerMessage);
|
||||||
clickButton(btnLeft);
|
clickButton(btnLeft);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ANSWER_NAME_NO:
|
case CMD_AUTO_ANSWER_NAME_NO:
|
||||||
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_TEXT_NO, gameId, message);
|
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_TEXT_NO, gameId,
|
||||||
|
autoAnswerMessage);
|
||||||
clickButton(btnRight);
|
clickButton(btnRight);
|
||||||
break;
|
break;
|
||||||
case CMD_AUTO_ANSWER_RESET_ALL:
|
case CMD_AUTO_ANSWER_RESET_ALL:
|
||||||
|
|
|
||||||
|
|
@ -59,5 +59,6 @@ public final class Constants {
|
||||||
public static final String ORIGINAL_ID = "originalId";
|
public static final String ORIGINAL_ID = "originalId";
|
||||||
public static final String SECOND_MESSAGE = "secondMessage";
|
public static final String SECOND_MESSAGE = "secondMessage";
|
||||||
public static final String HINT_TEXT = "hintText";
|
public static final String HINT_TEXT = "hintText";
|
||||||
|
public static final String AUTO_ANSWER_MESSAGE = "autoAnswerMessage";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -406,6 +406,7 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
|
|
||||||
MessageToClient messageToClient = new MessageToClient(message, secondMessage);
|
MessageToClient messageToClient = new MessageToClient(message, secondMessage);
|
||||||
Map<String, Serializable> options = new HashMap<>(2);
|
Map<String, Serializable> options = new HashMap<>(2);
|
||||||
|
String autoAnswerMessage = message; // Removes self-referential text for the purposes of auto-answering
|
||||||
if (trueText != null) {
|
if (trueText != null) {
|
||||||
options.put("UI.left.btn.text", trueText);
|
options.put("UI.left.btn.text", trueText);
|
||||||
}
|
}
|
||||||
|
|
@ -414,18 +415,21 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
}
|
}
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
//options.put(Constants.Option.ORIGINAL_ID, "")
|
//options.put(Constants.Option.ORIGINAL_ID, "")
|
||||||
|
autoAnswerMessage = autoAnswerMessage.replace(getRelatedObjectName(source, game), "{this}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options.put(Constants.Option.AUTO_ANSWER_MESSAGE, autoAnswerMessage);
|
||||||
|
|
||||||
// auto-answer
|
// auto-answer
|
||||||
Boolean answer = null;
|
Boolean answer = null;
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
// ability + text
|
// ability + text
|
||||||
answer = requestAutoAnswerId.get(source.getOriginalId() + "#" + message);
|
answer = requestAutoAnswerId
|
||||||
|
.get(source.getOriginalId() + "#" + autoAnswerMessage);
|
||||||
}
|
}
|
||||||
if (answer == null) {
|
if (answer == null) {
|
||||||
// text
|
// text
|
||||||
answer = requestAutoAnswerText.get(message);
|
answer = requestAutoAnswerText.get(autoAnswerMessage);
|
||||||
}
|
}
|
||||||
if (answer != null) {
|
if (answer != null) {
|
||||||
return answer;
|
return answer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue