summaryrefslogtreecommitdiff
path: root/ui.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-06-21 23:58:51 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:19:38 +0100
commit8b3f8439480b038abfb89b542d2f0ac601bbbdd4 (patch)
tree4fcbb6d2df349664d9c2dc696b6f7232b45684d7 /ui.js
parent37d4521ee7a9911f1dd89ee3768b2a9cce7c7f1c (diff)
downloadcrusader-rex-8b3f8439480b038abfb89b542d2f0ac601bbbdd4.tar.gz
crusader: Intrigue.
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js55
1 files changed, 34 insertions, 21 deletions
diff --git a/ui.js b/ui.js
index 9ef68a0..64044ee 100644
--- a/ui.js
+++ b/ui.js
@@ -519,7 +519,8 @@ function hide_block(element) {
function update_map() {
let layout = {};
- document.getElementById("turn").textContent = "Year " + game.year + " (" + (game.year-1186) + "/6)" ;
+ document.getElementById("turn").textContent =
+ "Turn " + game.turn + " of Year " + game.year;
for (let town in TOWNS)
layout[town] = { north: [], south: [] };
@@ -574,29 +575,41 @@ function update_map() {
}
}
-function update_cards() {
- let cards = game.hand;
- for (let c = 1; c <= 27; ++c) {
- ui.cards[c].classList.remove('enabled');
- if (cards && cards.includes(c))
- ui.cards[c].classList.add('show');
- else
- ui.cards[c].classList.remove('show');
+function update_card_display(element, card, prior_card) {
+ console.log("update_card_display", element, card, prior_card);
+ if (!card && !prior_card) {
+ element.className = "small_card card_back";
+ } else if (prior_card) {
+ element.className = "small_card prior " + CARDS[prior_card].image;
+ } else {
+ element.className = "small_card " + CARDS[card].image;
}
+}
- if (game.actions && game.actions.play) {
- for (let c of game.actions.play)
- ui.cards[c].classList.add('enabled');
- }
+function update_cards() {
+ update_card_display(document.getElementById("frank_card"), game.f_card, game.prior_f_card);
+ update_card_display(document.getElementById("saracen_card"), game.s_card, game.prior_s_card);
- if (!game.f_card)
- document.querySelector("#frank_card").className = "small_card card_back";
- else
- document.querySelector("#frank_card").className = "small_card " + CARDS[game.f_card].image;
- if (!game.s_card)
- document.querySelector("#saracen_card").className = "small_card card_back";
- else
- document.querySelector("#saracen_card").className = "small_card " + CARDS[game.s_card].image;
+ for (let c = 1; c <= 27; ++c) {
+ let element = ui.cards[c];
+ if (game.hand.includes(c)) {
+ element.classList.add("show");
+ if (game.actions && game.actions.play) {
+ if (game.actions.play.includes(c)) {
+ element.classList.add("enabled");
+ element.classList.remove("disabled");
+ } else {
+ element.classList.remove("enabled");
+ element.classList.add("disabled");
+ }
+ } else {
+ element.classList.remove("enabled");
+ element.classList.remove("disabled");
+ }
+ } else {
+ element.classList.remove("show");
+ }
+ }
}
function update_battle() {