diff options
-rw-r--r-- | play.css | 16 | ||||
-rw-r--r-- | play.js | 29 | ||||
-rw-r--r-- | rules.js | 32 |
3 files changed, 68 insertions, 9 deletions
@@ -70,15 +70,19 @@ svg .region.action, svg .sea.action { fill-opacity: 0.3; } -body.sel_general svg .region.action { +body.military svg .region.action { fill: hsl(358, 78%, 51%); } -body.sel_governor svg .region.action { +body.senate svg .region.action { fill: hsl(206, 100%, 35%); } -body.sel_governor svg .region.selected { +body.populace svg .region.action { + fill: hsl(44, 80%, 52%); +} + +body.senate svg .region.selected { fill: hsl(206, 100%, 35%); fill-opacity: 0.3; stroke: hsl(206, 100%, 35%); @@ -86,7 +90,7 @@ body.sel_governor svg .region.selected { stroke-dasharray: 8 4; } -body.sel_general svg .sea.action { +body.military svg .sea.action { fill: hsl(206, 100%, 35%); fill-opacity: 0.25; } @@ -174,12 +178,12 @@ body.sel_general svg .sea.action { z-index: 2; } -body.sel_general .capital.action { +body.military .capital.action { border-color: hsl(358, 78%, 51%); background-color: hsla(358, 75%, 51%, 0.2); } -body.sel_governor .capital.action { +body.populace .capital.action { border-color: hsl(44, 80%, 52%); background-color: hsla(44, 80%, 52%, 0.2); } @@ -535,6 +535,7 @@ let ui = { governors: [ [], [], [], [] ], castra: [ [], [], [], [] ], mcastra: [], + mobs: [], } function get_province_governor_player(where) { @@ -602,6 +603,8 @@ function on_click_action(evt, target) { function create_building(region, className, xoff, yoff) { let [ x, y, w, h ] = LAYOUT_SUPPORT[region] + if (region === ITALIA) + y += 52 let e = create_thing({ className }) e.style.left = x + (w >> 1) + xoff - 46 + "px" e.style.top = y + h + yoff + "px" @@ -675,6 +678,11 @@ function on_init() { ui.capital[region] = document.getElementById(REGION_NAME[region] + "_Capital") ui.quaestor[region] = document.getElementById(REGION_NAME[region] + "_Quaestor") + // at most 3 mobs per province + ui.mobs[region * 3 + 0] = create_piece(region, "mob", "mob") + ui.mobs[region * 3 + 1] = create_piece(region, "mob", "mob") + ui.mobs[region * 3 + 2] = create_piece(region, "mob", "mob") + if (true) { ui.amphitheater[region] = create_building(region, "amphitheater hide", -48 - 3, 6) ui.basilica[region] = create_building(region, "basilica hide", 48 + 3, 6) @@ -761,6 +769,17 @@ function layout_governor_unavailable(e, color, ix) { e.className = color + " governor n" + ix } +function layout_mob(region, i, e, visible, x2) { + if (visible) { + let [ x, y, w ,h ] = LAYOUT_SUPPORT[region] + e.className = x2 ? "mob_x2" : "mob" + e.style.top = (y - 36) + "px" + e.style.left = (x + 26 + 26 * i) + "px" + } else { + e.className = "hide" + } +} + function on_update() { let player_count = view.legacy.length @@ -945,6 +964,11 @@ function on_update() { hide(ui.neutral_governors[region]) } } + + let n = view.mobs[region] + layout_mob(region, 0, ui.mobs[region * 3 + 0], n >= 1, n >= 2) + layout_mob(region, 1, ui.mobs[region * 3 + 1], n >= 3, n >= 4) + layout_mob(region, 2, ui.mobs[region * 3 + 2], n >= 5, n >= 6) } for (let pi = 0; pi < player_count; ++pi) { @@ -1018,8 +1042,9 @@ function on_update() { layout_available(avail_stack, avail_stack.length > 5 ? 43 : 58, pi * 625 + 325, 27) } - ui.body.classList.toggle("sel_governor", typeof view.selected_governor === "number") - ui.body.classList.toggle("sel_general", typeof view.selected_general === "number") + ui.body.classList.toggle("military", view.color === 0) + ui.body.classList.toggle("senate", view.color === 1) + ui.body.classList.toggle("populace", view.color === 2) ui.dice[0].className = "dice black d" + view.dice[0] ui.dice[1].className = "dice white d" + view.dice[1] @@ -1195,11 +1195,13 @@ states.take_actions = { gen_action_card(c) if (game.selected_governor >= 0) { + view.color = SENATE view.selected_governor = game.selected_governor where = get_governor_location(game.selected_governor) } if (game.selected_general >= 0) { + view.color = MILITARY view.selected_general = game.selected_general where = get_general_location(game.selected_general) } @@ -1642,7 +1644,7 @@ states.place_governor = { let votes = game.misc.spend if (game.misc.where === ITALIA) votes += count_own_basilicas() - view.selected_governor = game.selected_governor + view.color = SENATE view.selected_region = game.misc.where prompt(`Place Governor: ${sip} Senate. Rolling ${votes} dice. ${need} votes needed.`) @@ -1890,6 +1892,34 @@ states.foederati = { }, } +// CARD: MOB + +function can_play_mob() { + for (let where = 0; where < 12; ++where) + if (!has_mob(where) && is_enemy_province(where)) + return true + return false +} + +function play_mob() { + game.state = "mob" +} + +states.mob = { + prompt() { + prompt("Mob: Place a Mob in a province.") + view.color = POPULACE + for (let where = 0; where < 12; ++where) + if (!has_mob(where) && is_enemy_province(where)) + gen_action_region(where) + }, + region(where) { + log("Mob in S" + where) + add_one_mob(where) + game.state = "take_actions" + }, +} + // === COMBAT === function goto_battle_vs_general(where, attacker, target) { |