Skip to content

Commit

Permalink
fix: sometimes moves are already numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Aug 31, 2023
1 parent 2bd27aa commit 1e15b8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pogo-data-generator",
"version": "1.16.2",
"version": "1.16.3",
"description": "Pokemon GO project data generator",
"author": "TurtIeSocks",
"license": "Apache-2.0",
Expand Down
36 changes: 18 additions & 18 deletions src/classes/Pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,34 +190,34 @@ export default class Pokemon extends Masterfile {
}
}

getMoves(moves: string[]): number[] {
getMoves(moves: (string | number)[]): number[] {
if (!moves) return []
try {
try {
return moves
.map((move) => Rpc.HoloPokemonMove[move as MoveProto])
.sort((a, b) => a - b)
} catch (e) {
console.warn(e, '\n', moves)
}
return moves
.map((move) =>
typeof move === 'string'
? Rpc.HoloPokemonMove[move as MoveProto]
: move,
)
.sort((a, b) => a - b)
} catch (e) {
console.warn(e, `Failed to lookup moves for ${moves}`)
}
}

getTypes(incomingTypes: string[]): number[] {
getTypes(incomingTypes: (string | number)[]): number[] {
if (!incomingTypes) return []
try {
try {
if (!incomingTypes[1]) {
incomingTypes.pop()
}
return incomingTypes
.map((type) => Rpc.HoloPokemonType[type as TypeProto])
.sort((a, b) => a - b)
} catch (e) {
console.warn(e, '\n', incomingTypes)
if (!incomingTypes[1]) {
incomingTypes.pop()
}
return incomingTypes
.map((type) =>
typeof type === 'string'
? Rpc.HoloPokemonType[type as TypeProto]
: type,
)
.sort((a, b) => a - b)
} catch (e) {
console.warn(e, `Failed to lookup types for ${incomingTypes}`)
}
Expand Down

0 comments on commit 1e15b8f

Please sign in to comment.