From 622c6f7083e0eb6192211dd87cb7b32cf7825268 Mon Sep 17 00:00:00 2001 From: Joël Simoneau Date: Wed, 30 Oct 2024 15:00:32 -0400 Subject: VP and Tax. --- rules.js | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 7 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 31eb1ca..2c18d34 100644 --- a/rules.js +++ b/rules.js @@ -187,6 +187,7 @@ exports.setup = function (seed, scenario, _options) { cylinder: [ ELIGIBLE, ELIGIBLE, ELIGIBLE ], resources: [ 12, 6, 7 ], vp: [ 18, 0, 0 ], + prosperity: [ 0, 0, 0 ], bk_inf: 0, ve_inf: 0, tributary: 8191, // all 13 provinces @@ -444,6 +445,11 @@ function goto_rebel() { game.state = "rebel" } +function goto_tax() { + init_command("Tax") + game.state = "tax" +} + /* STATES */ states.eligible = { @@ -498,6 +504,7 @@ states.command_decree = { march: goto_march, rally: goto_rally, rebel: goto_rebel, + tax: goto_tax, } states.event_command = { @@ -702,7 +709,21 @@ states.rebel = { log_space(s, "Rebel") }, end_rebel: end_command, +} + +states.tax = { + prompt() { + view.prompt = `Tax: Collect ${tax_count()} from Controlled Prosperity and Temples` + gen_action_resources(VE) + }, + resources(f) { + let t = tax_count() + add_resources(game.current, t) + logi_resources(VE, t) + game.decree = 0 + game.state = "command_decree" + } } /* COMMANDS */ @@ -834,9 +855,17 @@ function end_command() { function gen_any_decree() { if (game.current === DS) { - // view.actions.conscript = can_conscript() ? 1 : 0 - } else if (game.current === BK || game.current === VE) { + // view.actions.collect = can_collect() ? 1 : 0 + // view.actions.campaign = can_campaign() ? 1 : 0 + // view.actions.demand = can_demand() ? 1 : 0 + } else if (game.current === BK) { + // view.actions.trade = can_trade() ? 1 : 0 + view.actions.build = can_build() ? 1 : 0 + // view.actions.conspire = can_conspire() ? 1 : 0 + } else if (game.current === VE) { + view.actions.tax = can_tax() ? 1 : 0 view.actions.build = can_build() ? 1 : 0 + // view.actions.compel = can_compel() ? 1 : 0 } } @@ -845,7 +874,15 @@ function can_build() { } function can_build_in_space(s) { - return has_piece(s, game.current, ELITE) + return has_piece(s, game.current, ELITE) && !has_piece(s, game.current, DISC) +} + +function can_tax() { + return tax_count() > 0 +} + +function tax_count() { + return count_pieces_on_map(VE, DISC) + game.prosperity[VE] } /* TRIBUTARY AND REBELS */ @@ -902,6 +939,16 @@ function count_pieces(s, faction, type) { return n } +function count_pieces_on_map(faction, type) { + let first = first_piece[faction][type] + let last = last_piece[faction][type] + let n = 0 + for (let p = first; p <= last; ++p) + if (piece_space(p) >= 0) + ++n + return n +} + function count_faction_pieces(s, faction) { switch (faction) { case DS: @@ -1032,13 +1079,26 @@ function add_resources(faction, n) { function update_control() { game.control = [0, 0, 0] + game.prosperity = [0, 0, 0] for (let s = first_space; s <= last_province; ++s) { - if (is_tributary(s)) continue + if (is_tributary(s)) + game.prosperity[DS] += SPACES[s].pop + else { + let c = has_majority(s) + if (c <= VE) + game.control[c] |= (1 << s) - let c = has_majority(s) - if (c <= VE) - game.control[c] |= (1 << s) + if (c === BK || c === VE) + game.prosperity[c] += SPACES[s].pop + } } + update_vp() +} + +function update_vp() { + game.vp[DS] = game.prosperity[DS] + game.vp[BK] = game.prosperity[BK] + count_pieces_on_map(BK, DISC) + game.bk_inf + game.vp[VE] = game.prosperity[VE] + count_pieces_on_map(VE, DISC) + game.ve_inf } /* ACTIONS */ @@ -1053,6 +1113,10 @@ function gen_action_piece(p) { gen_action("piece", p) } +function gen_action_resources(faction) { + gen_action("resources", faction) +} + function gen_action_space(s) { gen_action("space", s) } @@ -1149,6 +1213,13 @@ function log_summary_remove(p) { log_summary("Removed % " + piece_name(p)) } +function logi_resources(faction, n) { + if (n > 0) + logi(faction_name[faction] + " Resources +" + n) + else + logi(faction_name[faction] + " Resources " + n) +} + function log_resources(faction, n) { if (n > 0) log(faction_name[faction] + " Resources +" + n + ".") -- cgit v1.2.3