--- # nuzlocke-tracker-3a5n title: Add condition data to seed files via PokeDB merge status: todo type: task priority: normal created_at: 2026-02-14T21:48:03Z updated_at: 2026-02-14T21:48:03Z parent: oqfo --- ## Problem The PokeDB data already contains per-condition encounter rates (`rate_morning`, `rate_day`, `rate_night`, `rate_spring`, `rate_summer`, etc.), but the current importer in `tools/import-pokedb` flattens them to `max()` in `extract_encounter_rate()`. We need to preserve these as `conditions` dicts in the seed JSON files. Re-running the full import would overwrite route names (normalized in bean r48e) and route ordering (refined in bean qvww), so we need a targeted merge approach. ## Approach Update the import tool to emit condition data, then merge it into existing seed files without touching route names or order. ## Checklist - [ ] Update `Encounter` model in `tools/import-pokedb/import_pokedb/models.py` to carry an optional `conditions: dict[str, int] | None` field - [ ] Update `extract_encounter_rate` in `processing.py` to return conditions alongside the flat rate (Gen 2/4 time-of-day, Gen 5 seasons, Gen 8 weather) - [ ] Update `aggregate_encounters` in `processing.py` to handle condition dicts (merge/sum per condition key) - [ ] Update `output.py` to emit `conditions` dict in seed JSON when present, with `encounter_rate` set to `null` - [ ] Write a merge script/mode that: - Runs the PokeDB processing for a game to get condition-aware encounters - Reads the **existing** seed JSON file (preserving route names, order, and structure) - For each encounter in the existing file, looks up the condition data from PokeDB - Adds the `conditions` dict where applicable, without changing anything else - Writes back to the same file - [ ] Run the merge for Gen 2/4 games: gold, silver, crystal, heartgold, soulsilver, diamond, pearl, platinum, brilliant-diamond, shining-pearl - [ ] Run the merge for Gen 5 games: black, white, black-2, white-2 - [ ] Run the merge for Gen 8 Sw/Sh: sword, shield - [ ] Verify seed loader handles all new condition data correctly (re-seed and spot check) - [ ] Remove the proof-of-concept manual conditions from heartgold.json Route 29 (replaced by real data) ## Affected games by condition type - **morning/day/night**: Gold, Silver, Crystal, HeartGold, SoulSilver, Diamond, Pearl, Platinum, Brilliant Diamond, Shining Pearl - **spring/summer/autumn/winter**: Black, White, Black 2, White 2 - **weather (clear, rain, thunderstorm, etc.)**: Sword, Shield - **No conditions (flat rates)**: Gen 1, Gen 3, Gen 6, Gen 7, Gen 9 — no changes needed ## Key files - `tools/import-pokedb/import_pokedb/processing.py` — `extract_encounter_rate()` currently flattens with `max()` - `tools/import-pokedb/import_pokedb/models.py` — `Encounter` dataclass - `tools/import-pokedb/import_pokedb/output.py` — seed JSON writer - `backend/src/app/seeds/loader.py` — already supports `conditions` dict expansion