Skip to content

Pokeapi better#132

Merged
Mygod merged 12 commits into
mainfrom
pokeapi-better
Apr 23, 2026
Merged

Pokeapi better#132
Mygod merged 12 commits into
mainfrom
pokeapi-better

Conversation

@Mygod
Copy link
Copy Markdown
Collaborator

@Mygod Mygod commented Apr 23, 2026

making PokeAPI fallback data behave correctly and consistently.

  • In src/classes/PokeApi.ts and src/classes/Pokemon.ts, the fallback merge now correctly handles Splash + Struggle placeholders. It keeps legal zero-power fast moves like SPLASH_FAST, inherits pre-evolution moves through the species chain, uses form-aware parent lookup for cases like Basculegion, and fetches placeholder-only mons even when GM stats/types already exist.
  • The charged-move fallback path was tightened. Placeholder and estimated fallback merges now filter out only RETURN and FRUSTRATION, and preserve an explicit “hidden-only charged fallback existed” state so cached fallback data can still drop placeholder STRUGGLE correctly without shipping those hidden moves in the wrong places.
  • Metadata handling is better. The branch preserves GM legendary/mythic flags when PokeAPI species metadata disagrees, fixes the cached-parent ordering issue in evoApi(), and updates src/typings/general.ts so evolves_from_species matches real nullable PokeAPI responses.

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.

Mygod added 12 commits April 22, 2026 17:15
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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 static baseStats.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.

Comment thread src/classes/PokeApi.ts
}

private isKnownMove(move?: number): move is number {
return !!move && !!this.moveReference?.[move]
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
return !!move && !!this.moveReference?.[move]
if (!move) {
return false
}
const moveSettings = this.moveReference?.[move]
return !!moveSettings && typeof moveSettings.power === 'number'

Copilot uses AI. Check for mistakes.
@Mygod Mygod merged commit 87f15ec into main Apr 23, 2026
5 checks passed
@Mygod Mygod deleted the pokeapi-better branch April 23, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants