From 0d300b3070f51910af34877de9de97d4fa163703 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 24 Oct 2024 13:45:01 +0200 Subject: Create and cancel subsidy contracts. --- play.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index 5e8357f..f3f5630 100644 --- a/play.js +++ b/play.js @@ -22,6 +22,23 @@ function toggle_shift() { document.body.classList.toggle("shift") } +function action_menu_item(action) { + let menu = document.getElementById(action + "_menu") + if (view.actions && action in view.actions) { + menu.classList.toggle("disabled", view.actions[action] === 0) + return 1 + } else { + menu.classList.toggle("disabled", true) + return 0 + } +} + +function action_menu(menu, action_list) { + let x = 0 + for (let action of action_list) + x |= action_menu_item(action) +} + /* DATA (SHARED) */ const deck_name = [ "red", "green", "blue", "yellow" ] @@ -1267,6 +1284,11 @@ function on_update() { layout_combat_marker() } + action_menu(document.getElementById("subsidy_menu"), [ + "propose_subsidy", + "cancel_subsidy", + ]) + action_button_with_argument("suit", SPADES, colorize_S) action_button_with_argument("suit", CLUBS, colorize_C) action_button_with_argument("suit", HEARTS, colorize_H) @@ -1287,10 +1309,13 @@ function on_update() { for (let pow of all_powers) action_button_with_argument("power", pow, power_name[pow]) - action_button("reduce", "Reduce") - action_button("offer", "Offer") + action_button("subsidy", "Subsidy") + action_button("cancel", "Cancel") + + action_button("reduce", "Reduce military objectives") + action_button("offer", "Offer peace") action_button("accept", "Accept") - action_button("deny", "Deny") + action_button("refuse", "Refuse") action_button("re_enter", "Re-enter") action_button("force_march", "Force march") -- cgit v1.2.3