summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-10-01 13:57:42 +0200
committerTor Andersson <tor@ccxvii.net>2023-02-18 12:42:59 +0100
commitd590e5f2e5107084f35aefdf40b383aa564d3d62 (patch)
tree5d57a8438ccc5646db9bb12502fa0e675f840133
parentf3fe9aa59d42b6ce991d2918a226917349f10986 (diff)
download300-earth-and-water-d590e5f2e5107084f35aefdf40b383aa564d3d62.tar.gz
300: Always show undo button.
Help muscle memory by always showing the undo button in the same place.
-rw-r--r--play.html2
-rw-r--r--rules.js1
-rw-r--r--ui.js22
3 files changed, 23 insertions, 2 deletions
diff --git a/play.html b/play.html
index fe3cb5e..8180fd1 100644
--- a/play.html
+++ b/play.html
@@ -293,8 +293,8 @@
<button id="button_draw" onclick="on_draw()" class="hide">Draw</button>
<button id="button_battle" onclick="on_battle()" class="hide">Battle</button>
<button id="button_pass" onclick="on_pass()" class="hide">Pass</button>
- <button id="button_undo" onclick="on_undo()" class="hide">Undo</button>
<button id="button_next" onclick="on_next()" class="hide">Next</button>
+ <button id="button_undo" onclick="on_undo()" class="hide">Undo</button>
<div id="rematch_button" class="image_button hide" onclick="send_rematch()"><img src="/images/cycle.svg"></div>
<div id="exit_button" class="image_button hide" onclick="send_exit()"><img src="/images/exit-door.svg"></div>
diff --git a/rules.js b/rules.js
index e1218e1..c209f00 100644
--- a/rules.js
+++ b/rules.js
@@ -9,6 +9,7 @@
// Diary: 2021-05-03 - Monday Night - Clean up reaction event game states.
// Diary: 2021-05-04 - Tuesday Night - Event code cleanup.
// Diary: 2021-05-08 - Saturday Afternoon - Polish game log messages.
+// Diary: 2021-10-01 - Friday Afternoon - Fix bugs.
// Acropolis on Fire -- if sudden death of the great king, does greece get 6 or 5 talents for the next campaign?
// leonidas + miltiades -- forbid combination?
diff --git a/ui.js b/ui.js
index 5c95765..d37adf6 100644
--- a/ui.js
+++ b/ui.js
@@ -267,6 +267,26 @@ function show_marker(id, class_name, show = 1, enabled = 0) {
elt.className = class_name;
}
+function show_undo_button(sel, action, use_label = false) {
+ let button = document.querySelector(sel);
+ if (game.actions) {
+ button.classList.remove("hide");
+ if (game.actions && action in game.actions) {
+ if (game.actions[action]) {
+ if (use_label)
+ button.textContent = game.actions[action];
+ button.disabled = false;
+ } else {
+ button.disabled = true;
+ }
+ } else {
+ button.disabled = true;
+ }
+ } else {
+ button.classList.add("hide");
+ }
+}
+
function on_update() {
document.getElementById("greek_info").textContent = greek_info();
document.getElementById("persian_info").textContent = persian_info();
@@ -285,7 +305,7 @@ function on_update() {
show_action_button("#button_draw", "draw");
show_action_button("#button_next", "next");
show_action_button("#button_pass", "pass");
- show_action_button("#button_undo", "undo");
+ show_undo_button("#button_undo", "undo");
if (game.actions && game.actions.destroy)
document.getElementById("bridge").className = "show destroy";