diff options
author | Joël Simoneau <simoneaujoel@gmail.com> | 2025-01-22 22:48:20 -0500 |
---|---|---|
committer | Joël Simoneau <simoneaujoel@gmail.com> | 2025-01-22 22:48:20 -0500 |
commit | a81a0848e12f736a009d7b377ccfac1b6f2003ea (patch) | |
tree | ce56421ad4a575f4a1ecffc32f7748f2fa7c4491 | |
parent | a08c374cda70b94d0e8b5c48df862108180424c4 (diff) | |
download | vijayanagara-a81a0848e12f736a009d7b377ccfac1b6f2003ea.tar.gz |
Event 23.
-rw-r--r-- | const.js | 1 | ||||
-rw-r--r-- | events.txt | 24 | ||||
-rw-r--r-- | rules.js | 87 |
3 files changed, 95 insertions, 17 deletions
@@ -17,6 +17,7 @@ const NAME_SOLO = "Solo" const DISC = 0 const ELITE = 1 const TROOPS = 2 +const UNITS = [TROOPS, ELITE] // Pieces status const AVAILABLE = -1 @@ -237,10 +237,30 @@ SHADED 22 log "NOT IMPLEMENTED" EVENT 23 - log "NOT IMPLEMENTED" + current VE + prompt "Build and then replace a Unit with a Raja in each Province with a Temple." + add_influence VE + space 1 can_build_in_space(s) + free_build + endspace + prompt "In each Province with a Temple, replace a Unit with a Raja." + space all has_temple(s) && has_units_enemy_faction(s) + piece 1 is_enemy_unit(p) && is_piece_in_event_space(p) + remove + auto_place VE ELITE + endpiece + endspace SHADED 23 - log "NOT IMPLEMENTED" + prompt "Place 4 Units in a Province with a Temple." + space_opt 1 has_temple(s) + place_opt 4 (game.current) UNITS + prompt "Remove the Temple." + piece 1 (is_temple(p) && is_piece_in_event_space(p)) + remove + endpiece + endspace + steal (game.current) VE 2 EVENT 24 log "NOT IMPLEMENTED" @@ -258,7 +258,7 @@ exports.setup = function (seed, scenario, _options) { } function setup_deck() { - game.deck = [ 19, 8, 7, 6, 5, 3, 36, 10, 37, 11, 2, 10, 1, 12, 13, 14 ] + game.deck = [ 19, 23, 8, 7, 6, 5, 3, 36, 10, 37, 11, 2, 10, 1, 12, 13, 14 ] } function setup_standard() { @@ -2328,6 +2328,19 @@ function count_faction_pieces(s, faction) { } } +function count_faction_units(s, faction) { + switch (faction) { + case DS: + return count_pieces(s, DS, TROOPS) + count_pieces(s, DS, ELITE) + case BK: + return count_pieces(s, BK, ELITE) + case VE: + return count_pieces(s, VE, ELITE) + case MI: + return count_pieces(s, MI, TROOPS) + } +} + function has_majority(s) { let d = count_faction_pieces(s, DS) let b = count_faction_pieces(s, BK) @@ -2369,6 +2382,12 @@ function has_piece_enemy_faction(s, faction) { .some(f => count_faction_pieces(s, f) > 0) } +function has_units_enemy_faction(s, faction) { + return FACTIONS + .filter(f => f != faction) + .some(f => count_faction_units(s, f) > 0) +} + function has_unmoved_piece(space, faction) { let unmoved = false for_each_movable(faction, p => { @@ -2506,6 +2525,10 @@ function has_qasbah(s) { return has_piece(s, DS, DISC) } +function has_temple(s) { + return has_piece(s, VE, DISC) +} + function has_ds_unit(s) { return has_piece(s, DS, ELITE) || has_piece(s, DS, TROOPS) } @@ -2518,6 +2541,10 @@ function is_enemy_piece(p) { return piece_faction(p) !== game.current } +function is_enemy_unit(p) { + return is_enemy_piece(p) && piece_type(p) !== DISC +} + function is_piece(p, faction, type) { return p >= first_piece[faction][type] && p <= last_piece[faction][type] } @@ -2534,6 +2561,10 @@ function is_qasbah(p) { return piece_name(p) === "Qasbah" } +function is_temple(p) { + return piece_name(p) === "Temple" +} + function is_piece_in_event_space(p) { return piece_space(p) === game.vm.s } @@ -3354,6 +3385,7 @@ function goto_vm(proc) { ss: [], s: -1, pp: [], + pl: [], p: -1, m: 0, } @@ -3421,6 +3453,7 @@ states.vm_current = { function vm_exec() { + console.log(game.vm.ip) vm_inst(0)() } @@ -3631,7 +3664,7 @@ function vm_piece() { game.state = "vm_piece" } else { pop_vm_prompt() - game.vm.pp = [] + game.vm.pl = [] game.vm.p = -1 vm_goto(vm_endpiece, vm_piece, 1, 1) } @@ -3698,17 +3731,12 @@ function vm_auto_place() { function vm_place() { if (can_vm_place()) { push_summary() - game.vm.pp = [] game.state = "vm_place" } else { vm_next() } } -function vm_place_space() { - game.vm.s = vm_operand() -} - function can_vm_place_imp(s, faction, type) { if (!can_stack_piece(s, faction, type)) return false @@ -3743,16 +3771,24 @@ function can_vm_place() { states.vm_place = { prompt() { let skip = vm_inst(2) - let n = vm_inst(3) - game.vm.pp.length + let n = vm_inst(3) - game.vm.pl.length let faction = vm_operand(4) let type = vm_operand(5) let where = SPACE_NAME[game.vm.s] let possible = false view.where = game.vm.s - event_prompt(`Place up to ${n} ${PIECE_FACTION_TYPE_NAME[faction][type]} in ${where}.`) - if (gen_place_piece(faction, type)) + if (typeof type === "object") { + event_prompt(`Place up to ${n} Units in ${where}.`) + for (let t of type) + if (gen_place_piece(faction, t)) + possible = true + } else { + event_prompt(`Place up to ${n} ${PIECE_FACTION_TYPE_NAME[faction][type]} in ${where}.`) + if (gen_place_piece(faction, type)) possible = true + } + if (skip || !possible) view.actions.skip = 1 }, @@ -3760,10 +3796,10 @@ states.vm_place = { if (vm_inst(1)) push_undo() log_summary_place(p) - let pp = place_piece(p, game.vm.s) - set_add(game.vm.pp, pp) + let pl = place_piece(p, game.vm.s) + set_add(game.vm.pl, pl) - if (vm_inst(3) - game.vm.pp.length === 0) { + if (vm_inst(3) - game.vm.pl.length === 0) { placed_summary() vm_next() } @@ -3907,6 +3943,7 @@ const NAME_SOLO = "Solo" const DISC = 0 const ELITE = 1 const TROOPS = 2 +const UNITS = [TROOPS, ELITE] // Pieces status const AVAILABLE = -1 @@ -4301,13 +4338,33 @@ CODE[22 * 2 + 1] = [ // EVENT 23 CODE[23 * 2 + 0] = [ - [ vm_log, "NOT IMPLEMENTED" ], + [ vm_current, VE ], + [ vm_prompt, "Build and then replace a Unit with a Raja in each Province with a Temple." ], + [ vm_add_influence, VE ], + [ vm_space, true, 1, 1, (s)=>can_build_in_space(s) ], + [ vm_free_build ], + [ vm_endspace ], + [ vm_prompt, "In each Province with a Temple, replace a Unit with a Raja." ], + [ vm_space, true, 999, 999, (s)=>has_temple(s) && has_units_enemy_faction(s) ], + [ vm_piece, false, 1, 1, (p,s)=>is_enemy_unit(p) && is_piece_in_event_space(p) ], + [ vm_remove ], + [ vm_auto_place, false, 0, false, VE, ELITE ], + [ vm_endpiece ], + [ vm_endspace ], [ vm_return ], ] // SHADED 23 CODE[23 * 2 + 1] = [ - [ vm_log, "NOT IMPLEMENTED" ], + [ vm_prompt, "Place 4 Units in a Province with a Temple." ], + [ vm_space, true, 0, 1, (s)=>has_temple(s) ], + [ vm_place, false, 1, 4, ()=>(game.current), UNITS ], + [ vm_prompt, "Remove the Temple." ], + [ vm_piece, false, 1, 1, (p,s)=>(is_temple(p) && is_piece_in_event_space(p)) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_steal, ()=>(game.current), VE, 2 ], [ vm_return ], ] |