summaryrefslogtreecommitdiff
path: root/ui.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-06-06 16:15:43 +0200
committerTor Andersson <tor@ccxvii.net>2023-02-18 12:12:42 +0100
commit4befc7eb54e2f31709f0e29936570605abde8bbc (patch)
treec498652c67e33f312c3bfdf32657387a94a656db /ui.js
parent8889442d2f01b78952626aa9917630840afd87f5 (diff)
downloadshores-of-tripoli-4befc7eb54e2f31709f0e29936570605abde8bbc.tar.gz
tripoli: Basic card play.
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/ui.js b/ui.js
index 6813885..cd711d8 100644
--- a/ui.js
+++ b/ui.js
@@ -57,6 +57,9 @@ function on_blur(evt) {
document.getElementById("status").textContent = "";
}
+function on_pass() { if (game.actions) { send_action('pass', null); } }
+function on_undo() { if (game.actions) { send_action('undo', null); } }
+
function build_map() {
let i = 0;
for (let space of SPACES) {
@@ -80,15 +83,13 @@ function build_map() {
}
}
for (i = 1; i <= 27; ++i) {
- let e = ui.cards['us'+i] = document.getElementById("us_card_"+i);
+ let e = ui.cards[i] = document.getElementById("us_card_"+i);
e.addEventListener("click", on_card);
- e.deck = 'us';
e.card = i;
}
- for (i = 1; i <= 27; ++i) {
- let e = ui.cards['tr'+i] = document.getElementById("tr_card_"+i);
+ for (i = 28; i <= 54; ++i) {
+ let e = ui.cards[i] = document.getElementById("tr_card_"+(i-27));
e.addEventListener("click", on_card);
- e.deck = 'tr';
e.card = i;
}
}
@@ -104,18 +105,19 @@ function update_cards() {
document.getElementById("us_card_deck").textContent = game.us.deck;
document.getElementById("tr_card_deck").textContent = game.tr.deck;
for (let i = 1; i <= 3; ++i) {
- update_card('us'+i, game.us.core.includes('us'+i));
- update_card('tr'+i, game.tr.core.includes('tr'+i));
+ update_card(i, game.us.core.includes(i));
+ update_card(i+27, game.tr.core.includes(i+27));
}
for (let i = 4; i <= 27; ++i) {
- update_card('us'+i, game.hand.includes('us'+i));
- update_card('tr'+i, game.hand.includes('tr'+i));
+ update_card(i, game.hand.includes(i));
+ update_card(i+27, game.hand.includes(i+27));
}
}
/* MAP AND PIECE LAYOUT */
function on_update() {
+ show_action_button("#button_pass", "pass");
update_year_marker(game.year);
update_season_marker(game.season);
update_pieces(game.location);