summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js1
-rw-r--r--rules.js93
2 files changed, 82 insertions, 12 deletions
diff --git a/play.js b/play.js
index 4cdbaf3..663d903 100644
--- a/play.js
+++ b/play.js
@@ -741,6 +741,7 @@ function on_update() {
action_button("end_rout", "End rout")
action_button("end_retreat", "End retreat")
action_button("end_combat", "End combat")
+ action_button("end_buildup", "End buildup")
action_button("end_turn", "End turn")
action_button("undo", "Undo")
diff --git a/rules.js b/rules.js
index 1062f35..886ae3a 100644
--- a/rules.js
+++ b/rules.js
@@ -3,24 +3,21 @@
// TODO: fortress supply
// TODO: oasis supply
// TODO: raiders
+// TODO: reveal minefields
+// TODO: gazala scenario
// TODO: legal pass withdrawal moves (reduce supply net, withdraw from fortress attack)
-
-// TODO: BUILDUP
-// TODO: MINEFIELDS
-
// TOOD: reveal/hide blocks (hexes)
+// TODO: malta units?
-// TODO: setup scenario specials
+// TODO: BUILDUP
-// TODO: when is "fired" status cleared?
+// RULES: when is "fired" status cleared?
// RULES: disrupted units routed again in second enemy turn, will they still recover?
// assume yes, easy to change (remove from game.recover set if routed)
// RULES: reveal minefields moved through (but not stopped at)?
-// TODO: exit hexes off-limits to allied (or unsupplied) units?
-
// TODO: forbid single-group regroup moves or convert to group moves after the fact,
// to prevent forced march abuse.
@@ -477,6 +474,12 @@ function is_axis_unit(u) {
// === MAP STATE ===
+function friendly_base() {
+ if (is_axis_player())
+ return EL_AGHEILA
+ return ALEXANDRIA
+}
+
function update_presence() {
presence_invalid = false
presence_axis.fill(0)
@@ -1486,7 +1489,7 @@ function player_hand() {
states.turn_option = {
inactive: "turn option",
prompt() {
- view.prompt = `Select Turn Option: ${game.commit[0]} real and ${game.commit[1]} dummy supply.`
+ view.prompt = `Turn Option \u2014 committed ${game.commit[0]} real and ${game.commit[1]} dummy supply.`
let hand = player_hand()
if (game.commit[0] + game.commit[1] < 3) {
@@ -3720,7 +3723,7 @@ function end_rout_fire() {
goto_rout_move()
}
-// === BUILD-UP ===
+// === BUILDUP ===
function end_month() {
// Forget captured fortresses (for bonus cards)
@@ -3881,12 +3884,78 @@ function goto_buildup_point_determination() {
function goto_buildup_reinforcements() {
log_h2(game.active + " Buildup")
+ game.state = 'buildup_reinforcements'
+}
+
+states.buildup_reinforcements = {
+ prompt() {
+ view.prompt = `Buildup: Bring on reinforcements.`
+ gen_action_hex(friendly_base())
+ },
+ hex(base) {
+ apply_reinforcements()
+ goto_buildup_spending()
+ },
+}
+
+function apply_reinforcements() {
+ let base = friendly_base()
+ let scheduled = 0
+ let early = 0
+
+ for_each_friendly_unit_in_month(game.month, u => {
+ set_unit_hex(u, base)
+ scheduled++
+ })
+
+ if (game.month < current_scenario().end) {
+ for_each_friendly_unit_in_month(game.month + 1, u => {
+ if (roll_die() <= 2) {
+ set_unit_hex(u, base)
+ early++
+ }
+ })
+ }
- goto_buildup_spending()
+ log(`Reinforcements at #${base}:`)
+ log(`>${scheduled} on schedule`)
+ log(`>${early} early`)
}
function goto_buildup_spending() {
- end_buildup_spending()
+ game.state = 'spending_bps'
+}
+
+function available_bps() {
+ if (is_axis_player())
+ return game.axis_bps
+ else
+ return game.allied_bps
+}
+
+function pay_bps(n) {
+ if (is_axis_player())
+ game.axis_bps -= n
+ else
+ game.allied_bps -= n
+}
+
+states.spending_bps = {
+ prompt() {
+ view.prompt = `Buildup: Spend buildup points (${available_bps()} remain).`
+ gen_action('end_buildup')
+ },
+ end_buildup() {
+ clear_undo()
+
+ let n = available_bps()
+ if (n > 20) {
+ log(`Lost ${n - 20} unspent BPs.`)
+ pay_bps(n - 20)
+ }
+
+ end_buildup_spending()
+ }
}
function end_buildup_spending() {