Add seed JSON output (per-game, games.json, pokemon.json)

Wire output module into CLI pipeline: route ordering, special encounter
merging, and JSON writing for per-game encounters, global games list,
and pokemon list with types and sprite paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Julian Tabel
2026-02-11 10:59:56 +01:00
parent 29b954726a
commit df55233c62
4 changed files with 281 additions and 10 deletions

View File

@@ -18,6 +18,7 @@ from pathlib import Path
from .loader import load_pokedb_data, load_seed_config
from .mappings import PokemonMapper, LocationMapper, build_version_map, map_encounter_method
from .output import sort_routes, merge_special_encounters, write_game_json, write_games_json, write_pokemon_json
from .processing import filter_encounters_for_game, process_encounters, build_routes
from .sprites import download_sprites
@@ -157,6 +158,8 @@ def main(argv: list[str] | None = None) -> None:
continue
games_to_process.append((vg_key, slug, generation))
all_encountered_form_ids: set[str] = set()
for vg_key, game_slug, generation in games_to_process:
print(f"\n--- {game_slug} ---")
@@ -168,6 +171,12 @@ def main(argv: list[str] | None = None) -> None:
print(f" Raw encounters: {len(game_encounters)}")
# Track encountered form IDs for pokemon.json
for e in game_encounters:
fid = e.get("pokemon_form_identifier")
if fid:
all_encountered_form_ids.add(fid)
# Process into grouped encounters
encounters_by_area = process_encounters(
game_encounters, generation, pokemon_mapper, location_mapper,
@@ -177,6 +186,12 @@ def main(argv: list[str] | None = None) -> None:
# Build route hierarchy
routes = build_routes(encounters_by_area, location_mapper)
# Merge special encounters (starters, gifts, fossils)
routes = merge_special_encounters(routes, config, vg_key, pokemon_mapper)
# Sort routes by game progression order
routes = sort_routes(routes, config, vg_key)
# Stats
total_routes = sum(1 + len(r.children) for r in routes)
total_enc = sum(
@@ -186,13 +201,21 @@ def main(argv: list[str] | None = None) -> None:
print(f" Routes: {total_routes}")
print(f" Encounter entries: {total_enc}")
# Write per-game JSON
write_game_json(routes, output_dir, game_slug)
# Download sprites for all encountered pokemon
print("\nDownloading sprites...")
sprites_dir = output_dir / "sprites"
sprite_map = download_sprites(pokemon_mapper, form_ids_in_encounters, sprites_dir)
sprite_map = download_sprites(pokemon_mapper, all_encountered_form_ids, sprites_dir)
print(f" Sprite map covers {len(sprite_map)} forms")
print("\nProcessing complete. Output not yet written (subtask gkcy).")
# Write global JSON files
print("\nWriting global data files...")
write_games_json(config, output_dir)
write_pokemon_json(pokemon_mapper, all_encountered_form_ids, sprite_map, output_dir)
print("\nDone!")
if __name__ == "__main__":