diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-06-20 18:10:33 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-07 18:39:37 +0200 |
commit | d68a8f5426e335fce66c8b366646657115bbe65a (patch) | |
tree | cd509fbc50bddbb65d725652a2a86e9c388a8256 | |
parent | 8fb42cd1821020f433d19c01ce70fa45b4797ec4 (diff) | |
download | time-of-crisis-d68a8f5426e335fce66c8b366646657115bbe65a.tar.gz |
Clickable support boxes.
This reverts commit 0a1c421615aebefd26accf668c4ec640be917344.
-rw-r--r-- | play.css | 12 | ||||
-rw-r--r-- | play.js | 14 | ||||
-rw-r--r-- | rules.js | 33 |
3 files changed, 32 insertions, 27 deletions
@@ -94,6 +94,18 @@ svg .sea.action { transition-timing-function: ease; } +.support { + box-sizing: border-box; + width: 54px; + height: 54px; + border: 3px solid transparent; + border-radius: 8px; +} + +.support.action { + border-color: yellow; +} + .dice { width: 36px; height: 36px; @@ -622,6 +622,17 @@ function create_building(region, className, xoff, yoff) { return e } +function create_support_buttons(region) { + let [ x0, y0 ] = LAYOUT_SUPPORT[region] + for (let i = 0; i <= 4; ++i) { + let x = Math.floor(-1 + x0 + i * 51.6666) + let y = (-1 + y0) + let e = create_thing({ className: "support", my_action: "support", my_id: (region << 3) + i }) + e.style.top = y + "px" + e.style.left = x + "px" + } +} + function is_action(action, arg) { if (arg === undefined) return !!(view.actions && view.actions[action] === 1) @@ -691,6 +702,8 @@ function on_init() { register_action(ui.capital[region], "capital", region) register_action(ui.regions[region], "region", region) + create_support_buttons(region) + ui.neutral_governors[region] = create_thing({ className: "neutral governor hide" }) } for (let region = 12; region < 21; ++region) { @@ -1103,7 +1116,6 @@ function on_update() { action_button("roll", "Roll") action_button("place_militia", "Place Militia") - action_button("support", "Increase Support Level") action_button("hold_games", "Hold Games") action_button("build_improvement", "Build an Improvement") @@ -1088,7 +1088,7 @@ states.take_actions_governor = { let support = game.support[where] if (where !== ITALIA && support < 4) { if (pip > support) - view.actions.support = 1 + gen_action_support(where, support + 1) } // Place Militia @@ -1127,19 +1127,12 @@ states.take_actions_governor = { else goto_battle_vs_general(get_governor_location(game.who), -1, id) }, - recruit() { push_undo() log("Recruited Governor " + (game.who % 6) + ".") spend_ip(SENATE, game.who % 6) set_governor_location(game.who, AVAILABLE) }, - place() { - push_undo() - spend_ip(SENATE, 1) - game.state = "place_governor_where" - game.misc = { spend: 1 } - }, recall() { push_undo() let where = get_governor_location(game.who) @@ -1186,7 +1179,7 @@ states.take_actions_governor = { push_undo() spend_ip(SENATE, 1) game.misc = { spend: 1, where: where } - game.state = "place_governor_spend" + game.state = "place_governor" }, barbarian(id) { @@ -1411,23 +1404,7 @@ function calc_needed_votes(where) { return Math.max(1, n) } -states.place_governor_where = { - prompt() { - prompt("Place Governor.") - view.selected_governor = game.who - for (let where = 0; where < 12; ++where) { - if (can_place_governor(where)) - gen_action_region(where) - } - }, - region(where) { - push_undo() - game.misc.where = where - game.state = "place_governor_spend" - }, -} - -states.place_governor_spend = { +states.place_governor = { prompt() { let [ mip, sip, pip ] = game.ip let need = calc_needed_votes(game.misc.where) @@ -2355,6 +2332,10 @@ function gen_action_capital(where) { gen_action("capital", where) } +function gen_action_support(where, level) { + gen_action("support", where << 3 | level) +} + function gen_action_card(c) { gen_action("card", c) } |