diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-12-22 14:19:06 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-16 19:08:56 +0100 |
commit | 52f0cda13c555cd0c2149a9f92ecbccfdc6fed4d (patch) | |
tree | 0b6a49367ddd36aba52d2628d34c71bb005b0b53 | |
parent | c3c61f3785e02f62ccc174b8c03c45be3e1afa29 (diff) | |
download | julius-caesar-52f0cda13c555cd0c2149a9f92ecbccfdc6fed4d.tar.gz |
Show card backs when observing the block games.
-rw-r--r-- | play.html | 7 | ||||
-rw-r--r-- | rules.js | 9 | ||||
-rw-r--r-- | ui.js | 15 |
3 files changed, 28 insertions, 3 deletions
@@ -370,6 +370,13 @@ body.Observer .columbia-labels .known.jupiter.Cleopatra { border: 3px solid #822 <div id="card+26" class="card card_12" onclick="select_card(26)"></div> <div id="card+27" class="card card_12" onclick="select_card(27)"></div> +<div id="back+1" class="card card_back"></div> +<div id="back+2" class="card card_back"></div> +<div id="back+3" class="card card_back"></div> +<div id="back+4" class="card card_back"></div> +<div id="back+5" class="card card_back"></div> +<div id="back+6" class="card card_back"></div> + </div> </div> @@ -2526,6 +2526,13 @@ function make_battle_view() { return bv; } +function observer_hand() { + let hand = []; + hand.length = Math.max(game.c_hand.length, game.p_hand.length); + hand.fill(0); + return hand; +} + exports.view = function(state, current) { game = state; @@ -2539,7 +2546,7 @@ exports.view = function(state, current) { p_vp: game.p_vp, c_card: (game.show_cards || current === CAESAR) ? game.c_card : 0, p_card: (game.show_cards || current === POMPEIUS) ? game.p_card : 0, - hand: (current === CAESAR) ? game.c_hand : (current === POMPEIUS) ? game.p_hand : [], + hand: (current === CAESAR) ? game.c_hand : (current === POMPEIUS) ? game.p_hand : observer_hand(), who: (game.active === current) ? game.who : null, where: game.where, known: {}, @@ -72,6 +72,7 @@ let ui = { map_location: {}, battle_steps: {}, cards: {}, + card_backs: {}, }; create_log_entry = function (text) { @@ -288,9 +289,10 @@ function build_map() { build_battle_block(b, block, color); } - for (let c = 1; c <= 27; ++c) { + for (let c = 1; c <= 27; ++c) ui.cards[c] = document.getElementById("card+" + c); - } + for (let c = 1; c <= 6; ++c) + ui.card_backs[c] = document.getElementById("back+" + c); } function update_steps(memo, block, steps, element, animate) { @@ -692,6 +694,15 @@ function update_cards() { element.classList.remove("show"); } } + + if (player === 'Observer') { + let n = game.hand.length; + for (let c = 1; c <= 6; ++c) + if (c <= n) + ui.card_backs[c].classList.add("show"); + else + ui.card_backs[c].classList.remove("show"); + } } function on_update() { |