summaryrefslogtreecommitdiff
path: root/db/areas.php
blob: 55b2177ab6568fb350a527c003c6f761896a407b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php

foreach (scandir(__DIR__ . '/areas') as $file) {
  if (in_array($file, ['.', '..'])) continue;

  $filePath = __DIR__ . '/areas/' . $file;
  $fileName = pathinfo($file, PATHINFO_FILENAME);

  $area = json_decode(file_get_contents($filePath), true);
  $encounters = json_decode(@file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/encounter/$area[encounter_slug].json") ?? '', true);
  $environment = json_decode(file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/environment/$area[environment_slug].json"), true);

  array_push($area['encounters'], ...$encounters['monsters'] ?? []);
  $area['environment'] = $environment;

  file_put_contents(__DIR__ . "/_generated/areas/$fileName.json", json_encode($area));
}