diff options
Diffstat (limited to 'db/npc.php')
-rw-r--r-- | db/npc.php | 43 |
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)); +} |