diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 140 |
1 files changed, 63 insertions, 77 deletions
@@ -717,6 +717,10 @@ function is_insurgent_piece(p) { return is_farc_piece(p) || is_auc_piece(p) || is_cartels_piece(p) } +function is_insurgent_base(p) { + return is_farc_base(p) || is_auc_base(p) || is_cartels_base(p) +} + function is_active_guerrilla(p, faction) { return is_piece(p, faction, GUERRILLA) && is_active(p) } @@ -7834,95 +7838,65 @@ states.vm_set_passive_support_or_passive_opposition = { }, } -function can_place_or_remove_shipment(s) { - if (has_available_shipment() && has_any_guerrilla(s)) - return true - if (is_any_shipment_held_in_space(s)) - return true - return false +function can_place_shipment(s) { + return (has_available_shipment() && has_any_guerrilla(s)) } -function vm_place_or_remove_shipment() { - if (can_place_or_remove_shipment(game.vm.s)) - game.state = "vm_place_or_remove_shipment" - else - vm_next() +function can_remove_shipment(s) { + return (is_any_shipment_held_in_space(s)) } -states.vm_place_or_remove_shipment = { - prompt() { - event_prompt(`Place or remove Shipment in ${space_name[game.vm.s]}.`) - for (let sh = 0; sh < 4; ++sh) - if (is_shipment_held_in_space(sh, game.vm.s)) - gen_action_shipment(sh) - let sh = find_available_shipment() - if (sh >= 0) - gen_action_shipment(sh) - }, - shipment(sh) { - push_undo() - if (is_shipment_held_in_space(sh, game.vm.s)) { - let p = get_held_shipment_piece(sh) - log("Removed Shipment from " + piece_faction_name(p) + " in S" + piece_space(p) + ".") - remove_shipment(sh) - vm_next() - } else { - game.state = "vm_place_or_remove_shipment_place" - } - }, +function can_place_insurgent_base(s) { + return (can_place_piece(s, FARC, BASE) || can_place_piece(s, AUC, BASE) || can_place_piece(s, CARTELS, BASE)) } -states.vm_place_or_remove_shipment_place = { - prompt() { - event_prompt(`Place Shipment in ${space_name[game.vm.s]}.`) - view.selected_shipment = find_available_shipment() - gen_piece_in_space(game.vm.s, FARC, GUERRILLA) - gen_piece_in_space(game.vm.s, AUC, GUERRILLA) - gen_piece_in_space(game.vm.s, CARTELS, GUERRILLA) - }, - piece(p) { - push_undo() - let sh = find_available_shipment() - log("Placed Shipment with " + piece_faction_name(p) + " in S" + piece_space(p) + ".") - place_shipment(sh, p) - vm_next() - }, +function can_remove_insurgent_base(s) { + return (has_piece(s, FARC, BASE) || has_piece(s, AUC, BASE) || has_piece(s, CARTELS, BASE)) +} + +function can_place_or_remove_shipment(s) { + return can_place_shipment(s) || can_remove_shipment(s) } function can_place_or_remove_insurgent_base(s) { - if (can_place_piece(s, FARC, BASE) || can_place_piece(s, AUC, BASE) || can_place_piece(s, CARTELS, BASE)) - return true - if (has_piece(s, FARC, BASE) || has_piece(s, AUC, BASE) || has_piece(s, CARTELS, BASE)) - return true - return false + return can_place_insurgent_base(s) || can_remove_insurgent_base(s) } -function vm_place_or_remove_insurgent_base() { - if (can_place_or_remove_insurgent_base(game.vm.s)) - game.state = "vm_place_or_remove_insurgent_base" - else +function vm_place_or_remove() { + let p = can_place_shipment(game.vm.s) || can_place_insurgent_base(game.vm.s) + let r = can_remove_shipment(game.vm.s) || can_remove_insurgent_base(game.vm.s) + if (p && !r) { + game.vm.choice = "place" + vm_next() + } else if (!p && r) { + game.vm.choice = "remove" vm_next() + } else { + game.state = "vm_place_or_remove" + } } -states.vm_place_or_remove_insurgent_base = { +states.vm_place_or_remove = { prompt() { - event_prompt(`Place or remove Insurgent Base in ${space_name[game.vm.s]}.`) - gen_piece_in_space(game.vm.s, FARC, BASE) - gen_piece_in_space(game.vm.s, AUC, BASE) - gen_piece_in_space(game.vm.s, CARTELS, BASE) - gen_place_piece(game.vm.s, FARC, BASE) - gen_place_piece(game.vm.s, AUC, BASE) - gen_place_piece(game.vm.s, CARTELS, BASE) + event_prompt(`Place or remove Shipment and Insurgent Base?`) + view.where = game.vm.s + if (can_place_shipment(game.vm.s) || can_place_insurgent_base(game.vm.s)) + view.actions.place = 1 + else + view.actions.place = 0 + if (can_remove_shipment(game.vm.s) || can_remove_insurgent_base(game.vm.s)) + view.actions.remove = 1 + else + view.actions.remove = 0 }, - piece(p) { + place() { push_undo() - if (piece_space(p) === game.vm.s) { - log("Removed " + piece_name(p) + " from S" + game.vm.s + ".") - remove_piece(p) - } else { - log("Placed " + piece_name(p) + " in S" + game.vm.s + ".") - place_piece(p, game.vm.s) - } + game.vm.choice = "place" + vm_next() + }, + remove() { + push_undo() + game.vm.choice = "remove" vm_next() }, } @@ -10042,13 +10016,25 @@ CODE[64 * 2 + 1] = [ // EVENT 65 CODE[65 * 2 + 0] = [ [ vm_prompt, "Place or remove 1 Shipment and Insurgent Base in any Mountain Department." ], - [ vm_if, ()=>can_vm_space(1,(s)=>is_mountain(s) && ( can_place_or_remove_shipment(s) && can_place_or_remove_insurgent_base(s) )) ], - [ vm_space, true, 1, 1, (s)=>is_mountain(s) && ( can_place_or_remove_shipment(s) && can_place_or_remove_insurgent_base(s) ) ], - [ vm_else ], [ vm_space, true, 1, 1, (s)=>is_mountain(s) && ( can_place_or_remove_shipment(s) || can_place_or_remove_insurgent_base(s) ) ], + [ vm_place_or_remove ], + [ vm_if, ()=>game.vm.choice === "place" ], + [ vm_prompt, "Place Shipment." ], + [ vm_piece, true, 1, 1, (p,s)=>is_piece_in_event_space(p) && is_any_guerrilla(p) ], + [ vm_place_shipment ], + [ vm_endpiece ], + [ vm_prompt, "Place Insurgent Base." ], + [ vm_place, false, 0, FARC_AUC_CARTELS, BASE ], + [ vm_else ], + [ vm_prompt, "Remove Shipment." ], + [ vm_shipment, false, 1, 1, (p,s)=>(s === game.vm.s) ], + [ vm_remove_shipment ], + [ vm_endshipment ], + [ vm_prompt, "Remove Insurgent Base." ], + [ vm_piece, false, 999, 999, (p,s)=>is_piece_in_event_space(p) && is_insurgent_base(p) ], + [ vm_remove ], + [ vm_endpiece ], [ vm_endif ], - [ vm_place_or_remove_shipment ], - [ vm_place_or_remove_insurgent_base ], [ vm_endspace ], [ vm_return ], ] |