diff options
author | Joël Simoneau <simoneaujoel@gmail.com> | 2025-02-01 08:23:15 -0500 |
---|---|---|
committer | Joël Simoneau <simoneaujoel@gmail.com> | 2025-02-01 08:23:15 -0500 |
commit | 69a05275bb9cda58fe8c561c79ca6f6ab8eb16d4 (patch) | |
tree | 1223aa0ae5708ae9674f5bffb5c4d6eda3ce34f8 | |
parent | 36e49ee394e1df50e5434051f33d1d5a3eef0d5d (diff) | |
download | vijayanagara-69a05275bb9cda58fe8c561c79ca6f6ab8eb16d4.tar.gz |
Event 14.
-rw-r--r-- | events.txt | 24 | ||||
-rw-r--r-- | rules.js | 93 |
2 files changed, 101 insertions, 16 deletions
@@ -167,10 +167,30 @@ SHADED 13 log "NOT IMPLEMENTED" EVENT 14 - log "NOT IMPLEMENTED" + current VE + gain_cavalry 2 + asm game.vm.count = 0 + repeat 2 + prompt `Place up to ${2-game.vm.count} Rajas adjacent to Vijayanagara.` + space_opt 1 is_adjacent_to_city(C_VIJAYANAGARA, s) && can_place_piece(s, VE, ELITE) + auto_place VE ELITE + asm (game.vm.count += 1) + endspace + endrepeat + prompt "Remove a Tributary marker in a Province adjacent to Vijayanagara." + space_opt 1 is_adjacent_to_city(C_VIJAYANAGARA, s) && is_tributary(s) + remove_tributary + endspace SHADED 14 - log "NOT IMPLEMENTED" + current DS + gain_cavalry 3 + prompt "Place up to 4 Troops and 1 Governor in a province adjacent to Vijayanagara and Demand Obedience there." + space_opt 1 is_adjacent_to_city(C_VIJAYANAGARA, s) + place_opt 4 DS TROOPS + place_opt 1 DS ELITE + demand_obedience + endspace EVENT 15 prompt "Replace Governors with Rebelling Amirs in Provinces adjacent to Devagiri." @@ -422,7 +422,24 @@ function goto_cavalry(n, next) { "n": n, "next": next } - game.state = "cavalry" + push_summary() + + while (game.cav.n > 0 && n_available_cavalry() > 0) { + let c = find_cavalry(AVAILABLE) + log_summary_cavalry(c) + set_cavalry_faction(c, game.current) + game.cav.n -= 1 + } + + if (game.cav.n !== 0) + game.state = "cavalry" + else { + pop_summary() + if (game.vm) + vm_next() + else + game.states = game.cav.next + } } function goto_compromising_gifts() { @@ -642,11 +659,14 @@ states.cavalry = { }, token(c) { game.cav.n -= 1 + log_summary_cavalry(c) set_cavalry_faction(c, game.current) - // TODO: cavalry log }, end_cavalry() { - if (game.cav.next) + pop_summary() + if (game.vm) + vm_next() + else if (game.cav.next) game.state = game.cav.next else goto_eligible() @@ -692,14 +712,18 @@ states.demand = { 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") + demand_obedience_in_space(s) }, end_demand: end_decree, } +function demand_obedience_in_space(s) { + add_resources(DS, SPACES[s].pop) + add_tributary(s) + to_obedient_space(s) + log_space(s, "Demand Obedience") +} + states.march = { prompt() { view.prompt = "March: Select a space to move into." @@ -1317,7 +1341,7 @@ function goto_conscript_space() { states.conscript = { prompt() { - view.prompt = "Conscript: Select Tributaries, Qasbah or Dehli to place troops." + view.prompt = "Conscript: Select Tributaries, Qasbah or Delhi to place troops." if (can_select_cmd_space(1) && can_conscript()) { for (let s = first_space; s <= last_space; ++s) { @@ -1403,7 +1427,7 @@ function goto_govern_space() { states.govern = { prompt() { - view.prompt = "Govern: Select a Tributary, Controlled, Mongol Invader region or Dehli." + view.prompt = "Govern: Select a Tributary, Controlled, Mongol Invader region or Delhi." if (can_select_cmd_space(1) && can_govern()) for (let s = first_space; s <= last_space; ++s) @@ -2629,7 +2653,7 @@ function n_province_with_both_rebels() { /* CAVALRY */ -function available_cavalry() { +function n_available_cavalry() { let n = 0 for (let c = 0; c <= LAST_CAVALRY; ++c) if (game.cavalry[c] === AVAILABLE) @@ -2973,6 +2997,14 @@ function log_summary_remove(p) { log_summary("Removed % " + piece_name(p)) } +function log_summary_cavalry(c) { + let from = game.cavalry[c] + if (from !== AVAILABLE) + log_summary(faction_acronyms[game.current] + " Cavalry + % from " + faction_acronyms[from] + ".") + else + log_summary(faction_acronyms[game.current] + " Cavalry + % from supply.") +} + function logi_resources(faction, n) { if (n > 0) logi(faction_acronyms[faction] + " Resources +" + n) @@ -2997,7 +3029,6 @@ function set_piece_space(p, s) { game.pieces[p] = s } - /* COMMON LIBRARY */ function clear_undo() { @@ -3810,7 +3841,7 @@ function vm_place() { function can_vm_place_imp(s, faction, type) { if (!can_stack_piece(s, faction, type)) return false - if (game.current === faction) + if (game.current === faction) // TODO: PLACE ONLY IF AVAILABLE return true return has_piece(AVAILABLE, faction, type) } @@ -3884,6 +3915,12 @@ states.vm_place = { }, } +// VM: GAIN_CAVALRY + +function vm_gain_cavalry() { + goto_cavalry(vm_operand(1), "") +} + // VM: INFLUENCE function vm_add_influence() { @@ -3987,6 +4024,14 @@ function vm_free_compel() { goto_compel_space() } +// VM: DEMAND_OBEDIENCE + +function vm_demand_obedience() { + if (can_demand_in_space(game.vm.s)) + demand_obedience_in_space(game.vm.s) + vm_next() +} + // VM: GOVERN function vm_free_govern() { @@ -4310,13 +4355,33 @@ CODE[13 * 2 + 1] = [ // EVENT 14 CODE[14 * 2 + 0] = [ - [ vm_log, "NOT IMPLEMENTED" ], + [ vm_current, VE ], + [ vm_gain_cavalry, 2 ], + [ vm_asm, ()=>game.vm.count = 0 ], + [ vm_repeat, 2 ], + [ vm_prompt, ()=>`Place up to ${2-game.vm.count} Rajas adjacent to Vijayanagara.` ], + [ vm_space, true, 0, 1, (s)=>is_adjacent_to_city(C_VIJAYANAGARA, s) && can_place_piece(s, VE, ELITE) ], + [ vm_auto_place, false, 0, false, VE, ELITE ], + [ vm_asm, ()=>(game.vm.count += 1) ], + [ vm_endspace ], + [ vm_endrepeat ], + [ vm_prompt, "Remove a Tributary marker in a Province adjacent to Vijayanagara." ], + [ vm_space, true, 0, 1, (s)=>is_adjacent_to_city(C_VIJAYANAGARA, s) && is_tributary(s) ], + [ vm_remove_tributary ], + [ vm_endspace ], [ vm_return ], ] // SHADED 14 CODE[14 * 2 + 1] = [ - [ vm_log, "NOT IMPLEMENTED" ], + [ vm_current, DS ], + [ vm_gain_cavalry, 3 ], + [ vm_prompt, "Place up to 4 Troops and 1 Governor in a province adjacent to Vijayanagara and Demand Obedience there." ], + [ vm_space, true, 0, 1, (s)=>is_adjacent_to_city(C_VIJAYANAGARA, s) ], + [ vm_place, false, 1, 4, DS, TROOPS ], + [ vm_place, false, 1, 1, DS, ELITE ], + [ vm_demand_obedience ], + [ vm_endspace ], [ vm_return ], ] |