From 95b90a9b4c21d6fd0805177d5193a8a62fa217ad Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 20 Nov 2023 02:58:24 +0100 Subject: data processing --- tools/gendata.js | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 tools/gendata.js (limited to 'tools/gendata.js') diff --git a/tools/gendata.js b/tools/gendata.js new file mode 100644 index 0000000..764f011 --- /dev/null +++ b/tools/gendata.js @@ -0,0 +1,86 @@ +const fs = require("fs") +const { parse } = require("csv-parse/sync") + +var card_buffer = fs.readFileSync("tools/cards.csv", "utf-8") +var card_records = parse(card_buffer, { columns: true, skip_empty_lines: true }) + +// console.log(card_records) + +var result = [ +` +Table Battle Cards + + + +
` +] + +for (let c of card_records) { + if (!c.scenario) + continue + + if (!c.number) { + result.push(`

${c.scenario}

`) + continue + } + + if (!c.name) + continue + + if (c.strength.endsWith("*")) { + c.strength = parseInt(c.strength) + c.star = true + } + + result.push(`
`) + result.push(`
${c.name}
`) + if (c.strength) + result.push(`
${c.strength}
`) + + if (c.dice) { + if (c.star) + result.push(`
${c.dice}
`) + else + result.push(`
${c.dice}
`) + } + + if (c.action1_type) { + result.push(`
`) + result.push(`
${c.action1_type}
`) + result.push(`
${c.action1_req}
`) + result.push(`
${c.action1_target}
`) + if (c.action1_effect) + result.push(`
${c.action1_effect}
`) + result.push(`
`) + } + + if (c.action2_type || c.action2_effect) { + result.push(`
`) + result.push(`
${c.action2_type}
`) + result.push(`
${c.action2_req}
`) + result.push(`
${c.action2_target}
`) + if (c.action2_effect) + result.push(`
${c.action2_effect}
`) + result.push(`
`) + } + + if (c.flavor) + result.push(`
${c.flavor}
`) + + if (c.reserve) { + if (c.reserve === "RETIRE" || c.reserve === "PURSUIT") + result.push(`
${c.reserve}
`) + else + result.push(`
IN RESERVE (${c.reserve})
`) + } + + result.push(`
${c.number}
`) + result.push(`
${c.wing}
`) + + result.push(`
`) +} + +console.log(result.join("\n")) -- cgit v1.2.3