From 151b9a3c5336f70eaf3acc47b2e9fa10e56ee28f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 22 Dec 2021 14:19:06 +0100 Subject: Show card backs when observing the block games. --- cards/card_back.svg | 6 +----- info/f5.png | Bin 0 -> 30503 bytes play.html | 5 +++++ rules.js | 9 ++++++++- ui.js | 13 +++++++++++++ 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 info/f5.png diff --git a/cards/card_back.svg b/cards/card_back.svg index bd424c8..57233a1 100644 --- a/cards/card_back.svg +++ b/cards/card_back.svg @@ -4,11 +4,7 @@ - -Created by potrace 1.15, written by Peter Selinger 2001-2017 - - +
+
+
+
+
+
diff --git a/rules.js b/rules.js index 0fd3184..05e9cc8 100644 --- a/rules.js +++ b/rules.js @@ -2887,6 +2887,13 @@ exports.resign = function (state, current) { return state; } +function observer_hand() { + let hand = []; + hand.length = Math.max(game.e_hand.length, game.s_hand.length); + hand.fill(0); + return hand; +} + exports.view = function(state, current) { game = state; @@ -2899,7 +2906,7 @@ exports.view = function(state, current) { s_vp: count_scottish_nobles(), e_card: (game.show_cards || current === ENGLAND) ? game.e_card : 0, s_card: (game.show_cards || current === SCOTLAND) ? game.s_card : 0, - hand: (current === ENGLAND) ? game.e_hand : (current === SCOTLAND) ? game.s_hand : [], + hand: (current === ENGLAND) ? game.e_hand : (current === SCOTLAND) ? game.s_hand : observer_hand(), who: (game.active === current) ? game.who : null, where: game.where, known: {}, diff --git a/ui.js b/ui.js index 66790c2..8d525ff 100644 --- a/ui.js +++ b/ui.js @@ -40,6 +40,7 @@ function toggle_blocks() { let ui = { cards: {}, + card_backs: {}, areas: {}, known: {}, secret: { England: {}, Scotland: {} }, @@ -348,6 +349,9 @@ function build_map() { ui.cards[c].addEventListener("click", on_click_card); } + for (let c = 1; c <= 5; ++c) + ui.card_backs[c] = document.getElementById("back+"+c); + for (let name in AREAS) { let area = AREAS[name]; let element = svgmap.getElementById("area+"+name); @@ -641,6 +645,15 @@ function update_cards() { ui.cards[c].classList.remove('show'); } + if (player === 'Observer') { + let n = game.hand.length; + for (let c = 1; c <= 5; ++c) + if (c <= n) + ui.card_backs[c].classList.add("show"); + else + ui.card_backs[c].classList.remove("show"); + } + if (game.actions && game.actions.play) { for (let c of game.actions.play) ui.cards[c].classList.add('enabled'); -- cgit v1.2.3