diff options
author | Joël Simoneau <simoneaujoel@gmail.com> | 2024-11-02 08:29:32 -0400 |
---|---|---|
committer | Joël Simoneau <simoneaujoel@gmail.com> | 2024-11-02 08:29:32 -0400 |
commit | 8ded7faaaa113d749546edfb21113d43ed406623 (patch) | |
tree | b1d594934f67edd2fcf17eae2cbeab4df63dd3d3 /rules.js | |
parent | fe00f5d1a5232a9cfdff2c70bf8f55e292f4c3ea (diff) | |
download | vijayanagara-8ded7faaaa113d749546edfb21113d43ed406623.tar.gz |
Demand Obedience.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 57 |
1 files changed, 55 insertions, 2 deletions
@@ -403,6 +403,11 @@ function end_conscript_space() { game.state = "conscript" } +function goto_demand() { + init_command("Demand Obedience") + game.state = "demand" +} + function goto_govern() { init_command("Govern") game.state = "govern" @@ -539,6 +544,7 @@ states.command_decree = { build: goto_build, collect: goto_collect, conscript: goto_conscript, + demand: goto_demand, govern: goto_govern, march: goto_march, rally: goto_rally, @@ -657,6 +663,31 @@ states.conscript_space = { } } +states.demand = { + prompt() { + view.prompt = "Demand Obedience: Select a Controlled province with a Governor" + + if (can_select_cmd_space(0) && can_demand()) + for (let s = first_space; s <= last_space; ++s) + if (!is_selected_cmd_space(s) && can_demand_in_space(s)) + gen_action_space(s) + + view.actions.end_demand = prompt_end_cmd(1) + }, + space(s) { + push_undo() + select_cmd_space(s, 0) + add_resources(DS, SPACES[s].pop) + add_tributary(s) + to_obedient_space(s) + log_space(s, "Demand Obedience") + }, + end_demand() { + game.decree = 0 + game.state = "command_decree" + } +} + states.govern = { prompt() { view.prompt = "Govern: Select a Tributary, Controlled, Mongol Invader region or Dehli." @@ -1033,7 +1064,7 @@ function gen_any_decree() { if (game.current === DS) { view.actions.collect = can_collect() ? 1 : 0 // view.actions.campaign = can_campaign() ? 1 : 0 - // view.actions.demand = can_demand() ? 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 @@ -1053,6 +1084,17 @@ function can_build_in_space(s) { return has_piece(s, game.current, ELITE) && !has_piece(s, game.current, DISC) } +function can_demand() { + for (let s = first_space; s <= last_province; ++s) + if (can_demand_in_space(s)) + return true + return false +} + +function can_demand_in_space(s) { + return is_faction_control(s, DS) && has_piece(s, DS, ELITE) +} + function can_tax() { return tax_count() > 0 } @@ -1101,7 +1143,13 @@ function is_rebel(p) { function to_obedient(p) { let faction = piece_faction(p) let piece_index = p - first_piece[faction][ELITE] - game.rebel[faction] |= ~(1 << piece_index) + game.rebel[faction] &= ~(1 << piece_index) +} + +function to_obedient_space(s) { + for (let p of iter_rebel_elite()) + if (piece_space(p) === s) + to_obedient(p) } function to_rebel(p) { @@ -1784,6 +1832,11 @@ function* iter_faction_movable(faction) { } } +function* iter_rebel_elite() { + yield* iter_faction_pieces(BK, ELITE) + yield* iter_faction_pieces(VE, ELITE) +} + // === CONST === |