1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
"use strict"
const fs = require("fs")
let data = {}
const RURAL = 1
const URBAN = 2
const REMOTE = 3
const COUNTRY = 4
let locations = {}
let areas = []
let zone_areas = {}
let next_location_id = 0
function def_area(id, name, type, zone) {
let loc = next_location_id++
locations[id] = loc
if (type && type !== COUNTRY && type !== URBAN)
areas.push({loc, id, full_name: id + " " + name, name, type, zone})
else if (type === URBAN)
areas.push({loc, id, full_name: id, name, type, zone})
else
areas.push({loc, id, full_name: name, name, type, zone})
if (zone) {
if (!(zone in zone_areas)) {
zone_areas[zone] = []
}
zone_areas[zone].push(loc)
}
}
// special locations
def_area("NONE", "None")
def_area("DEPLOY", "Deployment")
def_area("ELIMINATED", "Eliminated")
// countries
def_area("FRANCE", "France", COUNTRY, null)
def_area("TUNISIA", "Tunisia", COUNTRY, "TUNISIA")
def_area("MOROCCO", "Morocco", COUNTRY, "MOROCCO")
def_area("I-1", "Barika", RURAL, "I")
def_area("I-2", "Batna", REMOTE, "I")
def_area("I-3", "Biskra", REMOTE, "I")
def_area("I-4", "Tebessa", RURAL, "I")
def_area("CONSTANTINE", "Constantine", URBAN, "II")
def_area("II-1", "Setif", RURAL, "II")
def_area("II-2", "Philippeville", RURAL, "II")
def_area("II-3", "Souk Ahras", RURAL, "II")
def_area("III-1", "Tizi Ouzou", RURAL, "III")
def_area("III-2", "Bordj Bou Arreridj", RURAL, "III")
def_area("III-3", "Bougie", RURAL, "III")
def_area("ALGIERS", "Algiers", URBAN, "IV")
def_area("IV-1", "Medea", RURAL, "IV")
def_area("IV-2", "Orleansville", RURAL, "IV")
def_area("ORAN", "Oran", URBAN, "V")
def_area("V-1", "Mecheria", REMOTE, "V")
def_area("V-2", "Tlemcen", RURAL, "V")
def_area("V-3", "Sidi Bel Abbes", RURAL, "V")
def_area("V-4", "Mostaganem", RURAL, "V")
def_area("V-5", "Saida", REMOTE, "V")
def_area("V-6", "Mascara", REMOTE, "V")
def_area("V-7", "Ain Sefra", REMOTE, "V")
def_area("V-8", "Laghouat", REMOTE, "V")
def_area("VI-1", "Sidi Aissa", REMOTE, "VI")
def_area("VI-2", "Ain Qussera", RURAL, "VI")
let adjacents = {}
function def_adjacent(id, neighbours) {
function add_adjacent(from, to) {
const from_id = locations[from]
if (!(from_id in adjacents)) {
adjacents[from_id] = []
}
adjacents[from_id].push(locations[to])
}
for (const n of neighbours) {
add_adjacent(id, n)
add_adjacent(n, id)
}
}
// only adjacent with neighbour zones are tracked, defined one way but they are bidirectional
def_adjacent("TUNISIA", ["I-2", "I-3", "I-4", "II-3"])
def_adjacent("MOROCCO", ["V-1", "V-2", "V-7"])
def_adjacent("I-1", ["II-1", "III-2", "VI-1"])
def_adjacent("I-3", ["V-8", "VI-1"])
def_adjacent("I-4", ["II-1", "II-2", "II-3"])
def_adjacent("II-1", ["III-2", "III-3"])
def_adjacent("III-1", ["IV-1"])
def_adjacent("III-2", ["IV-1", "VI-1"])
def_adjacent("IV-1", ["VI-1", "VI-2"])
def_adjacent("IV-2", ["V-4", "VI-2"])
def_adjacent("V-4", ["VI-2"])
def_adjacent("V-6", ["VI-2"])
def_adjacent("V-8", ["VI-1", "VI-2"])
data.locations = locations
data.areas = areas
data.zone_areas = zone_areas
data.adjacents = adjacents
let units = []
const FLN = 0
const GOV = 1
// unit types
const FR_XX = 0
const FR_X = 1
const EL_X = 2
const AL_X = 3
const POL = 4
const FAILEK = 5
const BAND = 6
const CADRE = 7
const FRONT = 8
function def_unit(side, type, name, klass, evasion_contact, firepower, count = 1) {
for (let i = 0; i < count; ++i) {
units.push({side, type, name, class: klass, evasion_contact, firepower})
}
}
def_unit(GOV, FR_XX, "French 2nd division", "fr_xx_2", 1, 25)
def_unit(GOV, FR_XX, "French 4th division", "fr_xx_4", 1, 25)
def_unit(GOV, FR_XX, "French 9th division", "fr_xx_9", 1, 25)
def_unit(GOV, FR_XX, "French 12th division", "fr_xx_12", 1, 25)
def_unit(GOV, FR_XX, "French 13th division", "fr_xx_13", 1, 25)
def_unit(GOV, FR_XX, "French 14th division", "fr_xx_14", 1, 25)
def_unit(GOV, FR_XX, "French 19th division", "fr_xx_19", 1, 25)
def_unit(GOV, FR_XX, "French 20th division", "fr_xx_20", 1, 25)
def_unit(GOV, FR_XX, "French 21th division", "fr_xx_21", 1, 25)
def_unit(GOV, FR_XX, "French 29th division", "fr_xx_29", 1, 25)
def_unit(GOV, FR_XX, "French 27th division", "fr_xx_27", 1, 25)
def_unit(GOV, FR_XX, "French 5th division", "fr_xx_5", 1, 25)
def_unit(GOV, FR_XX, "French 7th division", "fr_xx_7", 1, 25) // rules errata: - The French light mechanized division (circle with slash through it) should be numbered "7", not "2"
def_unit(GOV, FR_X, "French brigade", "fr_x", 1, 6, 4)
def_unit(GOV, EL_X, "French elite brigade", "fr_elite_x_para", 2, 9, 3)
def_unit(GOV, EL_X, "French elite brigade", "fr_elite_x_inf", 2, 9)
def_unit(GOV, EL_X, "French elite brigade", "fr_elite_x_marine", 2, 9, 3)
def_unit(GOV, AL_X, "Algerian brigade", "alg_x", 1, 5, 6)
def_unit(GOV, POL, "Algerian Police", "alg_police", 2, 2, 10)
def_unit(FLN, FAILEK, "FLN Failek", "fln_failek", 2, 4, 10)
def_unit(FLN, BAND, "FLN Band", "fln_band", 3, 2, 24)
def_unit(FLN, CADRE, "FLN Cadre", "fln_cadre", 4, 1, 30)
def_unit(FLN, FRONT, "FLN Front", "fln_front", 3, 3, 16)
console.log("const area_count =", areas.length)
console.log("const unit_count =", units.length)
console.log("const first_gov_unit =", units.findIndex((u) => u.side === GOV))
console.log("const last_gov_unit =", units.findLastIndex((u) => u.side === GOV))
console.log("const first_fln_unit =", units.findIndex((u) => u.side === FLN))
console.log("const last_fln_unit =", units.findLastIndex((u) => u.side === FLN))
data.units = units
fs.writeFileSync("data.js", "const data = " + JSON.stringify(data, 0, 0) + "\nif (typeof module !== 'undefined') module.exports = data\n")
|