summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.css5
-rw-r--r--play.js99
-rw-r--r--rules.js148
3 files changed, 169 insertions, 83 deletions
diff --git a/play.css b/play.css
index ddaa6ce..1f36fc2 100644
--- a/play.css
+++ b/play.css
@@ -165,7 +165,10 @@ path.tip { stroke: yellow; }
background-size: 36px 36px;
width: 36px;
height: 36px;
- margin: 4px 5px 5px 4px;
+}
+
+.token.reminder {
+ //margin: 4px 5px 5px 4px;
}
.token.shipment
diff --git a/play.js b/play.js
index cec0dc6..90c6b6c 100644
--- a/play.js
+++ b/play.js
@@ -445,9 +445,16 @@ function init_ui() {
register_action(ui.sop[7], "sop", 7)
}
+function is_carrying_shipment(p) {
+ for (let i = 0; i < 4; ++i)
+ if (view.shipments[i] === p << 2)
+ return true
+ return false
+}
+
function filter_piece_list(list, space, faction, type) {
for (let i = first_piece[faction][type]; i <= last_piece[faction][type]; ++i)
- if (view.pieces[i] === space)
+ if (view.pieces[i] === space && (type !== GUERRILLA || !is_carrying_shipment(i)))
list.push(ui.pieces[i])
}
@@ -731,6 +738,74 @@ function layout_farc_zone(s, elt) {
elt.style.left = (x - 25) + "px"
}
+const shipment_layout_city = [
+ [ -60, 0, 3 ],
+ [ -48, -30, 2 ],
+ [ -36, -60, 1 ],
+ [ -72, 30, 4 ],
+]
+
+const shipment_layout_dept = [
+ [ -18, -60, 2 ],
+ [ 18, -60, 3 ],
+ [ -54, -60, 1 ],
+ [ 54, -60, 4 ],
+]
+
+const shipment_layout_loc_ns = [
+ [ 36, 18, 3 ],
+ [ 36, -18, 2 ],
+ [ 36, 54, 4 ],
+ [ 36, -54, 1 ],
+]
+
+const shipment_layout_loc_ew = [
+ [ -18, 36, 2 ],
+ [ 18, 36, 3 ],
+ [ 54, 36, 4 ],
+ [ -54, 36, 1 ],
+]
+
+function layout_shipments_push(list, pc, sh) {
+ for (let i = 0; i < list.length; ++i) {
+ if (list[i][0] === pc) {
+ list[i].push(sh)
+ return
+ }
+ }
+ list.push([pc, sh])
+}
+
+function layout_shipments(s, list, xc, yc) {
+ let shipment_layout = shipment_layout_dept
+ if (s <= last_city)
+ shipment_layout = shipment_layout_city
+ if (s >= first_loc)
+ shipment_layout = shipment_layout_loc_ew
+ if (list.length > 0) {
+ for (let i = 0; i < list.length; ++i) {
+ let [xo, yo, zo] = shipment_layout[i]
+ let x = xc + xo
+ let y = yc + yo
+ let z = zo * 4
+ let pc = list[i][0]
+ if (pc) {
+ pc.style.left = (x+5) + "px"
+ pc.style.top = (y-8) + "px"
+ pc.style.zIndex = z + 1
+ }
+ for (let k = 1; k < list[i].length; ++k) {
+ let sh = list[i][k]
+ sh.style.left = (x) + "px"
+ sh.style.top = (y) + "px"
+ sh.style.zIndex = z--
+ x += 8
+ y += 8
+ }
+ }
+ }
+}
+
function on_update() {
switch (player) {
case "Government": favicon.href = "images/icon_govt.png"; break
@@ -874,6 +949,18 @@ function on_update() {
else
console.log("NO SPACE", s, data.space_name[s])
+ list.length = 0
+ for (let i = 0; i < 4; ++i) {
+ let shx = view.shipments[i]
+ if (shx !== 0) {
+ if ((shx & 3) === 0 && view.pieces[(shx >> 2)] === s)
+ layout_shipments_push(list, ui.pieces[shx >> 2], ui.shipments[i])
+ else if ((shx & 3) !== 0 && (shx >> 2) === s)
+ layout_shipments_push(list, null, ui.shipments[i])
+ }
+ }
+ layout_shipments(s, list, xy[0]-26, xy[1]-26)
+
ui.spaces[s].classList.toggle("action", is_action("space", s))
ui.spaces[s].classList.toggle("selected", view.where === s)
}
@@ -889,16 +976,6 @@ function on_update() {
let shx = view.shipments[i]
if (shx === 0)
list.push(ui.shipments[i])
- /*
- if ((shx & 3) === 0) {
- let holder = ui.pieces[shx >> 2]
- place_piece_under(ui.shipments[i], holder)
- } else {
- // dropped shipment!
- let xy = get_center_xy(shx >> 2)
- place_piece(ui.shipments[i], xy[0] - 26, xy[1] - 72, 0)
- }
- */
if (view.actions && view.actions.shipment && set_has(view.actions.shipment, i))
ui.shipments[i].classList.add("action")
else
diff --git a/rules.js b/rules.js
index 20462f3..6dee5c4 100644
--- a/rules.js
+++ b/rules.js
@@ -4045,6 +4045,83 @@ states.bribe_flip = {
},
}
+// === PROPAGANDA ===
+
+function goto_propaganda_card() {
+ throw "TODO"
+}
+
+// === EVENTS ===
+
+states.event = {
+ prompt() {
+ let c = this_card()
+ view.prompt = `${data.card_title[c]}: Choose effect.`
+ view.actions.shaded = 1
+ view.actions.unshaded = 1
+ },
+ shaded() {
+ execute_shaded_event()
+ },
+ unshaded() {
+ execute_unshaded_event()
+ },
+}
+
+function execute_event() {
+ let c = this_card()
+ log(`C${c} - Event`)
+
+ log("TODO")
+ resume_event_card()
+}
+
+function execute_unshaded_event() {
+ let c = this_card()
+ log(`C${c} - Unshaded`)
+ log(data.card_flavor[c] + ".")
+
+ if (set_has(capability_events, c)) {
+ set_add(game.capabilities, c)
+ resume_event_card()
+ return
+ }
+
+ log("TODO")
+ resume_event_card()
+}
+
+function execute_shaded_event() {
+ let c = this_card()
+ log(`C${c} - Shaded`)
+ log(data.card_flavor_shaded[c] + ".")
+
+ if (c === MOM_SENADO_CAMARA) {
+ log("No Sweep or Assault against " + faction_name[game.current] + " until next Propaganda.")
+ game.senado = game.current
+ }
+
+ if (c === EVT_DARIEN)
+ set_add(game.capabilities, EVT_DARIEN)
+ if (c === EVT_SUCUMBIOS)
+ set_add(game.capabilities, EVT_SUCUMBIOS)
+
+ if (set_has(capability_events, c)) {
+ set_add(game.capabilities, -c)
+ resume_event_card()
+ return
+ }
+
+ if (set_has(momentum_events, c)) {
+ set_add(game.momentum, c)
+ resume_event_card()
+ return
+ }
+
+ log("TODO")
+ resume_event_card()
+}
+
// === GAME OVER ===
function goto_game_over(result, victory) {
@@ -4257,77 +4334,6 @@ exports.is_checkpoint = function (a, b) {
return a.turn !== b.turn
}
-// === EVENTS ===
-
-states.event = {
- prompt() {
- let c = this_card()
- view.prompt = `${data.card_title[c]}: Choose effect.`
- view.actions.shaded = 1
- view.actions.unshaded = 1
- },
- shaded() {
- execute_shaded_event()
- },
- unshaded() {
- execute_unshaded_event()
- },
-}
-
-function execute_event() {
- let c = this_card()
- log(`C${c} - Event`)
-
- log("TODO")
- resume_event_card()
-}
-
-function execute_unshaded_event() {
- let c = this_card()
- log(`C${c} - Unshaded`)
- log(data.card_flavor[c] + ".")
-
- if (set_has(capability_events, c)) {
- set_add(game.capabilities, c)
- resume_event_card()
- return
- }
-
- log("TODO")
- resume_event_card()
-}
-
-function execute_shaded_event() {
- let c = this_card()
- log(`C${c} - Shaded`)
- log(data.card_flavor_shaded[c] + ".")
-
- if (c === MOM_SENADO_CAMARA) {
- log("No Sweep or Assault against " + faction_name[game.current] + " until next Propaganda.")
- game.senado = game.current
- }
-
- if (c === EVT_DARIEN)
- set_add(game.capabilities, EVT_DARIEN)
- if (c === EVT_SUCUMBIOS)
- set_add(game.capabilities, EVT_SUCUMBIOS)
-
- if (set_has(capability_events, c)) {
- set_add(game.capabilities, -c)
- resume_event_card()
- return
- }
-
- if (set_has(momentum_events, c)) {
- set_add(game.momentum, c)
- resume_event_card()
- return
- }
-
- log("TODO")
- resume_event_card()
-}
-
// === COMMON LIBRARY ===
function clear_undo() {