summaryrefslogtreecommitdiff
path: root/tools/genconst.js
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/genconst.js
parentc2df9cc16c98db5286509e2bf6deef028b111fac (diff)
download1989-dawn-of-freedom-76375e277603bc144ea1c572ec273bd3f3a79dcb.tar.gz
Generate space and card name constants for code.
Diffstat (limited to 'tools/genconst.js')
-rw-r--r--tools/genconst.js25
1 files changed, 25 insertions, 0 deletions
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("")