summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-26 22:10:36 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-26 22:14:53 +0200
commit76375e277603bc144ea1c572ec273bd3f3a79dcb (patch)
treeafeed68e1594e28f4d273435a812dd482376093b /tools
parentc2df9cc16c98db5286509e2bf6deef028b111fac (diff)
download1989-dawn-of-freedom-76375e277603bc144ea1c572ec273bd3f3a79dcb.tar.gz
Generate space and card name constants for code.
Diffstat (limited to 'tools')
-rw-r--r--tools/gencode.js1
-rw-r--r--tools/genconst.js25
2 files changed, 25 insertions, 1 deletions
diff --git a/tools/gencode.js b/tools/gencode.js
index f2e3a26..a46823f 100644
--- a/tools/gencode.js
+++ b/tools/gencode.js
@@ -103,4 +103,3 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) {
emit(["return"])
console.log("]")
-console.log("// #endregion")
diff --git a/tools/genconst.js b/tools/genconst.js
new file mode 100644
index 0000000..a2b9235
--- /dev/null
+++ b/tools/genconst.js
@@ -0,0 +1,25 @@
+const data = require("../data.js")
+
+function clean_name(s) {
+ return s.toUpperCase()
+ .replace(" - ", "_")
+ .replace(/[ /-]/g, "_")
+ .replace(/[!,*"'.]/g, "")
+}
+
+console.log("")
+
+console.log("// SPACES")
+for (let s of data.spaces) {
+ console.log("const S_" + clean_name(s.ascii_name) + " = " + s.space_id)
+}
+
+console.log("")
+
+console.log("// CARDS")
+for (let c of data.cards) {
+ if (c)
+ console.log("const C_" + clean_name(c.name) + " = " + c.number)
+}
+
+console.log("")