`)
}
function make_action(type, requirement, target, effect) {
let a = { type }
if (requirement) a.requirement = requirement
if (target) a.target = target
if (effect) a.effect = effect
return a
}
if (c.action1_type) {
card.actions.push(make_action(c.action1_type, c.action1_req, c.action1_target, c.action1_effect))
result.push(`
`)
}
if (c.rule)
card.rule = c.rule_tag
if (c.rule_text) {
card.rule_text = c.rule_text
result.push(`
${c.rule_text}
`)
}
if (c.lore_text) {
card.lore_text = c.lore_text
result.push(`
${c.lore_text}
`)
}
if (c.reserve) {
if (c.reserve === "RETIRE")
card.retire = 1
else if (c.reserve === "PURSUIT")
card.pursuit = 1
else if (c.reserve === "Commanded")
card.reserve = []
else
card.reserve = c.reserve.split(" or ")
if (c.reserve === "RETIRE" || c.reserve === "PURSUIT")
result.push(`
${c.reserve}
`)
else
result.push(`
IN RESERVE (${c.reserve})
`)
}
result.push(`
${c.number}
`)
result.push(`
${WING_ICON[card.wing]}
`)
result.push(`
`)
}
function find_card(scenario, name) {
name = name.replace(" out of reserve", "")
for (let c of cards)
if (c.scenario === scenario && c.name === name)
return card_index[c.number]
throw new Error("CARD NOT FOUND: " + scenario + " " + name)
}
function find_enemy_cards(scenario, wing) {
let w1, w2
if (wing === 0 || wing === 1)
w1 = 2, w2 = 3
if (wing === 2 || wing === 3)
w1 = 0, w2 = 1
let list = []
for (let c of cards)
if (c.scenario === scenario && (c.wing === w1 || c.wing === w2))
list.push(card_index[c.number])
return list
}
function find_friendly_cards(scenario, wing) {
let w1, w2
if (wing === 0 || wing === 1)
w1 = 0, w2 = 1
if (wing === 2 || wing === 3)
w1 = 2, w2 = 3
let list = []
for (let c of cards)
if (c.scenario === scenario && (c.wing === w1 || c.wing === w1))
list.push(card_index[c.number])
return list
}
function find_wing_cards(scenario, wing) {
let list = []
for (let c of cards)
if (c.scenario === scenario && c.wing === wing)
list.push(card_index[c.number])
return list
}
/* process action and reserve targets */
for (let c of cards) {
for (let a of c.actions) {
if (a.target) {
if (a.target === "Any enemy attack" || a.target === "Any enemy formation")
a.target_list = find_enemy_cards(c.scenario, c.wing)
else if (a.target === "Any friendly formation")
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
a.target_list = a.target.split(", ").map(name => find_card(c.scenario, name))
}
}
if (c.reserve)
c.reserve = c.reserve.map(name => find_card(c.scenario, name))
}
fs.writeFileSync("info/all-cards.html", result.join("\n"))
result = [
`
Table Battle Cards
`
]
function parse_cards(text) {
let out = []
let list = text.split(",")
for (let range of list) {
let [a, b] = range.split("-")
a = card_index[a]
b = card_index[b]
if (a === undefined || b === undefined)
throw new Error("MISSING CARDS FOR " + text)
for (let i = a; i <= b; ++i)
out.push(i)
}
return out
}
let last_exp = null
for (let s of scenario_records) {
if (!s.name)
continue
if (last_exp !== s.expansion) {
result.push(`