From c3e452ce9172f818126e2b15bd46c563c0f2ef88 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 5 Mar 2023 18:10:00 +0100 Subject: Ambush! --- play.html | 8 ++++---- play.js | 10 ++++++++-- rules.js | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 7 deletions(-) diff --git a/play.html b/play.html index 46a5f2d..7ed9757 100644 --- a/play.html +++ b/play.html @@ -40,10 +40,10 @@
diff --git a/play.js b/play.js index 459e759..082023c 100644 --- a/play.js +++ b/play.js @@ -758,6 +758,13 @@ function on_update() { for (let i = 0; i < ui.pieces.length; ++i) ui.pieces[i].classList.remove("action") + action_button("remove", "Remove") + // menu trade + // action_button("trade", "Trade with Govt") + // action_button("trade", "Trade with FARC") + // action_button("trade", "Trade with AUC") + // action_button("trade", "Trade with Cartels") + action_button("train", "Train") action_button("patrol", "Patrol") action_button("sweep", "Sweep") @@ -796,8 +803,7 @@ function on_update() { action_button("limop", "LimOp") action_button("next", "Next") - action_button("done", "Done") - action_button("remove", "Remove") + action_button("done", "Done!") action_button("undo", "Undo") } diff --git a/rules.js b/rules.js index f454330..5e3e4f1 100644 --- a/rules.js +++ b/rules.js @@ -420,6 +420,15 @@ function has_active_guerrilla(s, faction) { return false } +function has_underground_guerrilla(s, faction) { + let first = first_piece[faction][GUERRILLA] + let last = last_piece[faction][GUERRILLA] + for (let p = first; p <= last; ++p) + if (game.pieces[p] === s && is_underground(p)) + return true + return false +} + function count_bases(s) { return ( count_pieces(s, GOVT, BASE) + @@ -571,6 +580,14 @@ function gen_place_piece(space, faction, type) { gen_action_piece(p) } +function gen_activate_guerrilla(s, faction) { + for_each_piece(faction, GUERRILLA, p => { + if (game.pieces[p] === s) + if (is_underground(p)) + gen_action_piece(p) + }) +} + // === SEQUENCE OF PLAY === function this_card() { @@ -1452,8 +1469,20 @@ states.attack_space = { view.prompt = `Attack in ${space_name[game.op.where]}.` view.where = game.op.where view.actions.resolve = 1 + + // Ambush activity modifies Attack action intead of being a stand-alone activity. + if (game.sa) { + if (game.current === FARC || game.current === AUC) + if (has_underground_guerrilla(game.op.where, game.current)) + view.actions.ambush = 1 + else + view.actions.ambush = 0 + } }, ambush() { + push_undo() + game.state = "ambush" + game.sa = 0 }, resolve() { clear_undo() @@ -1478,6 +1507,18 @@ states.attack_space = { }, } +states.ambush = { + prompt() { + view.prompt = `Ambush in ${space_name[game.op.where]}: Activate an Underground Guerrilla.` + gen_activate_guerrilla(game.op.where, game.current) + }, + piece(p) { + set_active(p) + game.state = "attack_remove" + game.op.count = 2 + } +} + states.attack_place = { prompt() { view.prompt = `Attack in ${space_name[game.op.where]}: Place a Guerrilla.` @@ -1734,12 +1775,32 @@ exports.view = function (state, role) { } else { view.actions = {} view.who = game.who - if (game.op) + + if (game.op) { view.actions.remove = 1 + /* + if (game.active === "Government + AUC") + view.actions.trade = [ FARC, CARTELS ] + if (game.active === "FARC + Cartels") + view.actions.trade = [ GOVT, AUC ] + if (game.active === "AUC + Cartels") + view.actions.trade = [ GOVT, FARC ] + if (game.active === "Government") + view.actions.trade = [ FARC, AUC, CARTELS ] + if (game.active === "FARC") + view.actions.trade = [ GOVT, AUC, CARTELS ] + if (game.active === "AUC") + view.actions.trade = [ GOVT, FARC, CARTELS ] + if (game.active === "Cartels") + view.actions.trade = [ GOVT, FARC, AUC ] + */ + } + if (states[game.state]) states[game.state].prompt() else view.prompt = "Unknown state: " + game.state + if (view.actions.undo === undefined) { if (game.undo && game.undo.length > 0) view.actions.undo = 1 -- cgit v1.2.3