diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-03-18 00:23:28 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-05-03 18:48:16 +0200 |
commit | ab7f13b30af38ab6b91a106552f572c56efbb8db (patch) | |
tree | c852ad9b2752ef9da9e89de879e0484e3150f00d | |
parent | 56f3ff6f7b24dfa8968c9b813be8fae371717063 (diff) | |
download | andean-abyss-ab7f13b30af38ab6b91a106552f572c56efbb8db.tar.gz |
Event programs.
-rw-r--r-- | play.js | 1 | ||||
-rw-r--r-- | rules.js | 765 | ||||
-rw-r--r-- | tools/events.txt | 644 | ||||
-rw-r--r-- | tools/gencode.py | 72 |
4 files changed, 1474 insertions, 8 deletions
@@ -1056,6 +1056,7 @@ function on_update() { action_button("end_activity", "End Activity") action_button("end_operation", "End Op") + action_button("end_event", "End Event") action_button("next", "Next") action_button("deny", "Deny") @@ -71,6 +71,8 @@ const space_name = data.space_name const first_piece = data.first_piece const last_piece = data.last_piece +const all_first_piece = 0 +const all_last_piece = 152 const first_space = data.first_space const last_space = data.last_space @@ -658,6 +660,10 @@ function count_bases(s) { ) } +function can_place_base(s) { + return count_bases(s) < 2 +} + function count_cubes(s) { return ( count_pieces(s, GOVT, TROOPS) + @@ -1028,27 +1034,27 @@ function is_neutral(s) { return is_pop(s) && game.support[s] === NEUTRAL } -function has_passive_support(s) { +function is_passive_support(s) { return is_pop(s) && game.support[s] === PASSIVE_SUPPORT } -function has_passive_opposition(s) { +function is_passive_opposition(s) { return is_pop(s) && game.support[s] === PASSIVE_OPPOSITION } -function has_active_support(s) { +function is_active_support(s) { return is_pop(s) && game.support[s] === ACTIVE_SUPPORT } -function has_active_opposition(s) { +function is_active_opposition(s) { return is_pop(s) && game.support[s] === ACTIVE_OPPOSITION } -function has_support(s) { +function is_support(s) { return is_pop(s) && game.support[s] > 0 } -function has_opposition(s) { +function is_opposition(s) { return is_pop(s) && game.support[s] < 0 } @@ -1152,6 +1158,7 @@ function gen_place_piece(space, faction, type) { break } } + // TODO if (!done && faction === game.current) if (!done) for (let p = p0; p <= p1; ++p) if (game.pieces[p] !== space || (type === GUERRILLA && !is_underground(p))) @@ -3613,9 +3620,9 @@ function goto_extort() { game.sa = { save: game.state, spaces: [], - // where: -1, // for extort2 + where: -1, // for extort2 } - game.state = "extort1" + game.state = "extort2" } states.extort1 = { @@ -4213,6 +4220,11 @@ function execute_event() { let c = this_card() log(`C${c} - Event`) + if (UNSHADED_START[c] >= 0) { + goto_vm(UNSHADED_START[c]) + return + } + log("TODO") resume_event_card() } @@ -4228,6 +4240,13 @@ function execute_unshaded_event() { return } + console.log("UNSHADED", c, UNSHADED_START[c]) + + if (UNSHADED_START[c] >= 0) { + goto_vm(UNSHADED_START[c]) + return + } + log("TODO") resume_event_card() } @@ -4259,10 +4278,320 @@ function execute_shaded_event() { return } + console.log("SHADED", c, SHADED_START[c]) + + if (SHADED_START[c] >= 0) { + goto_vm(SHADED_START[c]) + return + } + log("TODO") resume_event_card() } +// === EVENT VM === + +function goto_vm(start) { + game.state = "vm" + game.vm = { + pc: start, + ss: [], + s: 0, + pp: [], + p: 0, + die: 0, + } + vm_exec() +} + +function vm_exec() { + CODE[game.vm.pc][0]() +} + +function vm_operand(a) { + a = CODE[game.vm.pc][a] + if (typeof a === "function") + return a() + return a +} + +function vm_next() { + game.vm.pc ++ + vm_exec() +} + +function vm_goto(op, dir, step) { + while (CODE[game.vm.pc][0] !== op) + game.vm.pc += dir + game.vm.pc += step + vm_exec() +} + +function vm_endevent() { + game.state = "vm_endevent" +} + +function vm_space() { + if (can_vm_space()) { + game.state = "vm_space" + } else { + game.vm.ss = [] + vm_goto(vm_endspace, 1, 1) + } +} + +function vm_endspace() { + vm_goto(vm_space, -1, 0) +} + +function can_vm_space() { + let n = CODE[game.vm.pc][1] + let f = CODE[game.vm.pc][2] + if (n > 0 && game.vm.ss.length >= n) + return false + for (let s = first_space; s <= last_space; ++s) + if (!set_has(game.vm.ss, s) && f(s)) + return true + return false +} + +states.vm_space = { + prompt() { + let n = CODE[game.vm.pc][1] + let f = CODE[game.vm.pc][2] + for (let s = first_space; s <= last_space; ++s) + if (!set_has(game.vm.ss, s) && f(s)) + gen_action_space(s) + }, + space(s) { + push_undo() + set_add(game.vm.ss, s) + game.vm.s = s + vm_next() + }, +} + +function vm_piece() { + if (can_vm_piece()) { + game.state = "vm_piece" + } else { + game.vm.pp = [] + vm_goto(vm_endpiece, 1, 1) + } +} + +function can_vm_piece() { + let n = CODE[game.vm.pc][1] + let f = CODE[game.vm.pc][2] + if (n > 0 && game.vm.pp.length >= n) + return false + for (let p = all_first_piece; p <= all_last_piece; ++p) + if (game.pieces[p] >= 0 && !set_has(game.vm.pp, p) && f(p, game.pieces[p])) + return true + return false +} + +states.vm_piece = { + prompt() { + let n = CODE[game.vm.pc][1] + let f = CODE[game.vm.pc][2] + view.prompt = "Select piece." + for (let p = all_first_piece; p <= all_last_piece; ++p) + if (game.pieces[p] >= 0 && !set_has(game.vm.pp, p) && f(p, game.pieces[p])) + gen_action_piece(p) + }, + piece(p) { + push_undo() + set_add(game.vm.pp, p) + game.vm.p = p + vm_next() + }, +} + +function vm_endpiece() { + vm_goto(vm_piece, -1, 0) +} + +function vm_transfer() { + game.state = "vm_transfer" +} + +function vm_resources() { + game.state = "vm_resources" +} + +function vm_aid() { + game.state = "vm_aid" +} + +function vm_select_insurgent() { + game.state = "vm_select_insurgent" +} + +function vm_place() { + if (can_vm_place()) + game.state = "vm_place" + else + vm_next() +} + +function can_vm_place() { + let faction = vm_operand(1) + let type = vm_operand(2) + if (type === BASE && !can_place_base(game.vm.s)) + return false + if (game.current === faction) + return true + return has_piece(AVAILABLE, faction, type) +} + +states.vm_place = { + prompt() { + let faction = vm_operand(1) + let type = vm_operand(2) + view.prompt = `Place piece in ${space_name[game.vm.s]}.` + gen_place_piece(game.vm.s, faction, type) + }, + piece(p) { + place_piece(p, game.vm.s) + update_control() + vm_next() + }, +} + +function vm_place_any() { + if (can_vm_place_any()) + game.state = "vm_place_any" + else + vm_next() +} + +function vm_remove_shipment() { + game.state = "vm_remove_shipment" +} + +function vm_remove() { + remove_piece(game.vm.p) + update_control() + vm_next() +} + +function vm_remove_or_end() { + game.state = "vm_remove_or_end" +} + +function vm_activate() { + game.state = "vm_activate" +} + +function vm_underground() { + game.state = "vm_underground" +} + +function vm_set_active_support() { + game.support[game.vm.s] = ACTIVE_SUPPORT + vm_next() +} + +function vm_set_passive_support() { + game.support[game.vm.s] = PASSIVE_SUPPORT + vm_next() +} + +function vm_set_active_opposition() { + game.support[game.vm.s] = ACTIVE_OPPOSITION + vm_next() +} + +function vm_set_passive_opposition() { + game.support[game.vm.s] = PASSIVE_OPPOSITION + vm_next() +} + +function vm_set_neutral() { + game.support[game.vm.s] = NEUTRAL + vm_next() +} + +function vm_shift_support() { + if (game.support[game.vm.s] < 2) + game.support[game.vm.s] ++ + vm_next() +} + +function vm_shift_opposition() { + if (game.support[game.vm.s] > -2) + game.support[game.vm.s] -- + vm_next() +} + +function vm_current() { + game.current = vm_operand(1) + vm_next() +} + +function vm_terror() { + place_terror(game.vm.s) + vm_next() +} + +function vm_sabotage() { + place_sabotage(game.vm.s) + vm_next() +} + +function vm_ineligible() { + let faction = vm_operand(1) + log("TODO: ineligible " + faction_name[faction]) + vm_next() +} + +function vm_roll() { + // TODO: pause for button "Roll" ? + game.vm.die = random() + 1 + log("Rolled " + game.vm.die) + vm_next() +} + +states.vm_resources = { + prompt() { + let f = vm_operand(1) + let n = vm_operand(2) + view.prompt = `Add ${n} resources to ${faction_name[f]}.` + gen_action_resources(f) + }, + resources(f) { + push_undo() + let n = vm_operand(2) + add_resources(f, n) + vm_next() + }, +} + +states.vm_aid = { + prompt() { + let n = vm_operand(1) + view.prompt = `Add ${n} aid.` + view.actions.aid = 1 + }, + aid() { + push_undo() + let n = vm_operand(1) + add_aid(n) + vm_next() + }, +} + +states.vm_endevent = { + prompt() { + view.prompt = "Event: All done." + view.actions.end_event = 1 + }, + end_event() { + resume_event_card() + }, +} + // === GAME OVER === function goto_game_over(result, victory) { @@ -4412,6 +4741,7 @@ exports.view = function (state, role) { else view.prompt = "Unknown state: " + game.state + if (states[game.state]) if (!states[game.state].disable_negotiation) { view.actions.remove_pieces = 1 view.actions.ask_resources = 1 @@ -4724,3 +5054,422 @@ function map_delete(map, item) { } } } + +// === GENERATED EVENT CODE === +// :r !python3 tools/gencode.py +const CODE = [ + // EVENT 4 + [ vm_space, 3, (s)=>is_unsabotaged_pipeline(s) ], + [ vm_resources, GOVT, ()=>(2*data.spaces[game.vm.s].econ) ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 6 + [ vm_space, 2, (s)=>(!is_support(s) && is_adjacent_to_support(s)) ], + [ vm_set_passive_support ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 12 + [ vm_resources, GOVT, ()=>(Math.min(game.aid,20)) ], + [ vm_aid, 10 ], + [ vm_endevent ], + // EVENT 14 + [ vm_current, GOVT ], + [ vm_space, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], + [ vm_place, GOVT, BASE ], + [ vm_place, GOVT, TROOPS ], + [ vm_place, GOVT, TROOPS ], + [ vm_place, GOVT, TROOPS ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 15 + [ vm_roll ], + [ vm_resources, GOVT, ()=>(game.vm.die*4) ], + [ vm_endevent ], + // EVENT 17 + [ vm_resources, GOVT, ()=>(Math.min(game.aid,20)) ], + [ vm_aid, 6 ], + [ vm_endevent ], + // EVENT 18 + [ vm_resources, GOVT, ()=>(Math.min(game.aid,20)) ], + [ vm_aid, 20 ], + [ vm_endevent ], + // EVENT 21 + [ vm_resources, FARC, -6 ], + [ vm_piece, 1, (p,s)=>is_farc_base(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endevent ], + // EVENT 22 + [ vm_space, 1, (s)=>is_opposition(s) ], + [ vm_set_neutral ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 23 + [ vm_space, 1, (s)=>is_dept(s) ], + [ vm_piece, 0, (p,s)=>is_piece_in_event_space(p) && is_underground_guerrilla(p) ], + [ vm_activate ], + [ vm_endpiece ], + [ vm_piece, 0, (p,s)=>is_piece_in_event_space(p) && is_cartels_base(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 24 + [ vm_space, 1, (s)=>is_city(s) ], + [ vm_set_active_support ], + [ vm_endspace ], + [ vm_ineligible, FARC ], + [ vm_endevent ], + // EVENT 25 + [ vm_space, 1, (s)=>is_mountain(s) ], + [ vm_piece, 0, (p,s)=>is_piece_in_event_space(p) && is_farc_piece(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 28 + [ vm_space, 1, (s)=>is_next_to_venezuela(s) ], + [ vm_piece, 3, (p,s)=>is_piece_in_event_space(p) && is_insurgent_piece(p) ], + [ vm_remove_or_end ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 31 + [ vm_space, 2, (s)=>is_city(s) ], + [ vm_shift_support ], + [ vm_endspace ], + [ vm_space, 1, (s)=>is_dept(s) ], + [ vm_shift_support ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 32 + [ vm_space, 2, (s)=>is_neutral(s) || is_passive_opposition(s) ], + [ vm_set_passive_support ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 33 + [ vm_space, 1, (s)=>is_next_to_ecuador(s) ], + [ vm_piece, 3, (p,s)=>is_piece_in_event_space(p) && is_insurgent_piece(p) ], + [ vm_remove_or_end ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 38 + [ vm_space, 3, (s)=>has_cubes(s) || is_support(s) ], + [ vm_piece, 0, (p,s)=>is_piece_in_event_space(p) && is_auc_guerrilla(p) && is_active(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 39 + [ vm_space, 6, (s)=>is_dept(s) && !is_farc_zone(s) ], + [ vm_place, GOVT, POLICE ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 41 + [ vm_resources, AUC, -6 ], + [ vm_space, 1, (s)=>true ], + [ vm_piece, 0, (p,s)=>is_piece_in_event_space(p) && is_auc_piece(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 42 + [ vm_space, 2, (s)=>is_neutral(s) ], + [ vm_set_passive_support ], + [ vm_endspace ], + [ vm_resources, GOVT, 3 ], + [ vm_endevent ], + // EVENT 43 + [ vm_space, 1, (s)=>is_dept(s) && has_troops(s) ], + [ vm_terror, 2 ], + [ vm_piece, 0, (p,s)=>is_piece_in_event_space(p) && is_farc_base(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 44 + [ vm_space, 1, (s)=>is_city(s) && !is_opposition(s) ], + [ vm_set_active_support ], + [ vm_endspace ], + [ vm_resources, GOVT, 3 ], + [ vm_endevent ], + // EVENT 45 + [ vm_space, 0, (s)=>has_cubes(s) && has_terror(s) ], + [ vm_shift_support ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 50 + [ vm_current, GOVT ], + [ vm_space, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], + [ vm_place, GOVT, POLICE ], + [ vm_endspace ], + [ vm_space, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], + [ vm_place, GOVT, POLICE ], + [ vm_endspace ], + [ vm_space, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], + [ vm_place, GOVT, POLICE ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 52 + [ vm_space, 2, (s)=>is_city(s) || is_mountain(s) ], + [ vm_shift_support ], + [ vm_endspace ], + [ vm_endevent ], + // EVENT 55 + [ vm_remove_shipment ], + [ vm_remove_shipment ], + [ vm_piece, 5, (p,s)=>is_cartels_guerrilla(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_aid, 3 ], + [ vm_endevent ], + // EVENT 56 + [ vm_transfer, CARTELS, GOVT, 15 ], + [ vm_endevent ], + // EVENT 58 + [ vm_resources, CARTELS, -6 ], + [ vm_piece, 0, (p,s)=>is_cartels_guerrilla(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endevent ], + // EVENT 61 + [ vm_space, 1, (s)=>is_city(s) ], + [ vm_piece, 0, (p,s)=>is_piece_in_event_space(p) && is_cartels_piece(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_resources, CARTELS, -6 ], + [ vm_endevent ], + // EVENT 62 + [ vm_piece, 3, (p,s)=>is_insurgent_piece(p) && is_zero_pop_forest(s) ], + [ vm_remove_or_end ], + [ vm_endpiece ], + [ vm_endevent ], + // EVENT 66 + [ vm_piece, 3, (p,s)=>is_cartels_base(p) && is_forest(s) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endevent ], + // EVENT 67 + [ vm_resources, CARTELS, -20 ], + [ vm_endevent ], + // EVENT 70 + [ vm_space, 0, (s)=>is_forest(s) && !has_any_guerrilla(s) ], + [ vm_resources, GOVT, 6 ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 4 + [ vm_space, 3, (s)=>is_highest_value_pipeline_without_cubes(s) ], + [ vm_sabotage ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 5 + [ vm_space, 1, (s)=>is_adjacent_to_loc3(s) ], + [ vm_shift_opposition ], + [ vm_shift_opposition ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 8 + [ vm_resources, GOVT, -9 ], + [ vm_endevent ], + // SHADED 14 + [ vm_space, 1, (s)=>is_dept(s) ], + [ vm_piece, 1, (p,s)=>is_piece_in_event_space(p) && is_govt_base(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_piece, 1, (p,s)=>is_piece_in_event_space(p) && (is_troops(p) || is_police(p)) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 15 + [ vm_space, 1, (s)=>is_city() && (is_neutral(s) || is_passive_support(s)) ], + [ vm_set_passive_opposition ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 16 + [ vm_resources, GOVT, -10 ], + [ vm_endevent ], + // SHADED 18 + [ vm_resources, GOVT, -6 ], + [ vm_roll ], + [ vm_aid, ()=>(-game.vm.die) ], + [ vm_endevent ], + // SHADED 21 + [ vm_resources, FARC, 6 ], + [ vm_space, 1, (s)=>(is_city(s) || is_dept(s)) && can_place_base(s) ], + [ vm_place, FARC, BASE ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 23 + [ vm_current, GOVT ], + [ vm_piece, 3, (p,s)=>is_troops(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_ineligible, GOVT ], + [ vm_ineligible, FARC ], + [ vm_endevent ], + // SHADED 24 + [ vm_space, 1, (s)=>has_farc_piece(s) ], + [ vm_piece, 2, (p,s)=>is_piece_in_event_space(p) && is_troops(p) ], + [ vm_remove ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_space, 1, (s)=>is_support(s) ], + [ vm_set_neutral ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 25 + [ vm_space, 1, (s)=>s === ANTIOQUIA || set_has(data.spaces[ANTIOQUIA].adjacent, s) ], + [ vm_place_any, FARC ], + [ vm_place_any, FARC ], + [ vm_place_any, FARC ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 26 + [ vm_space, 0, (s)=>has_cartels_base(s) && has_farc_guerrilla(s) ], + [ vm_transfer, CARTELS, FARC, 6 ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 28 + [ vm_space, 1, (s)=>is_dept(s) && is_next_to_venezuela(s) && can_place_base(s) ], + [ vm_place, FARC, BASE ], + [ vm_endspace ], + [ vm_space, 0, (s)=>is_loc(s) && set_has(data.spaces[CUCUTA].adjacent, s) && is_empty(s) ], + [ vm_sabotage ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 31 + [ vm_space, 3, (s)=>is_passive_opposition(s) ], + [ vm_set_active_opposition ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 32 + [ vm_resources, FARC, 12 ], + [ vm_endevent ], + // SHADED 33 + [ vm_space, 1, (s)=>s === ECUADOR ], + [ vm_place_any, ()=>(game.current) ], + [ vm_place_any, ()=>(game.current) ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 34 + [ vm_select_insurgent ], + [ vm_space, 1, (s)=>is_zero_pop_dept(s) ], + [ vm_place, ()=>(game.current), GUERRILLA ], + [ vm_place, ()=>(game.current), GUERRILLA ], + [ vm_place, ()=>(game.current), BASE ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 35 + [ vm_space, 1, (s)=>is_dept(s) && has_cartels_base(s) ], + [ vm_shift_opposition ], + [ vm_shift_opposition ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 38 + [ vm_space, 0, (s)=>has_cubes(s) || is_support(s) ], + [ vm_piece, 0, (p,s)=>is_piece_in_event_space(p) && is_auc_guerrilla(p) && is_active(p) ], + [ vm_underground ], + [ vm_endpiece ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 41 + [ vm_space, 0, (s)=>has_auc_piece(s) && has_cartels_piece(s) ], + [ vm_resources, AUC, 3 ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 43 + [ vm_space, 1, (s)=>is_dept(s) && has_troosps(s) ], + [ vm_terror, 2 ], + [ vm_endspace ], + [ vm_aid, -9 ], + [ vm_endevent ], + // SHADED 44 + [ vm_space, 1, (s)=>is_city(s) && is_support(s) ], + [ vm_set_neutral ], + [ vm_endspace ], + [ vm_resources, GOVT, -3 ], + [ vm_endevent ], + // SHADED 45 + [ vm_space, 0, (s)=>has_auc_piece(s) ], + [ vm_aid, -1 ], + [ vm_endspace ], + [ vm_roll ], + [ vm_resources, GOVT, ()=>(-game.vm.die) ], + [ vm_endevent ], + // SHADED 48 + [ vm_space, 2, (s)=>s !== BOGOTA && is_city(s) ], + [ vm_shift_opposition ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 49 + [ vm_space, 1, (s)=>is_dept(s) ], + [ vm_place, AUC, GUERRILLA ], + [ vm_place, AUC, BASE ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 51 + [ vm_space, 3, (s)=>is_pipeline(s) && (has_farc_guerrilla(s) || adjacent_has_farc_guerrilla(s)) ], + [ vm_sabotage ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 52 + [ vm_space, 1, (s)=>has_auc_piece(s) && can_place_base(s) ], + [ vm_place, AUC, BASE ], + [ vm_endspace ], + [ vm_piece, 0, (p,s)=>is_auc_base(p) ], + [ vm_resources, AUC, 1 ], + [ vm_endpiece ], + [ vm_endevent ], + // SHADED 55 + [ vm_space, 3, (s)=>has_cartel_piece(s) ], + [ vm_shift_opposition ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 56 + [ vm_piece, 0, (p,s)=>is_cartels_piece(p) && is_city(s) ], + [ vm_resources, CARTELS, 2 ], + [ vm_endpiece ], + [ vm_space, 2, (s)=>is_city(s) && can_place_base(s) ], + [ vm_place, CARTELS, BASE ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 61 + [ vm_space, 3, (s)=>!has_cartels_piece(s) && can_place_base(s) ], + [ vm_place, CARTELS, BASE ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 62 + [ vm_space, 3, (s)=>s === GUAINIA || s === VAUPES || s === AMAZONAS ], + [ vm_place, CARTELS, BASE ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 64 + [ vm_piece, 0, (p,s)=>is_cartels_base(p) && is_city(s) ], + [ vm_resources, CARTELS, 2 ], + [ vm_endpiece ], + [ vm_piece, 0, (p,s)=>is_cartels_base(p) && is_dept(s) ], + [ vm_resources, CARTELS, 1 ], + [ vm_endpiece ], + [ vm_endevent ], + // SHADED 66 + [ vm_space, 0, (s)=>is_forest(s) && has_cartels_base(s) && can_place_base(s) ], + [ vm_place, CARTELS, BASE ], + [ vm_endspace ], + [ vm_endevent ], + // SHADED 68 + [ vm_piece, 0, (p,s)=>is_cartels_piece(p) && is_coastal_space(s) ], + [ vm_resources, CARTELS, 2 ], + [ vm_endpiece ], + [ vm_endevent ], + // SHADED 71 + [ vm_space, 1, (s)=>s === PANAMA ], + [ vm_place, ()=>(game.current), BASE ], + [ vm_place, ()=>(game.current), BASE ], + [ vm_endspace ], + [ vm_endevent ], +] +const UNSHADED_START = [-1,-1,-1,-1,0,-1,4,-1,-1,-1,-1,-1,8,-1,11,19,-1,22,25,-1,-1,28,33,37,46,51,-1,-1,57,-1,-1,63,70,74,-1,-1,-1,-1,80,86,-1,90,97,102,109,114,-1,-1,-1,-1,118,-1,129,-1,-1,133,140,-1,142,-1,-1,147,154,-1,-1,-1,158,162,-1,-1,164,-1] +const SHADED_START = [-1,-1,-1,-1,168,172,-1,-1,177,-1,-1,-1,-1,-1,179,188,192,-1,194,-1,-1,198,-1,203,210,219,225,-1,229,-1,-1,236,240,242,247,254,-1,-1,259,-1,-1,265,-1,269,274,279,-1,-1,285,289,-1,294,298,-1,-1,305,309,-1,-1,-1,-1,316,320,-1,324,-1,331,-1,335,-1,-1,339] diff --git a/tools/events.txt b/tools/events.txt new file mode 100644 index 0000000..2746b21 --- /dev/null +++ b/tools/events.txt @@ -0,0 +1,644 @@ +SHADED 26 + space 0 has_cartels_base(s) && has_farc_guerrilla(s) + transfer CARTELS FARC 6 + endspace + +EVENT 56 + transfer CARTELS GOVT 15 + +EVENT 4 + space 3 is_unsabotaged_pipeline(s) + resources GOVT (2*data.spaces[game.vm.s].econ) + endspace + +EVENT 12 + resources GOVT (Math.min(game.aid,20)) + aid 10 + +EVENT 15 + roll + resources GOVT (game.vm.die*4) + +EVENT 17 + resources GOVT (Math.min(game.aid,20)) + aid 6 + +EVENT 18 + resources GOVT (Math.min(game.aid,20)) + aid 20 + +EVENT 67 + resources CARTELS -20 + +EVENT 70 + space 0 is_forest(s) && !has_any_guerrilla(s) + resources GOVT 6 + endspace + +SHADED 8 + resources GOVT -9 + +SHADED 16 + resources GOVT -10 + +SHADED 18 + resources GOVT -6 + roll + aid (-game.vm.die) + +SHADED 32 + resources FARC 12 + +SHADED 41 + space 0 has_auc_piece(s) && has_cartels_piece(s) + resources AUC 3 + endspace + +SHADED 45 + space 0 has_auc_piece(s) + aid -1 + endspace + roll + resources GOVT (-game.vm.die) + +SHADED 64 + piece 0 is_cartels_base(p) && is_city(s) + resources CARTELS 2 + endpiece + piece 0 is_cartels_base(p) && is_dept(s) + resources CARTELS 1 + endpiece + +SHADED 68 + piece 0 is_cartels_piece(p) && is_coastal_space(s) + resources CARTELS 2 + endpiece + +SHADED 5 + space 1 is_adjacent_to_loc3(s) + shift_opposition + shift_opposition + endspace + +SHADED 15 + space 1 is_city() && (is_neutral(s) || is_passive_support(s)) + set_passive_opposition + endspace + +SHADED 31 + space 3 is_passive_opposition(s) + set_active_opposition + endspace + +SHADED 35 + space 1 is_dept(s) && has_cartels_base(s) + shift_opposition + shift_opposition + endspace + +SHADED 48 + space 2 s !== BOGOTA && is_city(s) + shift_opposition + endspace + +SHADED 55 + space 3 has_cartel_piece(s) + shift_opposition + endspace + +EVENT 6 + space 2 (!is_support(s) && is_adjacent_to_support(s)) + set_passive_support + endspace + +EVENT 22 + space 1 is_opposition(s) + set_neutral + endspace + +EVENT 31 + space 2 is_city(s) + shift_support + endspace + space 1 is_dept(s) + shift_support + endspace + +EVENT 32 + space 2 is_neutral(s) || is_passive_opposition(s) + set_passive_support + endspace + +EVENT 45 + space 0 has_cubes(s) && has_terror(s) + shift_support + endspace + +EVENT 52 + space 2 is_city(s) || is_mountain(s) + shift_support + endspace + +EVENT 42 + space 2 is_neutral(s) + set_passive_support + endspace + resources GOVT 3 + +EVENT 44 + space 1 is_city(s) && !is_opposition(s) + set_active_support + endspace + resources GOVT 3 + +SHADED 44 + space 1 is_city(s) && is_support(s) + set_neutral + endspace + resources GOVT -3 + +EVENT 24 + space 1 is_city(s) + set_active_support + endspace + ineligible FARC + +SHADED 4 + space 3 is_highest_value_pipeline_without_cubes(s) + sabotage + endspace + +SHADED 51 + space 3 is_pipeline(s) && (has_farc_guerrilla(s) || adjacent_has_farc_guerrilla(s)) + sabotage + endspace + +EVENT 21 + resources FARC -6 + piece 1 is_farc_base(p) + remove + endpiece +EVENT 23 + space 1 is_dept(s) + piece 0 is_piece_in_event_space(p) && is_underground_guerrilla(p) + activate + endpiece + piece 0 is_piece_in_event_space(p) && is_cartels_base(p) + remove + endpiece + endspace +EVENT 25 + space 1 is_mountain(s) + piece 0 is_piece_in_event_space(p) && is_farc_piece(p) + remove + endpiece + endspace +EVENT 28 + space 1 is_next_to_venezuela(s) + piece 3 is_piece_in_event_space(p) && is_insurgent_piece(p) + remove_or_end + endpiece + endspace +EVENT 33 + space 1 is_next_to_ecuador(s) + piece 3 is_piece_in_event_space(p) && is_insurgent_piece(p) + remove_or_end + endpiece + endspace + +EVENT 38 + space 3 has_cubes(s) || is_support(s) + piece 0 is_piece_in_event_space(p) && is_auc_guerrilla(p) && is_active(p) + remove + endpiece + endspace + +SHADED 38 + space 0 has_cubes(s) || is_support(s) + piece 0 is_piece_in_event_space(p) && is_auc_guerrilla(p) && is_active(p) + underground + endpiece + endspace + +EVENT 41 + resources AUC -6 + space 1 true + piece 0 is_piece_in_event_space(p) && is_auc_piece(p) + remove + endpiece + endspace + +EVENT 58 + resources CARTELS -6 + piece 0 is_cartels_guerrilla(p) + remove + endpiece + +EVENT 61 + space 1 is_city(s) + piece 0 is_piece_in_event_space(p) && is_cartels_piece(p) + remove + endpiece + endspace + resources CARTELS -6 + +EVENT 62 + piece 3 is_insurgent_piece(p) && is_zero_pop_forest(s) + remove_or_end + endpiece + +EVENT 66 + piece 3 is_cartels_base(p) && is_forest(s) + remove + endpiece + +SHADED 14 + space 1 is_dept(s) + piece 1 is_piece_in_event_space(p) && is_govt_base(p) + remove + endpiece + piece 1 is_piece_in_event_space(p) && (is_troops(p) || is_police(p)) + remove + endpiece + endspace + +SHADED 24 + space 1 has_farc_piece(s) + piece 2 is_piece_in_event_space(p) && is_troops(p) + remove + endpiece + endspace + space 1 is_support(s) + set_neutral + endspace + +SHADED 23 + current GOVT + piece 3 is_troops(p) + remove + endpiece + ineligible GOVT + ineligible FARC + +EVENT 43 + space 1 is_dept(s) && has_troops(s) + terror + terror + piece 0 is_piece_in_event_space(p) && is_farc_base(p) + remove + endpiece + endspace + +SHADED 43 + space 1 is_dept(s) && has_troosps(s) + terror + terror + endspace + aid -9 + +EVENT 55 + remove_shipment + remove_shipment + piece 5 is_cartels_guerrilla(p) + remove + endpiece + aid 3 + +EVENT 14 + current GOVT + space 1 is_dept(s) && !is_farc_zone(s) + place GOVT BASE + place GOVT TROOPS + place GOVT TROOPS + place GOVT TROOPS + endspace + +EVENT 39 + space 6 is_dept(s) && !is_farc_zone(s) + place GOVT POLICE + endspace + +EVENT 50 + current GOVT + space 1 is_dept(s) && !is_farc_zone(s) + place GOVT POLICE + endspace + space 1 is_dept(s) && !is_farc_zone(s) + place GOVT POLICE + endspace + space 1 is_dept(s) && !is_farc_zone(s) + place GOVT POLICE + endspace + +SHADED 21 + resources FARC 6 + space 1 (is_city(s) || is_dept(s)) && can_place_base(s) + place FARC BASE + endspace + +SHADED 49 + space 1 is_dept(s) + place AUC GUERRILLA + place AUC BASE + endspace + +SHADED 25 + space 1 s === ANTIOQUIA || set_has(data.spaces[ANTIOQUIA].adjacent, s) + place_any FARC + place_any FARC + place_any FARC + endspace + +SHADED 33 + space 1 s === ECUADOR + place_any (game.current) + place_any (game.current) + endspace + +SHADED 71 + space 1 s === PANAMA + place (game.current) BASE + place (game.current) BASE + endspace + +SHADED 52 + space 1 has_auc_piece(s) && can_place_base(s) + place AUC BASE + endspace + piece 0 is_auc_base(p) + resources AUC 1 + endpiece + +SHADED 56 + piece 0 is_cartels_piece(p) && is_city(s) + resources CARTELS 2 + endpiece + space 2 is_city(s) && can_place_base(s) + place CARTELS BASE + endspace + +SHADED 61 + space 3 !has_cartels_piece(s) && can_place_base(s) + place CARTELS BASE + endspace + +SHADED 62 + space 3 s === GUAINIA || s === VAUPES || s === AMAZONAS + place CARTELS BASE + endspace + +SHADED 66 + space 0 is_forest(s) && has_cartels_base(s) && can_place_base(s) + place CARTELS BASE + endspace + +SHADED 28 + space 1 is_dept(s) && is_next_to_venezuela(s) && can_place_base(s) + place FARC BASE + endspace + each space is_loc(s) && set_has(data.spaces[CUCUTA].adjacent, s) && is_empty(s) + sabotage + endspace + +SHADED 34 + select_insurgent + space 1 is_zero_pop_dept(s) + place (game.current) GUERRILLA + place (game.current) GUERRILLA + place (game.current) BASE + endspace + +EOF + +SHADED 72 + place all available guerrillas into spaces with cartels bases + +EVENT 20 + reposition 6 farc guerrillas into adjacent spaces + +SHADED 40 + in 1 dept with auc + move all cubes to any cities + in 2 cities + place 1 auc piece + +SHADED 58 + cartels relocate up to 4 police to any spaces + +SHADED 59 + current CARTELS + flip all cartels guerrillas underground + relocate up to 3 cartels guerrillas anywhere + +EVENT 53 + select insurgent faction + select 2 depts + move 1 or 2 guerrillas between depts + flip them underground + +EVENT 35 + in 1 dept + for each cartels base + replace with 1 police + aid 3 + +EVENT 40 + replace 3 auc guerrillas with available police + +EVENT 57 + replace up to 3 cartels pieces with available police + +EVENT 72 + in 2 spaces + replace all cartels guerrillas with other guerrillas + +SHADED 39 + in up to 3 depts + replace 1 police with 1 available auc guerrilla + +SHADED 57 + in 2 spaces + replace 1 police with 1 available cartels piece + +SELECT A OR B + +EVENT 48 + in 1 space adjacent to 3-econ pipeline + remove FARC base + OR + "remove 1 opposition" + if opposition + shift_neutral +EVENT 68 + remove 2 cartels pieces from coastal spaces + OR + remove 2 shipments from coastal spaces + +EVENT 54 + remove up to 2 guerrillas + or + replace up to 2 guerrillas with any other factions' available guerrillas + +EVENT 65 + in one mountain dept: + place or remove 1 shipment + place or remove 1 insurgent base + +SHADED 50 + remove 2 police + OR + replace 2 police with available auc guerrilla + +FREE ACTIVITIES / OPS + +EVENT 8 + GOVT 3 free air strikes +EVENT 19 + in all spaces + if GOVT + free sweep (without movement) + or + free assault + if insurgent + free attack + or + free terror +EVENT 26 + all spaces with cartels guerrillas + all cartels guerrillas free attack farc +EVENT 27 + GOVT 3 free special activities +EVENT 29 + in 1 space + activate all farc + GOVT free assault + +EVENT 37 + each space + GOVT free sweep farc (no moves) (auc guerrillas act as troops) + or + GOVT free assault farc (auc guerrillas act as troops) + +EVENT 47 + all/ auc guerrillas active + all police free assault auc as if troops + +EVENT 59 + all cartels guerrillas to active + free assault cartels in each space + +SHADED 20 + farc free marches + farc flip 3 farc guerrillas underground + +SHADED 29 + select farc or auc + execute 2 free ambushes with any of its guerrillas without activating + +SHADED 47 + select auc + place 2 guerrillas in cucuta + free terror in cucuta + flip any 2 auc guerrillas underground + +SHADED 60 + select cartels + in 2 cities + place available cartels base + in 1 space + free bribe + +SHADED 37 + select auc + free march any guerrillas + at 1 destination free ambush + +SHADED 70 + select insurgent faction + in each forest + free terror with any 1 guerrilla + resources 3 per terror (marker or op?) + +FARC ZONE + 30 + in one farc zone: + remove farc zone + remove farc base + 30 + place farc zone and base (see unshaded 36) + 36 + place farc zone and base + { + GOVT select 1 mountain space with most farc pieces and no farc zone + redeploy GOVT cubes + remove GOVT bases + place farc zone + place farc base + in 2 adjacent spaces + shift_support + } + remain eligible + +COMPLICATED + +EVENT 46 + select insurgent faction + select space for terror + free terror with any guerrilla + remove any 2 enemy pieces in space + if pop + set_to_passive_support_or_opposition + the terror places 2 markers + +EVENT 69 + select source space + select destination space through chain of up to 3 adjacent depts + move any cubes/guerrillas from source to destination + any free op (except patrol or march) in destination + +EVENT 71 + remove guerrilla from choco + resources its faction -5 + +EVENT 49 + permanently remove 3 available AUC guerrillas + +EVENT 63 + in each space with cartels guerrillas + remove all but 1 + cartels free terror with that 1 + ineligible CARTELS + +EVENT 51 + if any pipeline sabotage + remove all pipeline sabotage + else + resources GOVT 12 + +SHADED 6 + in 1 space (pipeline) + sabotage + in 1 space (adjacent) + shift_opposition + +EVENT 60 + in 2 cities OR in 1 dept + for all cartels pieces in space + remove + resources GOVT 6 + +EVENT 5 + place 6 police onto pipelines + flip to active 3 guerillas there or adjacent + +EVENT 64 + place 2 shipments with farc guerrillas in same spaces as cartels bases + +EVENT 16 + space 0 is_mountain(s) + select faction with most pieces (ties GOVT) + resources faction 5 + +EVENT 34 + select_insurgent + resources (game.current) -5 diff --git a/tools/gencode.py b/tools/gencode.py new file mode 100644 index 0000000..2d8af67 --- /dev/null +++ b/tools/gencode.py @@ -0,0 +1,72 @@ +#!/bin/env python3 + +code = {} +buf = [] +event = 0 + +def flush_code(): + global buf + if event > 0: + code[event] = buf + buf = [] + +event = 0 +for line in open("tools/events.txt").readlines(): + line = line.strip() + if line == "EOF": + break + elif line == "": + continue + elif line.startswith("#"): + continue + elif line.startswith("EVENT"): + flush_code() + event = int(line.split()[1]) + elif line.startswith("SHADED"): + flush_code() + event = int(line.split()[1]) + 100 + else: + buf.append(line) + +flush_code() + +shaded = ["-1"] * 72 +unshaded = ["-1"] * 72 + +pc = 0 +print("const CODE = [") +for event in sorted(code.keys()): + buf = code[event] + if event > 100: + print("\t// SHADED", event - 100) + shaded[event - 100] = str(pc) + else: + print("\t// EVENT", event) + unshaded[event] = str(pc) + for line in code[event]: + if line.startswith('space'): + line = line.split(' ', 2) + print('\t[ vm_space, ' + line[1] + ', (s)=>' + line[2] + ' ],') + elif line.startswith('each space'): + line = line.split(' ', 2) + print('\t[ vm_space, 0, (s)=>' + line[2] + ' ],') + elif line.startswith('piece'): + line = line.split(' ', 2) + print('\t[ vm_piece, ' + line[1] + ', (p,s)=>' + line[2] + ' ],') + elif line.startswith('each piece'): + line = line.split(' ', 2) + print('\t[ vm_piece, 0, (p,s)=>' + line[2] + ' ],') + else: + line = line.split(' ') + cmd = line[0] + args = [ ("()=>" + x if x[0] == '(' else x) for x in line[1:] ] + if len(args) > 0: + print('\t[ vm_' + cmd + ', ' + ', '.join(args) + ' ],') + else: + print('\t[ vm_' + cmd + ' ],') + pc = pc + 1 + print('\t[ vm_endevent ],') + pc = pc + 1 +print("]") +print("const SHADED_START = [" + ",".join(shaded) + "]") +print("const UNSHADED_START = [" + ",".join(unshaded) + "]") |