Pokeapi better#132
Conversation
Resolve inherited move parents through the species struct and keep the Basculegion overrides so form-restricted chains still inherit the right pre-evolution moves. This intentionally omits the transient-error fallback behavior from the old 27d321d batch.
When replacing GM Splash/Struggle placeholders with PokeAPI data, only keep fallback charged moves that already exist in the normal GM charged-move pool. That prevents Rest, Return, Frustration, and similar hidden or special-case moves from leaking into standard learnsets.
If a placeholder replacement has charged fallback data but all of it is filtered out as hidden or special-case, remove the placeholder charged slot instead of leaving Struggle behind.
Filter only the hidden or special-case charged moves that should not be published as standard learnset entries: Rest, Return, and Frustration. This keeps valid GO estimates like Last Resort or Chilling Water while still stripping the placeholder-leak cases.
Use the same hidden-move filtering for ordinary charged fallback merges as for the Splash/Struggle replacement path. That keeps fully estimated species from exposing Rest, Return, or Frustration in generated standard learnsets.
Keep GM legendary and mythic classifications when PokeAPI fallback data is enriching an existing species, and refresh the shipped fallback snapshot for paradox legendaries to match.
Keep hidden-only charged moves in live PokeAPI fallback data, but strip them from the serialized baseStats cache while preserving an explicit marker for placeholder merge logic. This replaces the old sanitize/cache/error-handling sequence with one durable cache-boundary fix.
Keep only Return and Frustration in the fallback charged-move exclusion policy so Rest is preserved in both live and cached PokeAPI fallback data. Refresh the placeholder-move regressions and static baseStats snapshot to match the narrower rule.
There was a problem hiding this comment.
Pull request overview
This PR improves how the codebase consumes PokeAPI-derived fallback data, with a focus on correctly handling placeholder move sets (Splash/Struggle), move inheritance across evolutions (including form-aware cases), and consistent handling of “hidden-only” charged fallback moves in live vs cached data.
Changes:
- Updated PokeAPI ingestion to support inherited move chains, placeholder detection, and better caching (pokemon + species).
- Tightened placeholder/fallback merge logic in
Pokemon.parsePokeApi()and introduced a cache-sanitization step for staticbaseStats.json. - Expanded regression coverage with a comprehensive placeholder-move test suite and regenerated
static/baseStats.json.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/pokemonPlaceholderMoves.test.js | Adds regression tests for placeholder replacement, hidden-only filtering, inheritance, and rarity flag preservation. |
| static/baseStats.json | Regenerated cached fallback base stats/moves to reflect the corrected logic. |
| src/typings/general.ts | Aligns Species API typing with PokeAPI’s nullable/optional evolves_from_species. |
| src/typings/dataTypes.ts | Adds _hiddenOnlyChargedMoves sentinel to support correct cache semantics. |
| src/classes/Pokemon.ts | Refines fallback merge logic to correctly handle placeholders and hidden-only charged fallbacks. |
| src/classes/PokeApi.ts | Adds caching, inheritance resolution, placeholder fetch behavior, and cache sanitization helper. |
| devWrapper.ts | Ensures serialized static/baseStats.json is sanitized before writing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| private isKnownMove(move?: number): move is number { | ||
| return !!move && !!this.moveReference?.[move] |
There was a problem hiding this comment.
isKnownMove currently treats any move present in moveReference as valid, even if it only exists because protoMoves() ran and therefore has no power/settings data. That can cause PokeAPI-derived move lists to include moves that aren't actually in the GM move settings. Consider changing the predicate to require a defined numeric power (while still allowing 0) so zero-power moves like SPLASH_FAST are kept but proto-only/unknown moves are excluded.
| return !!move && !!this.moveReference?.[move] | |
| if (!move) { | |
| return false | |
| } | |
| const moveSettings = this.moveReference?.[move] | |
| return !!moveSettings && typeof moveSettings.power === 'number' |
making PokeAPI fallback data behave correctly and consistently.
On the data side, devWrapper.ts now sanitizes fallback baseStats at serialization time, and static/baseStats.json was regenerated to include the corrected fallback entries for species like Magikarp, Cosmog/Cosmoem, Magearna, Basculegion, and the paradox placeholders. tests/pokemonPlaceholderMoves.test.js also grew into a large regression suite covering zero-power moves, pre-evo inheritance, placeholder replacement, cache serialization, form-aware inheritance, and GM rarity preservation.