From bdd654a6ef19ff2e9739e7c56383af1ba9483284 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 15 Dec 2023 20:05:59 +0100 Subject: gendata scenario reference cards --- tools/gendata.js | 115 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 46 deletions(-) (limited to 'tools') diff --git a/tools/gendata.js b/tools/gendata.js index 07c4f47..ff38695 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -4,26 +4,7 @@ const { parse } = require("csv-parse/sync") var card_records = parse(fs.readFileSync("tools/cards.csv", "utf-8"), { columns: true, records_with_empty_values: true }) var scenario_records = parse(fs.readFileSync("tools/scenarios.csv", "utf-8"), { columns: true, skip_records_with_empty_values: true }) -var result = [ -` - - - -Table Battle Cards - - - - - -
` -] +var result = [] const WING = { red: 0, pink: 1, blue: 2, dkblue: 3 } const WING_ICON = [ "\u2666", "\u2665", "\u2663", "\u2660" ] @@ -51,13 +32,26 @@ function remap(x) { let last_wing = null +var last_scen = null +var result = [ ] + +var scenario_html = {} + +function flush_scenario_html() { + scenario_html[last_scen] = result + result = [] +} + for (let c of card_records) { if (!c.number) { - result.push(`

${c.scenario}

`) + if (result.length > 2) + flush_scenario_html() last_wing = null continue } + last_scen = c.scenario + if ((c.wing === "blue" || c.wing === "dkblue") && (last_wing === "red" || last_wing === "pink")) result.push(`
`) if ((last_wing === "blue" || last_wing === "dkblue") && (c.wing === "red" || c.wing === "pink")) @@ -275,12 +269,16 @@ for (let c of card_records) { result.push(`
`) + /* if (c.number.endsWith("A")) result.push(``) else result.push(``) + */ } +flush_scenario_html() + function find_card(scenario, name) { name = name.replace("*", "") name = name.replace(" (Voluntary)", "") @@ -398,13 +396,16 @@ fs.writeFileSync("info/all-cards.html", result.join("\n")) result = [ ` + + Table Battle Scenarios @@ -448,29 +449,51 @@ for (let s of scenario_records) { rule_text: s.rule_text || undefined, lore_text: s.lore_text || undefined, }) - result.push(` -
-
-
${s.name}
-
${s.date}
-
-
-
${s.player1}
-
Cards ${s.cards1}
-
Morale: ${s.morale1}
-
${s.tactical1 ? "Tactical Victory: " + s.tactical1 : ""}
-
-
-
${s.player2}
-
Cards ${s.cards2}
-
Morale: ${s.morale2}
-
${s.tactical2 ? "Tactical Victory: " + s.tactical2 : ""}
-
-
${s.rule_text}
-
${s.lore_text}
-
${s.number}
-
- `) + var html = +`
+
+
${s.name}
+
${s.date}
+
+
+
${s.player1}
+
Cards ${s.cards1}
+
Morale: ${s.morale1}
+
${s.tactical1 ? "Tactical Victory: " + s.tactical1 : ""}
+
+
+
${s.player2}
+
Cards ${s.cards2}
+
Morale: ${s.morale2}
+
${s.tactical2 ? "Tactical Victory: " + s.tactical2 : ""}
+
+
${s.rule_text}
+
${s.lore_text}
+
${s.number}
+
` + + scenario_html[s.number].unshift(`
`) + scenario_html[s.number].unshift(html) + scenario_html[s.number].unshift( +` + + + + +${s.number} - ${s.name} + + + + + +

${s.number} - ${s.name}

+
`) + + fs.writeFileSync(`info/s_${s.number}.html`, scenario_html[s.number].join("\n")) + result.push(``, html, '') } catch (err) { console.log(err) } -- cgit v1.2.3