summaryrefslogtreecommitdiff
path: root/tools/gendata.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-08 12:08:30 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:47 +0100
commit301bc138267a99d1135c5eec30cedbd316eed742 (patch)
treecd82e5f4c896e5671bdb98746e702a0348c76af7 /tools/gendata.js
parentf86d574e5256e11b5a41fd922033274ab7c4eb61 (diff)
downloadtable-battles-301bc138267a99d1135c5eec30cedbd316eed742.tar.gz
more data
Diffstat (limited to 'tools/gendata.js')
-rw-r--r--tools/gendata.js41
1 files changed, 35 insertions, 6 deletions
diff --git a/tools/gendata.js b/tools/gendata.js
index 14fcfd3..dce36b3 100644
--- a/tools/gendata.js
+++ b/tools/gendata.js
@@ -143,8 +143,17 @@ for (let c of card_records) {
result.push(`</div>`)
}
- if (c.rule)
- card.rule = c.rule_tag
+ if (c.rule) {
+ card.rules = {}
+ for (let rule of c.rule.split("; ")) {
+ if (/=/.test(rule)) {
+ let [ key, vals ] = rule.split("=")
+ card.rules[key] = vals.split(",")
+ } else {
+ card.rules[rule] = 1
+ }
+ }
+ }
if (c.rule_text) {
card.rule_text = c.rule_text
@@ -157,8 +166,11 @@ for (let c of card_records) {
}
if (c.reserve) {
- console.log("RESERVE=", c.reserve)
- if (c.reserve === "RETIRE")
+ if (c.reserve === "RETIRE, Ward") {
+ card.retire = 1
+ card.reserve = [ "Ward" ]
+ }
+ else if (c.reserve === "RETIRE")
card.retire = 1
else if (c.reserve === "PURSUIT")
card.pursuit = 1
@@ -167,8 +179,12 @@ for (let c of card_records) {
else
card.reserve = c.reserve.split(" or ")
- if (c.reserve === "RETIRE" || c.reserve === "PURSUIT")
- result.push(`<div class="reserve">${c.reserve}</div>`)
+ if (card.retire && card.reserve)
+ result.push(`<div class="reserve">RETIRE; RESERVE (${card.reserve.join(", ")})</div>`)
+ else if (card.retire)
+ result.push(`<div class="reserve">RETIRE</div>`)
+ else if (card.pursuit)
+ result.push(`<div class="reserve">PURSUIT</div>`)
else
result.push(`<div class="reserve">IN RESERVE (${c.reserve})</div>`)
}
@@ -231,12 +247,25 @@ for (let c of cards) {
a.target_list = find_friendly_cards(c.scenario, c.wing)
else if (a.target === "Any friendly Pink formation")
a.target_list = find_wing_cards(c.scenario, WING.pink)
+ else if (a.target === "Any Red formation")
+ a.target_list = find_wing_cards(c.scenario, WING.red)
+ else if (a.target.startsWith("Any attack on "))
+ a.target_list = a.target.replace("Any attack on ", "").split(" or ").map(name => find_card(c.scenario, name))
+ else if (a.target === "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 (a.target === "The Fog Lifts...")
a.target_list = []
else
a.target_list = a.target.split(/, | OR /).map(name => find_card(c.scenario, name))
}
}
+ if (c.rules) {
+ for (let key in c.rules) {
+ let val = c.rules[key]
+ if (Array.isArray(val))
+ c.rules[key] = val.map(number => card_index[number])
+ }
+ }
if (c.pursuit) {
if (c.actions[0].type !== "Attack") throw new Error("PURSUIT without Attack as first action")
if (c.actions[0].target_list.length !== 1) throw new Error("PURSUIT with more than one target!")