summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js56
1 files changed, 18 insertions, 38 deletions
diff --git a/rules.js b/rules.js
index 007264d..c8e75ac 100644
--- a/rules.js
+++ b/rules.js
@@ -1,23 +1,5 @@
"use strict"
-// TODO: remember withdrawal supply lines for regroup pass moves
-// TODO: withdrawal pass regroup moves where 2+ moves combine to reduce supply network
-
-// TODO: clean up withdraw calculations and search_withdraw (pass supply source directly, not sample unit)
-// TODO: log summaries (deploy, rebuild, move, etc)
-// TODO: put initial deployment stack somewhere more accessible (spread out along the top?)
-
-// UI: skip clicking destination if only one regroup move selected?
-
-// UI: flash message cleanup during battles
-// UI: separate colors for secret and visible minefields
-// UI: basic turn - skip move - direct to combat
-
-// TODO: undo push/clear
-
-// ERRATA: forbid single-group regroup moves or convert to group moves after the fact,
-// to prevent forced march abuse.
-
const max = Math.max
const min = Math.min
const abs = Math.abs
@@ -30,7 +12,7 @@ var after_rout_table = {}
const {
all_hexes, hex_exists, hex_road, side_road, side_limit, hex_name, regions,
- unit_name, unit_appearance, unit_elite, unit_class, unit_speed, unit_start_steps,
+ unit_name, unit_appearance, unit_elite, unit_class, unit_speed, unit_max_steps,
} = require("./data")
function debug_hexes3(n, list) {
@@ -147,6 +129,9 @@ const ALLIED_REFIT = 48
const AXIS_QUEUE = 127
const ALLIED_QUEUE = 49
+// Free deployment holding box
+const DEPLOY = 1
+
// Off board optional 1942 Malta reinforcements
const MALTA = 4
@@ -424,11 +409,11 @@ function set_unit_lost_steps(u, n) {
}
function unit_steps(u) {
- return unit_start_steps[u] - unit_lost_steps(u)
+ return unit_max_steps[u] - unit_lost_steps(u)
}
function set_unit_steps(u, n) {
- set_unit_lost_steps(u, unit_start_steps[u] - n)
+ set_unit_lost_steps(u, unit_max_steps[u] - n)
}
function is_unit_moved(u) {
@@ -593,10 +578,6 @@ function has_friendly_unit_in_raw_hex(x) {
return false
}
-function has_friendly_unit_in_month(month) {
- return has_friendly_unit_in_raw_hex(hexdeploy + month)
-}
-
function for_each_friendly_unit_in_month(month, fn) {
for (let u = first_friendly_unit; u <= last_friendly_unit; ++u)
if (unit_hex(u) === hexdeploy + month)
@@ -6003,7 +5984,7 @@ function end_game() {
function goto_free_deployment() {
game.state = 'free_deployment'
game.selected = []
- if (!has_friendly_unit_in_month(current_scenario().start))
+ if (!has_friendly_unit_in_raw_hex(DEPLOY))
end_free_deployment()
}
@@ -6024,14 +6005,13 @@ states.free_deployment = {
inactive: "free deployment",
prompt() {
let scenario = current_scenario()
- let deploy = hexdeploy + scenario.start
let axis = (game.active === AXIS)
view.prompt = `Setup: ${game.active} Deployment.`
// view.prompt = `Setup: Deploy units in a supplied location in the setup area.`
let done = true
- for_each_friendly_unit_in_hex(deploy, u => {
+ for_each_friendly_unit_in_hex(DEPLOY, u => {
gen_action_unit(u)
done = false
})
@@ -6079,7 +6059,7 @@ states.free_deployment = {
function end_free_deployment() {
set_enemy_player()
- if (has_friendly_unit_in_month(current_scenario().start)) {
+ if (has_friendly_unit_in_raw_hex(DEPLOY)) {
game.selected = []
log_h2("Allied Deployment")
} else {
@@ -6197,7 +6177,7 @@ function setup_units(where, steps, list) {
u = find_unit(u)
set_unit_hex(u, where)
if (steps < 0)
- set_unit_steps(u, unit_start_steps[u] + steps)
+ set_unit_steps(u, unit_max_steps[u] + steps)
else if (steps > 0)
set_unit_steps(u, steps)
set_unit_supply(u, SS_BASE)
@@ -6308,7 +6288,7 @@ const SCENARIOS = {
}
const SETUP = {
- "1940" (DEPLOY) {
+ "1940" () {
setup_units(DEPLOY, 0, [ "Pav", "Bre", "Tre", "Bol", "Sav", "Sab", "Fas", "Ita" ])
setup_units(-3, 0, [ "Ari", "Pis"])
setup_units(-5, 0, [ "Lit", "Cen"])
@@ -6318,7 +6298,7 @@ const SETUP = {
setup_units(-4, 0, [ "Matilda/A", "7/4", "4IN/7m", "/Tob" ])
},
- "1941" (DEPLOY) {
+ "1941" () {
setup_units(EL_AGHEILA, 0, find_axis_units('S'))
setup_reinforcements(3)
setup_reinforcements(5)
@@ -6333,7 +6313,7 @@ const SETUP = {
setup_reinforcements(10)
},
- "Crusader" (DEPLOY) {
+ "Crusader" () {
setup_units(DEPLOY, 0, find_axis_units('S'))
setup_units(DEPLOY, 0, find_axis_units(3))
setup_units(DEPLOY, 0, find_axis_units(5))
@@ -6349,7 +6329,7 @@ const SETUP = {
setup_reinforcements(10)
},
- "Battleaxe" (DEPLOY) {
+ "Battleaxe" () {
setup_units(DEPLOY, 0, [ "21/5", "21/3", "15/33", "90/155", "15/115", "88mm/A" ])
setup_units(DEPLOY, -1, [ "21/104" ])
setup_units(DEPLOY, 0, [ "Ari", "Lit", "Pav", "Bre", "Tre", "Bol", "Ita" ])
@@ -6365,7 +6345,7 @@ const SETUP = {
setup_reinforcements(10)
},
- "1942" (DEPLOY) {
+ "1942" () {
setup_units(DEPLOY, 0, [
"21/3",
"15/33",
@@ -6422,7 +6402,7 @@ const SETUP = {
setup_reinforcements(20)
},
- "Gazala" (DEPLOY) {
+ "Gazala" () {
setup_units(DEPLOY, -1, [
"21/5",
"15/8",
@@ -6491,7 +6471,7 @@ const SETUP = {
])
},
- "Pursuit to Alamein" (DEPLOY) {
+ "Pursuit to Alamein" () {
setup_units(DEPLOY, 0, [
"21/3",
"15/33",
@@ -6566,7 +6546,7 @@ const SETUP = {
setup_reinforcements(20)
},
- "1941-42" (DEPLOY) {
+ "1941-42" () {
SETUP["1941"](-1)
setup_reinforcements(11)