blob: c1d97e0dc22dc653dddb66fb026af28a84b5ac42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
<?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);
$encounterSlug = $area['modules/tuxemon.encounter'] ?? '';
$environmentSlug = $area['modules/tuxemon.environment'] ?? '';
$encounters = json_decode(@file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/encounter/$encounterSlug.json") ?? '', true);
$environment = json_decode(@file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/environment/$environmentSlug.json") ?? '', true);
$map = @file_get_contents(__DIR__ . "/maps/$fileName.svg");
$area['encounters'] ??= [];
array_push($area['encounters'], ...$encounters['monsters'] ?? []);
$area['requiredEncounters'] ??= 0;
$area['trainers'] ??= [];
$area['environment'] = $environment;
$area['map'] = $map;
foreach ($area['connections'] as $areaSlug => $connection) {
$area['connections'][$areaSlug]['modules/tuxemon.slug'] = json_decode(file_get_contents(__DIR__ . "/areas/$areaSlug.json"), true)['modules/tuxemon.slug'];
}
foreach ($area['locations'] ?? [] as $locationId => $location) {
if ($location['type'] == 'shop') {
$economySlug = $location['modules/tuxemon.economy'];
$scoop = json_decode(file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/economy/$economySlug.json"), true);
array_unshift($area['locations'][$locationId]['items'], ...$scoop['items']);
}
}
file_put_contents(__DIR__ . "/_generated/areas/$fileName.json", json_encode($area));
}
|