summaryrefslogtreecommitdiff
path: root/tools/gendata.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-09 19:58:23 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:47 +0100
commit3d4909f946f724562d354a55a721ded43a12c268 (patch)
tree7e6659790356e7c021c51f85b9537f85a8d54d23 /tools/gendata.js
parentc5f35f99aa9605a7baf43d6c407b126a51e878f8 (diff)
downloadtable-battles-3d4909f946f724562d354a55a721ded43a12c268.tar.gz
Towton and Edgecote Moor. take_from, rout_with, and remove_with.
Diffstat (limited to 'tools/gendata.js')
-rw-r--r--tools/gendata.js41
1 files changed, 23 insertions, 18 deletions
diff --git a/tools/gendata.js b/tools/gendata.js
index 9580130..1bc9099 100644
--- a/tools/gendata.js
+++ b/tools/gendata.js
@@ -75,21 +75,13 @@ for (let c of card_records) {
result.push(`<div class="formation card">`)
result.push(`<div class="name ${c.wing}">${c.name}</div>`)
- if (c.symbol === "Inf1") {
+ if (c.symbol === "inf") {
card.infantry = 1
- result.push(`<div class="symbol infantry1"></div>`)
+ result.push(`<div class="symbol infantry"></div>`)
}
- if (c.symbol === "Inf2") {
- card.infantry = 2
- result.push(`<div class="symbol infantry2"></div>`)
- }
- if (c.symbol === "Cav1") {
+ if (c.symbol === "cav") {
card.cavalry = 1
- result.push(`<div class="symbol cavalry1"></div>`)
- }
- if (c.symbol === "Cav2") {
- card.cavalry = 2
- result.push(`<div class="symbol cavalry2"></div>`)
+ result.push(`<div class="symbol cavalry"></div>`)
}
if (card.strength)
@@ -177,9 +169,7 @@ for (let c of card_records) {
card.retire = 1
else if (c.reserve === "PURSUIT")
card.pursuit = 1
- else if (c.reserve === "Commanded")
- card.reserve = []
- else if (c.reserve === "See Above")
+ else if (c.reserve === "Commanded" || c.reserve === "See Above" || c.reserve === "Special Rule")
card.reserve = []
else
card.reserve = c.reserve.split(" or ")
@@ -242,7 +232,7 @@ function find_wing_cards(scenario, wing) {
}
/* process action and reserve targets */
-for (let c of cards) {
+function process_card(c) {
for (let a of c.actions) {
if (a.target) {
let tname = a.target.replace(" out of reserve", "")
@@ -260,12 +250,16 @@ for (let c of cards) {
a.target_list = find_wing_cards(c.scenario, WING.pink)
else if (tname === "Any Blue formation")
a.target_list = find_wing_cards(c.scenario, WING.blue)
+ else if (tname === "Any Dark Blue formation")
+ a.target_list = find_wing_cards(c.scenario, WING.dkblue)
else if (tname.startsWith("Any attack on "))
a.target_list = tname.replace("Any attack on ", "").split(" or ").map(name => find_card(c.scenario, name))
else if (tname === "Any friendly but Little Round Top")
a.target_list = find_friendly_cards(c.scenario, c.wing).filter(x => x !== find_card(c.scenario, "Little Round Top"))
+ else if (tname === 'Activate "Retreat to Nivelles"')
+ a.target_list = [ "Retreat to Nivelles" ]
else if (tname === "The Fog Lifts...")
- a.target_list = []
+ a.target_list = [ "The Fog" ]
else
a.target_list = tname.split(/, | OR | or | and /).map(name => find_card(c.scenario, name))
}
@@ -286,7 +280,18 @@ for (let c of cards) {
c.reserve = c.reserve.map(name => find_card(c.scenario, name))
}
-fs.writeFileSync("info/all-cards.html", result.join("\n"))
+let failed = false
+for (let c of cards) {
+ try {
+ process_card(c)
+ } catch (err) {
+ console.log(err)
+ failed = true
+ }
+}
+
+if (!failed)
+ fs.writeFileSync("info/all-cards.html", result.join("\n"))
result = [
`<!doctype html>