|
|
|
@ -308,6 +308,7 @@ interface PokemonFamilyEntry { |
|
|
|
family_pfic?: string; |
|
|
|
representative: string; |
|
|
|
catch_count: number; |
|
|
|
caught_count: number; |
|
|
|
evolve_to: string[]; |
|
|
|
breed_for: string[]; |
|
|
|
Any?: number; |
|
|
|
@ -342,6 +343,13 @@ app.get('/api/plan', authenticateToken, async (req: AuthRequest, res: Response) |
|
|
|
); |
|
|
|
const efficiencyPlan: GamePlan[] = JSON.parse(planData); |
|
|
|
|
|
|
|
const userDb = await userDbPromise; |
|
|
|
const caughtPokemon = await userDb.all( |
|
|
|
'SELECT pfic FROM caught_pokemon WHERE user_id = ?', |
|
|
|
[req.user.id] |
|
|
|
); |
|
|
|
const caughtPfics = new Set(caughtPokemon.map(p => p.pfic)); |
|
|
|
|
|
|
|
// Loop through each game plan
|
|
|
|
for (let i = 0; i < efficiencyPlan.length; i++) { |
|
|
|
const game_plan = efficiencyPlan[i]; |
|
|
|
@ -349,6 +357,7 @@ app.get('/api/plan', authenticateToken, async (req: AuthRequest, res: Response) |
|
|
|
if (Object.hasOwnProperty.call(game_plan.pokemon, key)) { |
|
|
|
const pokemonFamily: PokemonFamilyEntry = game_plan.pokemon[key]; |
|
|
|
pokemonFamily.family_pfic = key; |
|
|
|
pokemonFamily.caught_count = 0; |
|
|
|
|
|
|
|
// Merge evolve_to into pfics array
|
|
|
|
const pfics: string[] = pokemonFamily.evolve_to; |
|
|
|
@ -385,6 +394,10 @@ app.get('/api/plan', authenticateToken, async (req: AuthRequest, res: Response) |
|
|
|
|
|
|
|
pokemonFamily.evolve_to_augmented.push(entry); |
|
|
|
|
|
|
|
if (caughtPfics.has(pkmn)) { |
|
|
|
pokemonFamily.caught_count += 1; |
|
|
|
} |
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
console.error(`Error fetching details for PFIC ${pkmn}:`, err); |
|
|
|
} |
|
|
|
@ -423,6 +436,10 @@ app.get('/api/plan', authenticateToken, async (req: AuthRequest, res: Response) |
|
|
|
|
|
|
|
pokemonFamily.breed_for_augmented.push(entry); |
|
|
|
|
|
|
|
if (caughtPfics.has(pkmn)) { |
|
|
|
pokemonFamily.caught_count += 1; |
|
|
|
} |
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
console.error(`Error fetching details for PFIC ${pkmn}:`, err); |
|
|
|
} |
|
|
|
|