diff options
-rw-r--r-- | play.html | 8 | ||||
-rw-r--r-- | play.js | 10 | ||||
-rw-r--r-- | rules.js | 63 |
3 files changed, 74 insertions, 7 deletions
@@ -40,10 +40,10 @@ <div id="trade_menu" class="menu"> <div class="menu_title"><img src="images/shaking-hands.svg"></div> <div class="menu_popup"> - <div id="trade_govt" class="menu_item" onclick="send_action('trade',0)">Government</div> - <div id="trade_farc" class="menu_item" onclick="send_action('trade',1)">FARC</div> - <div id="trade_auc" class="menu_item" onclick="send_action('trade',2)">AUC</div> - <div id="trade_cartels" class="menu_item" onclick="send_action('trade',3)">Cartels</div> + <div id="g_button" class="menu_item" onclick="send_action('g')">Government</div> + <div id="f_button" class="menu_item" onclick="send_action('f')">FARC</div> + <div id="a_button" class="menu_item" onclick="send_action('a')">AUC</div> + <div id="c_button" class="menu_item" onclick="send_action('c')">Cartels</div> </div> </div> <div id="remove_button" class="icon_button" onclick="send_action('remove')"><img src="images/back-forth.svg"></div> @@ -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") } @@ -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 |