Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/classes/Pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,13 +1016,31 @@ export default class Pokemon extends Masterfile {
const existingEvos = Array.isArray(existing.evolutions)
? existing.evolutions.map((evo) => ({ ...evo }))
: []
const resolveFormId = (value?: number | null): number | undefined =>
value !== undefined && value !== null
? value
: defaultFormId !== undefined
? defaultFormId
: undefined
const resolveFormKey = (value?: number | null): string => {
const resolveFormId = (
value?: number | string | null,
): number | undefined => {
// undefined / null -> fallback to defaultFormId if provided
if (value === undefined || value === null) {
return defaultFormId !== undefined ? defaultFormId : undefined
}
// If the value is a string proto (e.g. 'VIKAVOLT_WINTER_2025'),
// convert it to the numeric form id using the Rpc lookup.
if (typeof value === 'string') {
const numeric = Rpc.PokemonDisplayProto.Form[
value as FormProto
]
return numeric !== undefined
? numeric
: defaultFormId !== undefined
? defaultFormId
: undefined
}
Comment on lines +1028 to +1037
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

When a string formId is provided but cannot be found in Rpc.PokemonDisplayProto.Form, the function silently falls back to defaultFormId or undefined without any warning. This could mask data issues where an invalid or misspelled form proto name is provided. Consider logging a warning when the lookup fails to help with debugging data generation issues.

Copilot uses AI. Check for mistakes.
// number -> return as-is
return value
}
const resolveFormKey = (
value?: number | string | null,
): string => {
const resolved = resolveFormId(value)
return resolved !== undefined ? `${resolved}` : 'unset'
}
Expand Down