From 11bae60c9d3cd333ae6b3921e0858f808efaa3dc Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 16 Dec 2023 17:18:12 +0100 Subject: reference cards --- tools/gendata.js | 125 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 48 deletions(-) (limited to 'tools') diff --git a/tools/gendata.js b/tools/gendata.js index 370c9e0..5e4891b 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -33,6 +33,26 @@ function remap(x) { let last_wing = null var last_scen = null + +var allcards = [ +` + + + + +Table Battle Scenarios + + + + + +
` +] + var result = [ ] var scenario_html = {} @@ -44,18 +64,22 @@ function flush_scenario_html() { for (let c of card_records) { if (!c.number) { - if (result.length > 2) + allcards.push(`

${c.scenario}

`) + if (result.length > 2) { flush_scenario_html() + } last_wing = null continue } last_scen = c.scenario + let html = [] + if ((c.wing === "blue" || c.wing === "dkblue") && (last_wing === "red" || last_wing === "pink")) - result.push(`
`) + html.push(`
`) if ((last_wing === "blue" || last_wing === "dkblue") && (c.wing === "red" || c.wing === "pink")) - result.push(`
`) + html.push(`
`) last_wing = c.wing if (!c.name) @@ -117,46 +141,46 @@ for (let c of card_records) { if (SQUEEZE_MARGINS.includes(c.number)) { card.squeeze = 1 - result.push(`
`) + html.push(`
`) } else { - result.push(`
`) + html.push(`
`) } if (c.symbol) - result.push(`
${c.name}
`) + html.push(`
${c.name}
`) else - result.push(`
${c.name}
`) + html.push(`
${c.name}
`) if (c.symbol === "inf") { card.infantry = 1 - result.push(`
`) + html.push(`
`) } if (c.symbol === "cav") { card.cavalry = 1 - result.push(`
`) + html.push(`
`) } if (card.strength) - result.push(`
${card.strength}
`) + html.push(`
${card.strength}
`) else - result.push(`
${c.strength}
`) + html.push(`
${c.strength}
`) if (c.link === "LR") { card.link = [ id - 1, id + 1 ] - result.push(``) - result.push(``) + html.push(``) + html.push(``) } else if (c.link === "L") { - result.push(``) + html.push(``) card.link = [ id - 1 ] } else if (c.link === "R") { - result.push(``) + html.push(``) card.link = [ id + 1 ] } if (c.dice) { if (card.morale === 2) - result.push(`
`) - result.push(`
${c.dice}
`) + html.push(`
`) + html.push(`
${c.dice}
`) } function make_action(type, requirement, target, effect, rule_text, short) { @@ -172,54 +196,54 @@ for (let c of card_records) { if (c.action1_type) { let short = c.action1_effect && (c.rule_text_1 || squeeze) card.actions.push(make_action(c.action1_type, c.action1_req, c.action1_target, c.action1_effect, c.action1_rule_text, short)) - result.push(`
`) + html.push(`
`) if (/Screen|Absorb|Counterattack/.test(c.action1_type)) - result.push(`
${c.action1_type}
`) + html.push(`
${c.action1_type}
`) else - result.push(`
${c.action1_type}
`) - result.push(`
${c.action1_req}
`) - result.push(`
${c.action1_target}
`) + html.push(`
${c.action1_type}
`) + html.push(`
${c.action1_req}
`) + html.push(`
${c.action1_target}
`) if (c.action1_effect) { if (c.rule_text_1 || squeeze) - result.push(`
${c.action1_effect}
`) + html.push(`
${c.action1_effect}
`) else - result.push(`
${c.action1_effect}
`) + html.push(`
${c.action1_effect}
`) } - result.push(`
`) + html.push(`
`) } if (c.rule_text_1) { card.rule_text_1 = c.rule_text_1 - result.push(`
${c.rule_text_1}
`) + html.push(`
${c.rule_text_1}
`) } if (c.action2_type || c.action2_effect) { let short = c.action2_effect && (c.rule_text_2 || squeeze) card.actions.push(make_action(c.action2_type, c.action2_req, c.action2_target, c.action2_effect, c.action2_rule_text, short)) - result.push(`
`) + html.push(`
`) if (/Screen|Absorb|Counterattack/.test(c.action2_type)) - result.push(`
${c.action2_type}
`) + html.push(`
${c.action2_type}
`) else - result.push(`
${c.action2_type}
`) - result.push(`
${c.action2_req}
`) - result.push(`
${c.action2_target}
`) + html.push(`
${c.action2_type}
`) + html.push(`
${c.action2_req}
`) + html.push(`
${c.action2_target}
`) if (c.action2_effect) { if (c.rule_text_2 || squeeze) - result.push(`
${c.action2_effect}
`) + html.push(`
${c.action2_effect}
`) else - result.push(`
${c.action2_effect}
`) + html.push(`
${c.action2_effect}
`) } - result.push(`
`) + html.push(`
`) } if (c.rule_text_2) { card.rule_text_2 = c.rule_text_2 - result.push(`
${c.rule_text_2}
`) + html.push(`
${c.rule_text_2}
`) } if (c.lore_text) { card.lore_text = c.lore_text - result.push(`
${c.lore_text}
`) + html.push(`
${c.lore_text}
`) } if (c.rule) { @@ -253,28 +277,31 @@ for (let c of card_records) { card.reserve = c.reserve.split(" or ") if (card.retire && card.reserve) - result.push(`
RETIRE; RESERVE (${card.reserve.join(", ")})
`) + html.push(`
RETIRE; RESERVE (${card.reserve.join(", ")})
`) else if (card.retire && card.pursuit) - result.push(`
RETIRE, PURSUIT
`) + html.push(`
RETIRE, PURSUIT
`) else if (card.retire) - result.push(`
RETIRE
`) + html.push(`
RETIRE
`) else if (card.pursuit) - result.push(`
PURSUIT
`) + html.push(`
PURSUIT
`) else - result.push(`
IN RESERVE (${c.reserve})
`) + html.push(`
IN RESERVE (${c.reserve})
`) } - result.push(`
${c.number}
`) - result.push(`
${WING_ICON[card.wing]}
`) + html.push(`
${c.number}
`) + html.push(`
${WING_ICON[card.wing]}
`) - result.push(`
`) + html.push(`
`) + + for (let line of html) { + result.push(line) + allcards.push(line) + } - /* if (c.number.endsWith("A")) - result.push(``) + allcards.push(``) else - result.push(``) - */ + allcards.push(``) } flush_scenario_html() @@ -402,6 +429,8 @@ cards.forEach((c, ix) => { } }) +fs.writeFileSync("info/ref.html", allcards.join("\n")) + result = [ ` -- cgit v1.2.3