From 1c5341697eb1bd41dd05e97a75c88fa461323a74 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 22 Jun 2023 23:29:00 +0200 Subject: Pretender (expand). --- play.css | 1 + play.js | 40 ++++++++++++++++++++-------------- rules.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 81 insertions(+), 36 deletions(-) diff --git a/play.css b/play.css index f1f400a..3e2a722 100644 --- a/play.css +++ b/play.css @@ -182,6 +182,7 @@ body.military svg .sea.action { .capital.action { display: block; border: 5px solid white; + background-color: #fff8; box-shadow: 0 0 6px white, inset 0 0 6px black; z-index: 2; } diff --git a/play.js b/play.js index baf4137..be4b192 100644 --- a/play.js +++ b/play.js @@ -737,11 +737,11 @@ function on_init() { for (let p = 0; p < 4; ++p) { for (let i = 0; i < 12; ++i) { ui.seat_of_power[p * 12 + i] = create_thing({ className: PLAYER_CLASS[p] + " seat_of_power hide" }) - ui.seat_of_power[p * 12 + i].style.left = LAYOUT_QUAESTOR[i][0] + "px" - ui.seat_of_power[p * 12 + i].style.top = LAYOUT_QUAESTOR[i][1] + "px" + ui.seat_of_power[p * 12 + i].style.left = (LAYOUT_QUAESTOR[i][0] + 16) + "px" + ui.seat_of_power[p * 12 + i].style.top = (LAYOUT_QUAESTOR[i][1]) + "px" ui.breakaway[p * 12 + i] = create_thing({ className: PLAYER_CLASS[p] + " breakaway hide" }) - ui.breakaway[p * 12 + i].style.left = LAYOUT_QUAESTOR[i][0] + "px" - ui.breakaway[p * 12 + i].style.top = LAYOUT_QUAESTOR[i][1] + "px" + ui.breakaway[p * 12 + i].style.left = (LAYOUT_QUAESTOR[i][0] + 16) + "px" + ui.breakaway[p * 12 + i].style.top = (LAYOUT_QUAESTOR[i][1]) + "px" } } @@ -770,8 +770,8 @@ function on_init() { ui.militia[region] = create_thing({ className: "militia hide", my_action: "militia", my_id: region }) ui.capital[region] = document.getElementById(REGION_NAME[region] + "_Capital") ui.quaestor[region] = create_thing({ className: "quaestor hide" }) - ui.quaestor[region].style.left = LAYOUT_QUAESTOR[region][0] + "px" - ui.quaestor[region].style.top = LAYOUT_QUAESTOR[region][1] + "px" + ui.quaestor[region].style.left = (LAYOUT_QUAESTOR[region][0] + 16) + "px" + ui.quaestor[region].style.top = (LAYOUT_QUAESTOR[region][1]) + "px" // at most 3 mobs per province ui.mobs[region * 3 + 0] = create_piece(region, "mob", "mob") @@ -843,11 +843,10 @@ function layout_available(list, dx, x0, y0) { let x = 25 + x0 for (let item of list) { let xo = item.my_id % 6 - if (list.length < 6) - xo -= 1 + //if (list.length < 6) xo -= 1 item.style.left = (x + xo * dx) + "px" item.style.top = y + "px" - item.style.zIndex = 1 + item.style.zIndex = 7 - xo item.my_stack = 0 } } @@ -878,11 +877,18 @@ function layout_mob(region, i, e, visible, x2) { } function layout_barbarian_dice(black, white, tribe) { - let [ x, y, w, h ] = LAYOUT_DICE[tribe] - black.style.top = (y + 4) + "px" - white.style.top = (y + 4) + "px" - black.style.left = (x + 0) + "px" - white.style.left = (x + 50) + "px" + if (tribe >= 0) { + show(black) + show(white) + let [ x, y, w, h ] = LAYOUT_DICE[tribe] + black.style.top = (y + 4) + "px" + white.style.top = (y + 4) + "px" + black.style.left = (x + 0) + "px" + white.style.left = (x + 50) + "px" + } else { + hide(black) + hide(white) + } } function on_update() { @@ -1145,7 +1151,8 @@ function on_update() { e.classList.toggle("unavailable", region === UNAVAILABLE) e.classList.toggle("selected", view.selected_general === pi * 6 + ai) } - layout_available(avail_stack, avail_stack.length > 5 ? 48 : 63, pi * 625 + 0, 30) + //layout_available(avail_stack, avail_stack.length > 5 ? 48 : 63, pi * 625 + 0, 30) + layout_available(avail_stack, 48, pi * 625 + 0, 30) } for (let pi = 0; pi < player_count; ++pi) { @@ -1165,7 +1172,8 @@ function on_update() { e.classList.toggle("unavailable", region === UNAVAILABLE) e.classList.toggle("selected", view.selected_governor === pi * 6 + ai) } - layout_available(avail_stack, avail_stack.length > 5 ? 43 : 58, pi * 625 + 325, 27) + //layout_available(avail_stack, avail_stack.length > 5 ? 43 : 58, pi * 625 + 325, 27) + layout_available(avail_stack, 43, pi * 625 + 325, 27) } ui.body.classList.toggle("military", view.color === 0) diff --git a/rules.js b/rules.js index d407d32..2abc607 100644 --- a/rules.js +++ b/rules.js @@ -49,13 +49,13 @@ game.battle -> game.battle / game.count + game.where [x] praetorian guard [ ] damnatio memoriae -[ ] pretender - [ ] place +[x] pretender + [x] place [ ] expand - [ ] scoring effects + [x] scoring effects [ ] occupation effects -[ ] game end +[x] game end [ ] rival emperors [ ] emperor turns @@ -1000,6 +1000,33 @@ function assign_hit_to_legion(id) { } } +function is_pretender_province(where) { + return is_breakaway(where) || is_seat_of_power(where) +} + +function find_seat_of_power() { + for (let where = 1; where < 12; ++where) + if (is_seat_of_power(where) && is_own_province(where)) + return where + return -1 +} + +function is_possible_seat_of_power(from) { + if (is_own_province(from) && get_support(from) >= 3) + for (let to of ADJACENT[from]) + if (is_own_province(to) && get_support(to) >= 3) + return true + return false +} + +function is_expand_pretender_province(from) { + if (get_support(from) >= 3 && !is_pretender_province(from) && is_own_province(from)) + for (let to of ADJACENT[from]) + if (is_pretender_province(to) && is_own_province(to)) + return true + return false +} + // === SETUP === states.setup_province = { @@ -1086,6 +1113,7 @@ function goto_upkeep() { // === CRISIS === function goto_crisis() { + game.crisis = -1 game.dice[0] = roll_die() game.dice[1] = roll_die() game.dice[2] = 0 @@ -1904,6 +1932,7 @@ states.move_army_at_sea = { prompt() { let [ mip, sip, pip ] = game.ip prompt("Move Army.") + view.color = MILITARY view.selected_general = game.selected_general gen_move_army() }, @@ -2107,21 +2136,6 @@ states.mob = { // CARD: PRETENDER -function find_seat_of_power() { - for (let where = 1; where < 12; ++where) - if (is_seat_of_power(where) && is_own_province(where)) - return where - return -1 -} - -function is_possible_seat_of_power(from) { - if (is_own_province(from) && get_support(from) >= 3) - for (let to of ADJACENT[from]) - if (is_own_province(to) && get_support(to) >= 3) - return true - return false -} - function can_play_pretender() { if (is_emperor_player()) return false @@ -2718,7 +2732,7 @@ states.support_check_emperor = { prompt() { prompt("Support Check: Reduce support in Italia for Rival Emperor and/or Pretender.") view.color = POPULACE - gen_action_region(where) + gen_action_region(ITALIA) }, region(where) { push_undo() @@ -2759,9 +2773,31 @@ states.support_check_mobs = { // === EXPAND PRETENDER EMPIRE === function goto_expand_pretender_empire() { + for (let where = 1; where < 12; ++where) { + if (is_expand_pretender_province(where)) { + game.state = "expand_pretender_empire" + return + } + } goto_gain_legacy() } +states.expand_pretender_empire = { + prompt() { + prompt("Expand Pretender Empire!") + view.color = POPULACE + for (let where = 1; where < 12; ++where) + if (is_expand_pretender_province(where)) + gen_action_region(where) + }, + region(where) { + push_undo() + add_breakaway(where) + remove_quaestor(where) // no effect anymore + goto_expand_pretender_empire() + }, +} + // === GAIN LEGACY === function goto_gain_legacy() { -- cgit v1.2.3