From 1d073110c0937e2a057efd0eeeef5223036c1187 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 2 Nov 2024 20:36:16 +0100 Subject: Highlight selected space. --- play.css | 5 +++++ play.js | 3 +++ rules.js | 17 +++-------------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/play.css b/play.css index f2113ed..dc801f8 100644 --- a/play.css +++ b/play.css @@ -90,6 +90,11 @@ body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } .space.Romania.action { border-color: peachpuff; } .space.Bulgaria.action { border-color: palegreen; } +.space.selected { + border-color: aqua; + box-shadow: 0 0 0 1px black, inset 0 0 0 1px black; +} + .space.tip { border-color: lime; box-shadow: 0 0 0 1px black, inset 0 0 0 1px black; diff --git a/play.js b/play.js index aa7a8b6..a201e8a 100644 --- a/play.js +++ b/play.js @@ -715,6 +715,9 @@ function on_update() { for (let e of action_register) e.classList.toggle("action", is_action(e.my_action, e.my_id)) + for (let s = 0; s <= last_space; ++s) + ui.spaces[s].classList.toggle("selected", view.selected_space === s) + action_button("yes", "Yes") action_button("no", "No") action_button("start", "Start") diff --git a/rules.js b/rules.js index dff42c5..3e4a867 100644 --- a/rules.js +++ b/rules.js @@ -387,19 +387,8 @@ exports.view = function(state, player) { view.drawn = game.vm.draw if (player === game.active) { - if (game.selected_space) { - view.valid_spaces = [game.selected_space] - } else { - view.valid_spaces = game.valid_spaces - } - } else { - view.valid_spaces = [] - } - - if (player === game.active) { - view.valid_cards = game.valid_cards - } else { - view.valid_cards = [] + if (game.selected_space >= 0) + view.selected_space = game.selected_space } if (player === DEM) { @@ -422,7 +411,7 @@ exports.view = function(state, player) { if (game.state === "game_over") { view.prompt = game.victory - } else if (player === "Observer" || (game.active !== player && game.active !== "Both")) { + } else if (game.active !== player) { if (states[game.state]) { let inactive = states[game.state].inactive if (typeof inactive === "function") -- cgit v1.2.3