diff options
author | Joël Simoneau <simoneaujoel@gmail.com> | 2025-03-12 21:56:40 -0400 |
---|---|---|
committer | Joël Simoneau <simoneaujoel@gmail.com> | 2025-03-12 21:56:40 -0400 |
commit | d0f0043856c05396e5928a8f03f255d138873fc3 (patch) | |
tree | cd8aa338778b581b2a38764793ac002f4dcb352d | |
parent | 9bef81cf84e71cfd0af255a68d1351e52b8d829e (diff) | |
download | vijayanagara-d0f0043856c05396e5928a8f03f255d138873fc3.tar.gz |
Bug Hunting.
-rw-r--r-- | rules.js | 118 |
1 files changed, 73 insertions, 45 deletions
@@ -397,6 +397,7 @@ function reset_cmd() { free: 0, spaces: [], pieces: [], + selected: [], where: -1, pass: 1 } @@ -463,9 +464,11 @@ function goto_amass() { } function goto_cavalry(n, next) { - game.cav = { - "n": n, - "next": next + if (typeof n !== "undefined") { + game.cav = { + "n": n, + "next": next + } } push_summary() @@ -479,16 +482,26 @@ function goto_cavalry(n, next) { if (game.cav.n !== 0) game.state = "cavalry" else { - if (game.vm) { - if (is_succession()) - pop_summary() - else - upop_summary() - vm_next() - } else { + end_cavalry() + } +} + +function end_cavalry() { + if (game.vm) { + if (is_succession()) pop_summary() - game.states = game.cav.next - } + else + upop_summary() + vm_next() + } else if (game.cav.next) { + pop_summary() + if (typeof game.cav.next === "function") + game.cav.next() + else + game.state = game.cav.next + } else { + pop_summary() + goto_eligible() } } @@ -607,17 +620,18 @@ states.eligible = { disable_negotiation: true, inactive: "Eligible Faction", prompt() { - if (did_option(SOP_COMMAND_DECREE)) { - view.prompt = `${data.card_title[this_card()]}: Event or Command.` + if (!did_option(SOP_COMMAND_DECREE) && !did_option(SOP_EVENT_OR_COMMAND)) { + view.prompt = `${data.card_title[this_card()]}: Event or Command & Decree.` + view.actions.command_decree = 1 view.actions.event_command = 1 - } else if (did_option(SOP_EVENT_OR_COMMAND)) { + } else if (!did_option(SOP_COMMAND_DECREE)) { view.prompt = `${data.card_title[this_card()]}: Command & Decree.` view.actions.command_decree = 1 - } else { - view.prompt = `${data.card_title[this_card()]}: Event or Command & Decree.` - view.actions.command_decree = 1 + } else if (!did_option(SOP_EVENT_OR_COMMAND)) { + view.prompt = `${data.card_title[this_card()]}: Event or Command.` view.actions.event_command = 1 - } + } else + view.prompt = `${data.card_title[this_card()]}: Limited Command.` view.actions.lim_command = 1 view.actions.pass = 1 view.actions.undo = 0 @@ -647,7 +661,7 @@ states.main_phase = { inactive: "Eligible Faction", prompt() { if (game.cmd && game.cmd.limited === 1) { - view.prompt = "Select a limited Command." + view.prompt = "Select a Limited Command." gen_any_command() } else if (game.cmd && game.decree && game.decree.n === 1) { view.prompt = "Select a Command and a Decree." @@ -704,37 +718,26 @@ states.cavalry = { log_summary_cavalry(c) set_cavalry_faction(c, game.current) }, - end_cavalry() { - if (game.vm) { - upop_summary() - vm_next() - } else if (game.cav.next) { - pop_summary() - game.state = game.cav.next - } else { - pop_summary() - goto_eligible() - } - } + end_cavalry: end_cavalry } states.compromising_gifts = { prompt() { - view.prompt = "Compromising gifts: Reduce your influence by one to gain two Resources and two Cavalry tokens" + view.prompt = "Compromising gifts: Reduce your influence by one to gain two Resources and two Cavalry tokens." gen_action_influence(game.current) view.actions.end_gifts = 1 }, influence(f) { log_h2(faction_acronyms[f] + "Compromising Gifts") - logi_resources(f, 2) + log_resources(f, 2) add_resources(f, 2) game.inf_shift = { - "next": "cavalry", + "next": goto_cavalry, } game.cav = { "n": 2, - "next": null + "next": end_card } remove_influence(f) }, @@ -745,18 +748,22 @@ states.compromising_gifts = { states.demand = { prompt() { - view.prompt = "Demand Obedience: Select a Controlled province with a Governor" + view.prompt = "Demand Obedience: Select a Controlled province with a Governor." - if (can_select_cmd_space(0) && can_demand()) + if (can_demand()) for (let s = first_space; s <= last_space; ++s) - if (!is_selected_cmd_space(s) && can_demand_in_space(s)) + if (!is_selected_decree_space(s) && can_demand_in_space(s)) gen_action_space(s) - view.actions.end_demand = prompt_end_cmd(1) + if (game.decree.spaces.length > 0) + view.actions.end_demand = 1 + + if (!view.actions.space) + view.prompt = "Demand Obedience: Done." }, space(s) { push_undo() - select_cmd_space(s, 0) + select_decree_space(s) demand_obedience_in_space(s) }, end_demand: end_decree, @@ -979,6 +986,11 @@ function select_cmd_space(s, cost) { game.cmd.where = s } +function select_decree_space(s) { + set_add(game.decree.spaces, s) + game.decree.where = s +} + function can_march() { for (let s = first_space; s <= last_space; ++s) if (can_march_in_space(s)) @@ -1670,7 +1682,7 @@ states.migrate = { prompt() { view.prompt = "Migrate: Select a Province as the Migrate destination." - if (can_select_cmd_space(1) && can_rally()) + if (can_select_cmd_space(1) && can_migrate()) for (let s = first_space; s <= last_province; ++s) if (!is_selected_cmd_space(s) && can_migrate_in_space(s)) gen_action_space(s) @@ -1884,7 +1896,9 @@ function init_decree(type) { if (!is_succession()) push_undo() log_h2(faction_name[game.current] + " - " + type) - game.decree = {} + game.decree = { + spaces: [], + } game.decree.type = type } @@ -1953,6 +1967,7 @@ function goto_collect() { } states.collect = { + inactive: "Collect Tribute", prompt() { view.prompt = `Collect Tribute: Collect ${collect_count()} from half the Tributaries prosperity` if (game.decree.count > 0) @@ -2449,6 +2464,7 @@ function can_amass() { } states.amass = { + inactive: "Amass", prompt() { view.prompt = "Amass: Place up to three invaders into the Mountain Passes" @@ -2502,6 +2518,7 @@ function can_mi_attack() { } states.mi_attack = { + inactive: "Attack & Plunder", prompt() { view.prompt = "Attack & Plunder: Select a Space to attack the Sultanate units and plunder resources." @@ -2521,6 +2538,7 @@ states.mi_attack = { } states.plunder = { + inactive: "Attack & Plunder", prompt() { let n = Math.min(game.resources[DS] - 3, count_pieces(game.cmd.where, MI, TROOPS)) view.prompt = `Attack & Plunder: Plunder ${n} resources from the Delhi Sultanate!` @@ -2558,6 +2576,7 @@ function has_troops_in_provinces() { } states.plunder_remove = { + inactive: "Attack & Plunder", prompt() { if (game.cmd.count > 0 && has_troops_in_provinces()) { view.prompt = `Attack & Plunder: Remove ${game.cmd.count} Troops from any Provinces.` @@ -2858,6 +2877,10 @@ function is_selected_cmd_space(s) { return game.cmd.spaces && set_has(game.cmd.spaces, s) } +function is_selected_decree_space(s) { + return game.decree.spaces && set_has(game.decree.spaces, s) +} + function place_piece(p, s) { if (piece_space(p) === AVAILABLE) p = find_piece(AVAILABLE, piece_faction(p), piece_type(p)) @@ -3120,8 +3143,12 @@ function remove_influence(faction) { function end_influence() { if (game.vm) vm_next() - else - game.state = game.inf_shift.next + else { + if (typeof game.inf_shift.next === "function") + game.inf_shift.next() + else + game.state = game.inf_shift.next + } } function troops_to_inf_track(faction, s) { @@ -3152,6 +3179,7 @@ function goto_return_troops(faction, n_troops, s) { } states.return_troops = { + inactive: "Returning Troops", prompt() { if (game.inf_shift.n > 0) { |