Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"maxSize": 10485760,
"includes": [
"**",
"!!**/dist"
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"apk": "ts-node devWrapper.ts --test --apk",
"test": "tsc && ./node_modules/.bin/jest",
"format": "biome format --write ./src/**/*.ts",
"publishBuild": "rm -r dist && tsc"
"publishBuild": "rm -r dist && tsc",
"deps:update": "yarn upgrade pogo-masterfile-types @na-ji/pogo-protos"
},
"repository": {
"type": "git",
Expand All @@ -53,10 +54,11 @@
"node": ">=21.0.0"
},
"devDependencies": {
"@biomejs/biome": "2.3.9",
"@biomejs/biome": "2.4.14",
"@types/node": "^24",
"jest": "^30.2.0",
"pogo-masterfile-types": "<1.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
"typescript": "^6.0.3"
}
}
10 changes: 4 additions & 6 deletions src/classes/Item.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rpc } from '@na-ji/pogo-protos'
import type { ItemSettings } from 'pogo-masterfile-types'
import type { AllItems } from '../typings/dataTypes'
import type { NiaMfObj } from '../typings/general'
import type { Options } from '../typings/inputs'
import { Rpc } from '@na-ji/pogo-protos'
import type { ItemProto } from '../typings/protos'
import Masterfile from './Masterfile'

Expand Down Expand Up @@ -34,12 +34,10 @@ export default class Item extends Masterfile {
this.parsedItems = {}
}

addItem(object: NiaMfObj) {
addItem(object: ItemSettings['data']) {
try {
const {
data: {
itemSettings: { itemId, itemType, category, dropTrainerLevel },
},
itemSettings: { itemId, itemType, category, dropTrainerLevel },
templateId,
} = object
if (
Expand Down
7 changes: 3 additions & 4 deletions src/classes/LocationCards.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rpc } from '@na-ji/pogo-protos'
import type { LocationCardSettings } from 'pogo-masterfile-types'
import type { AllLocationCards } from '../typings/dataTypes'
import type { NiaMfObj } from '../typings/general'
import type { Options } from '../typings/inputs'
import type { LocationCardProto } from '../typings/protos'
import Masterfile from './Masterfile'
Expand Down Expand Up @@ -30,9 +30,8 @@ export default class LocationCards extends Masterfile {
this.parsedLocationCards = {}
}

addLocationCard(object: NiaMfObj) {
const { templateId, data } = object
const { locationCardSettings } = data
addLocationCard(object: LocationCardSettings['data']) {
const { templateId, locationCardSettings } = object
if (!locationCardSettings) {
return
}
Expand Down
9 changes: 4 additions & 5 deletions src/classes/Masterfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ export default class Masterfile {
...translationOptions.prefix,
}
if (!translationOptions.questTitleTermsToSkip) {
merged.translations.options.questTitleTermsToSkip =
[...base.translations.options.questTitleTermsToSkip]
merged.translations.options.questTitleTermsToSkip = [
...base.translations.options.questTitleTermsToSkip,
]
}
}
})
Expand Down Expand Up @@ -209,9 +210,7 @@ export default class Masterfile {
// checks which fields are in the template and if the data is an object, loops through again
let returnedObj: any = {}
const ref =
x && typeof x === 'object'
? x
: reference[fieldKey]?.[x] ?? x
x && typeof x === 'object' ? x : (reference[fieldKey]?.[x] ?? x)
if (ref === undefined || ref === null || typeof ref !== 'object') {
return ref
}
Expand Down
16 changes: 5 additions & 11 deletions src/classes/Move.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rpc } from '@na-ji/pogo-protos'
import type { CombatMove, MoveSettings } from 'pogo-masterfile-types'
import type { AllMoves } from '../typings/dataTypes'
import type { NiaMfObj } from '../typings/general'
import type { MoveProto, TypeProto } from '../typings/protos'
import Masterfile from './Masterfile'

Expand All @@ -26,11 +26,8 @@ export default class Moves extends Masterfile {
})
}

addMoveSettings(object: NiaMfObj) {
const {
templateId,
data: { moveSettings },
} = object
addMoveSettings(object: MoveSettings['data']) {
const { templateId, moveSettings } = object
try {
const isMax = templateId.startsWith('VN_BM_')
const proto = isMax ? templateId : templateId.substring(11)
Expand Down Expand Up @@ -59,11 +56,8 @@ export default class Moves extends Masterfile {
}
}

addCombatMove(object: NiaMfObj) {
const {
templateId,
data: { combatMove },
} = object
addCombatMove(object: CombatMove['data']) {
const { templateId, combatMove } = object
try {
const id: number =
Rpc.HoloPokemonMove[templateId.substring(18) as MoveProto]
Expand Down
30 changes: 20 additions & 10 deletions src/classes/PokeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export default class PokeApi extends Masterfile {
[id: string]: { attack?: number; defense?: number; stamina?: number }
}
moveReference: AllMoves
private pokemonStatsCache: { [id: string]: Promise<PokeApiStats> | PokeApiStats }
private pokemonStatsCache: {
[id: string]: Promise<PokeApiStats> | PokeApiStats
}
private speciesCache: { [id: string]: Promise<SpeciesApi> | SpeciesApi }
private inheritedMoveParentOverrides: { [id: string]: string }
private apiBaseUrl: string
Expand Down Expand Up @@ -155,7 +157,9 @@ export default class PokeApi extends Masterfile {

private shouldFetchPlaceholderMoves(pokemon?: SinglePokemon) {
return (
this.hasExactMoves(pokemon?.quickMoves, [Rpc.HoloPokemonMove.SPLASH_FAST]) &&
this.hasExactMoves(pokemon?.quickMoves, [
Rpc.HoloPokemonMove.SPLASH_FAST,
]) &&
this.hasExactMoves(pokemon?.chargedMoves, [Rpc.HoloPokemonMove.STRUGGLE])
)
}
Expand Down Expand Up @@ -200,7 +204,9 @@ export default class PokeApi extends Masterfile {
.sort((a, b) => a - b)
}

private resolveStructId(struct?: BasePokeApiStruct | null): number | undefined {
private resolveStructId(
struct?: BasePokeApiStruct | null,
): number | undefined {
if (!struct) {
return undefined
}
Expand All @@ -218,9 +224,9 @@ export default class PokeApi extends Masterfile {
private async fetchPokemonStats(id: string | number): Promise<PokeApiStats> {
const cacheKey = `${id}`
if (!this.pokemonStatsCache[cacheKey]) {
this.pokemonStatsCache[cacheKey] = (this.fetch(
this.buildUrl(`pokemon/${id}`),
) as Promise<PokeApiStats>).catch((error) => {
this.pokemonStatsCache[cacheKey] = (
this.fetch(this.buildUrl(`pokemon/${id}`)) as Promise<PokeApiStats>
).catch((error) => {
delete this.pokemonStatsCache[cacheKey]
throw error
})
Expand All @@ -233,9 +239,11 @@ export default class PokeApi extends Masterfile {
private async fetchSpecies(id: string | number): Promise<SpeciesApi> {
const cacheKey = `${id}`
if (!this.speciesCache[cacheKey]) {
this.speciesCache[cacheKey] = (this.fetch(
this.buildUrl(`pokemon-species/${id}`),
) as Promise<SpeciesApi>).catch((error) => {
this.speciesCache[cacheKey] = (
this.fetch(
this.buildUrl(`pokemon-species/${id}`),
) as Promise<SpeciesApi>
).catch((error) => {
delete this.speciesCache[cacheKey]
throw error
})
Expand Down Expand Up @@ -504,7 +512,9 @@ export default class PokeApi extends Masterfile {
parsedPokemon[id]?.mythic ?? evoData.is_mythical
}
if (evoData.evolves_from_species) {
const prevEvoId = this.resolveStructId(evoData.evolves_from_species)
const prevEvoId = this.resolveStructId(
evoData.evolves_from_species,
)
if (prevEvoId) {
if (!this.baseStats[prevEvoId]) {
this.baseStats[prevEvoId] = {}
Expand Down
Loading
Loading