summaryrefslogtreecommitdiff
path: root/db/areas.php
diff options
context:
space:
mode:
Diffstat (limited to 'db/areas.php')
-rw-r--r--db/areas.php49
1 files changed, 40 insertions, 9 deletions
diff --git a/db/areas.php b/db/areas.php
index d2c9af9..fd0943a 100644
--- a/db/areas.php
+++ b/db/areas.php
@@ -8,16 +8,15 @@ foreach (scandir(__DIR__ . '/areas') as $file) {
$area = json_decode(file_get_contents($filePath), true);
- $encounterSlug = $area['modules/tuxemon.encounter'] ?? '';
- $encounters = json_decode(@file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/encounter/$encounterSlug.json") ?? '', true);
-
- $environmentSlug = $area['modules/tuxemon.environment'] ?? '';
- $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");
+ // encounters
$area['encounters'] ??= [];
+
+ $encounterSlug = $area['modules/tuxemon.encounter'] ?? '';
+ $encounters = json_decode(@file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/encounter/$encounterSlug.json") ?? '', true);
array_push($area['encounters'], ...$encounters['monsters'] ?? []);
+
if (! empty($area['encounters'])) {
// filter out duplicates, because day/night is ignored for now
$duplicates = [];
@@ -34,16 +33,38 @@ foreach (scandir(__DIR__ . '/areas') as $file) {
}
$area['encounter_percent_total'] = array_sum(array_column($area['encounters'], 'encounter_percent'));
}
+
$area['requiredEncounters'] ??= 0;
+
+ // trainers
+
$area['trainers'] ??= [];
+
+ // environment
+
+ $environmentSlug = $area['modules/tuxemon.environment'] ?? '';
+ $environment = json_decode(@file_get_contents(dirname(__DIR__) . "/modules/tuxemon/mods/tuxemon/db/environment/$environmentSlug.json") ?? '', true);
+
+ if (isset($area['environment'])) {
+ $environment = json_decode(file_get_contents(__DIR__ . "/environment/$area[environment].json"), true);
+ $environment['battle_graphics']['background'] = '/db/environment/' . $environment['battle_graphics']['background'];
+ } else if (! empty($environment)) {
+ $environment['battle_graphics']['background'] = '/modules/tuxemon/mods/tuxemon/gfx/ui/combat/' . $environment['battle_graphics']['background'];
+ }
+
$area['environment'] = $environment;
+
+
+ // map
+
+ $map = @file_get_contents(__DIR__ . "/maps/$fileName.svg");
+
$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'] ?? '';
- }
+
+ // locations
$area['locations'] ??= [];
foreach ($area['locations'] as $locationId => $location) {
@@ -54,5 +75,15 @@ foreach (scandir(__DIR__ . '/areas') as $file) {
}
}
+
+ // connections
+
+ 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'] ?? '';
+ }
+
+
+ // build
+
file_put_contents(__DIR__ . "/_generated/areas/$fileName.json", json_encode($area));
}