summaryrefslogtreecommitdiff
path: root/db/npc.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-31 20:23:06 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-31 20:23:06 +0200
commitc657c77d0cf49afba627b93848e1915e2ce7d3ff (patch)
tree5d96a65df277f52558cd5ff84f2fefbf4480a926 /db/npc.php
parent7f6ab8779bd143b1b5f3465e3681abcbc113d19d (diff)
story and npcs
Diffstat (limited to 'db/npc.php')
-rw-r--r--db/npc.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/db/npc.php b/db/npc.php
new file mode 100644
index 0000000..4aabc8a
--- /dev/null
+++ b/db/npc.php
@@ -0,0 +1,43 @@
+<?php
+
+$npcs = [];
+
+// modules/tuxemon
+$basePath = dirname(__DIR__) . '/modules/tuxemon/mods/tuxemon/db/npc';
+foreach (scandir($basePath) as $fileName) {
+ if (in_array($fileName, ['.', '..'])) continue;
+
+ $filePath = "$basePath/$fileName";
+ $json = json_decode(file_get_contents($filePath), true);
+
+ if (isset($json['slug']) && isset($json['template'])) {
+ $npcs[$json['slug']] = $json;
+ } else {
+ foreach ($json as $npc) {
+ $npcs[$npc['slug']] = $npc;
+ }
+ }
+}
+
+// tuxemon clicker
+$basePath = __DIR__ . '/npc';
+foreach (scandir($basePath) as $fileName) {
+ if (in_array($fileName, ['.', '..'])) continue;
+
+ $filePath = "$basePath/$fileName";
+ $npc = json_decode(file_get_contents($filePath), true);
+
+ $slug = $npc['modules/tuxemon.slug'] ?? pathinfo($fileName, PATHINFO_FILENAME);
+ $npcs[$slug] = [
+ 'slug' => $slug,
+ 'template' => [
+ [
+ 'sprite_name' => $npc['sprite'],
+ ],
+ ],
+ ];
+}
+
+foreach ($npcs as $slug => $npc) {
+ file_put_contents(__DIR__ . "/_generated/npc/$slug.json", json_encode($npc));
+}