From a259fb59db9718c4d2ae41c9fa7e75134303b638 Mon Sep 17 00:00:00 2001 From: Joël Simoneau Date: Thu, 16 Jan 2025 20:47:17 -0500 Subject: Event 33 --- rules.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 11 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index d73afc4..ebbd942 100644 --- a/rules.js +++ b/rules.js @@ -258,7 +258,7 @@ exports.setup = function (seed, scenario, _options) { } function setup_deck() { - game.deck = [ 10, 37, 11, 2, 41, 3, 4, 5, 6, 7, 8, 9, 10, 1, 12, 13, 14 ] + game.deck = [ 33, 36, 10, 37, 11, 2, 41, 3, 4, 5, 6, 7, 8, 9, 10, 1, 12, 13, 14 ] } function setup_standard() { @@ -2482,6 +2482,19 @@ function is_qasbah(p) { return piece_name(p) === "Qasbah" } +/* EVENT SPECIFIC */ + +function has_majority_goa() { + let c = [ + count_faction_pieces(S_MAHARASHTRA, DS) + count_faction_pieces(S_KARNATAKA, DS), + count_faction_pieces(S_MAHARASHTRA, BK) + count_faction_pieces(S_KARNATAKA, BK), + count_faction_pieces(S_MAHARASHTRA, VE) + count_faction_pieces(S_KARNATAKA, VE) + ] + let max = Math.max(...c) + return c.filter(n => n === max).length > 1 ? 1 : c.indexOf(max) +} + + /* CAVALRY */ function available_cavalry() { @@ -3357,9 +3370,6 @@ function vm_goto(cmd, nop, dir, step) { } function vm_inst(a) { - console.log("In vm_inst with ", a) - console.log(game.vm) - console.log(CODE[game.vm.fp]) return CODE[game.vm.fp][game.vm.ip][a] } @@ -3408,6 +3418,18 @@ function vm_remove() { vm_next() } +function vm_repeat() { + game.vm.n = vm_operand(1) + vm_next() +} + +function vm_endrepeat() { + if (--game.vm.n === 0) + vm_next() + else + vm_goto(vm_repeat, vm_endrepeat, -1, 1) +} + function vm_return() { game.state = "vm_return" } @@ -3474,6 +3496,14 @@ states.vm_space = { }, } +function vm_save_space() { + game.vm._ss = game.vm.ss + game.vm._s = game.vm.s + game.vm.ss = [] + game.vm.s = -1 + vm_next() +} + // VM: PIECE ITERATOR function vm_piece() { @@ -3549,6 +3579,10 @@ function vm_place() { 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 @@ -3621,20 +3655,27 @@ function vm_resources() { states.vm_resources = { prompt() { - let f = vm_operand(1) - let n = vm_operand(2) + let skip = vm_operand(1) + let f = vm_operand(2) + let n = vm_operand(3) if (n >= 0) event_prompt(`${faction_name[f]} +${n} Resources.`) else event_prompt(`${faction_name[f]} ${n} Resources.`) gen_action_resources(f) + + if (skip) + view.actions.skip = 1 }, resources(f) { - let n = vm_operand(2) + let n = vm_operand(3) log_resources(f, n) add_resources(f, n) vm_next() }, + skip() { + vm_next() + } } // === CONST === @@ -3789,7 +3830,6 @@ CODE[9 * 2 + 1] = [ // EVENT 10 CODE[10 * 2 + 0] = [ - [ vm_current, DS ], [ vm_prompt, "Move up to 4 Delhi Sultanate Units into adjacent Provinces." ], [ vm_piece, true, 0, 4, (p,s)=>is_ds_unit(p) ], [ vm_prompt, "Move Delhi Sultanate Unit into an adjacent space." ], @@ -3797,12 +3837,13 @@ CODE[10 * 2 + 0] = [ [ vm_move ], [ vm_endspace ], [ vm_endpiece ], - [ vm_resources, DS, -5 ], + [ vm_resources, false, DS, -5 ], [ vm_return ], ] // SHADED 10 CODE[10 * 2 + 1] = [ + [ vm_current, DS ], [ vm_prompt, "Move any Qasbah to Spaces containing Governors." ], [ vm_piece, false, 0, 999, (p,s)=>is_qasbah(p) ], [ vm_space, true, 1, 1, (s)=>has_governor(s) && !has_qasbah(s) ], @@ -4085,13 +4126,21 @@ CODE[32 * 2 + 1] = [ // EVENT 33 CODE[33 * 2 + 0] = [ - [ vm_log, "NOT IMPLEMENTED" ], + [ vm_current, ()=>(has_majority_goa()) ], + [ vm_prompt, "Remove up to 3 Opposing Units adjacent to Goa." ], + [ vm_piece, false, 0, 3, (p,s)=>(is_adjacent_to_city(C_GOA, piece_space(p))) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_resources, false, ()=>(game.current), 2 ], [ vm_return ], ] // SHADED 33 CODE[33 * 2 + 1] = [ - [ vm_log, "NOT IMPLEMENTED" ], + [ vm_current, DS ], + [ vm_prompt, "Reduce Rebel Factions Resources by half." ], + [ vm_resources, true, BK, ()=>(-Math.floor(game.resources[BK]/2)) ], + [ vm_resources, true, VE, ()=>(-Math.floor(game.resources[VE]/2)) ], [ vm_return ], ] -- cgit v1.2.3