Skip to content

Commit

Permalink
clear user action prompt during AI's choice if getHideAiActionPrompt(…
Browse files Browse the repository at this point in the history
…) is enabled, removes need for clearUserActionPrompt
  • Loading branch information
melvinzhang committed Mar 30, 2015
1 parent 33e580e commit e23debb
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/magic/ui/SwingGameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ private static void invokeAndWait(final Runnable task) {
/** Returns true when undo was clicked. */
private boolean waitForInputOrUndo() {
try {
final boolean isUndo = input.take();
clearUserActionPrompt();
return isUndo;
return input.take();
} catch (final InterruptedException ex) {
throw new RuntimeException(ex);
}
Expand Down Expand Up @@ -557,7 +555,9 @@ public void run() {

private Object[] getArtificialNextEventChoiceResults(final MagicEvent event) {
disableActionButton(true);
if (CONFIG.getHideAiActionPrompt() == false) {
if (CONFIG.getHideAiActionPrompt()) {
showMessage(MagicEvent.NO_SOURCE, "");
} else {
showMessage(event.getSource(),event.getChoiceDescription());
}
SwingGameController.invokeAndWait(new Runnable() {
Expand Down Expand Up @@ -970,16 +970,4 @@ public Rectangle getStackViewerRectangle(Component canvas) {
public void doFlashPlayerHandZoneButton() {
gamePanel.doFlashPlayerHandZoneButton();
}

private void clearUserActionPrompt() {
if (game.getPhase().getType() != MagicPhaseType.DeclareAttackers) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
userActionPanel.showMessage("");
}
});
}
}

}

5 comments on commit e23debb

@lodici
Copy link
Member

@lodici lodici commented on e23debb Mar 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, it certainly is much simpler. The only problem with this specific commit is that the prompt is not immediately cleared after the user makes their decision, hence the original clearing of the prompt straight after input.take().

@melvinzhang
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Priority always alternates between human and AI, during the AI's turn it will be cleared if CONFIG.getHideAiActionPrompt() is true. It doesn't occur immediately as before but it avoids the problem with complex choices that requires multiple waitForInput using the same message. Is there a specific situation where the prompt persists visibly longer?

@lodici
Copy link
Member

@lodici lodici commented on e23debb Mar 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example
As soon as I click the land it should disappear as before because I have done what it has asked.

@melvinzhang
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see that's where the player continue to have priority. Think I found a good place to clear the prompt, in clearValidChoices. The purpose of this method is to remove the highlighted cards, seems reasonable that when we clear the highlighted cards we should also clear the question in the user action prompt. Implemented in e94b547

@lodici
Copy link
Member

@lodici lodici commented on e23debb Mar 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent.

Please sign in to comment.