From 80fb3b86b2372a7ca864edb86e473959c9bbf3b7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 30 May 2024 17:10:09 +0200 Subject: TOOLS --- tools/parse-cards.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tools/parse-cards.js (limited to 'tools/parse-cards.js') diff --git a/tools/parse-cards.js b/tools/parse-cards.js new file mode 100644 index 0000000..940d826 --- /dev/null +++ b/tools/parse-cards.js @@ -0,0 +1,48 @@ +const fs = require("fs") + +let fate_text = [] +let fate_effect = [] + +function parse_fate_cards_raw() { + let num = 1 + let out = [] + let buf = [] + + function flush_card() { + if (buf.length === 0) + return + if (buf.length !== 9) + throw "BAD CARD" + + let number = parseInt(buf[8]) + let x = (number - 1) * 4 + + + fate_text[x+0] = buf[0] + fate_text[x+1] = buf[2] + fate_text[x+2] = buf[4] + fate_text[x+3] = buf[6] + + fate_effect[x+0] = buf[1] + fate_effect[x+1] = buf[3] + fate_effect[x+2] = buf[5] + fate_effect[x+3] = buf[7] + } + + fs.readFileSync("tools/fatecards.ascii.txt", "utf-8").split("\n").forEach(line => { + line = line.trim() + + if (line[0] === "-") { + flush_card() + num++ + buf = [] + } else if (line.length > 0) { + buf.push(line) + } + }) +} + +parse_fate_cards_raw() + +console.log("const fate_flavor_text = " + JSON.stringify(fate_text, 0, 4)) +console.log("const fate_effect_text = " + JSON.stringify(fate_effect, 0, 4)) -- cgit v1.2.3