Browse Source

- Updates to work with the new structure

pull/1/head
Dan 1 year ago
parent
commit
37b0944769
  1. 31
      src/server.ts

31
src/server.ts

@ -176,24 +176,17 @@ app.get('/api/pokemon/:pfic/details', async (req, res) => {
const { pfic } = req.params;
const details = await db.get(`
SELECT pf.name, pf.form_name, pf.national_dex, pf.generation,
ps.storable_in_home, pf.is_baby_form
FROM pokemon_forms pf
LEFT JOIN pokemon_storage ps ON pf.PFIC = ps.PFIC
WHERE pf.PFIC = ?
SELECT *
FROM pokemon_forms
WHERE PFIC = ?
`, pfic);
const encounters = await db.all(`
SELECT g.name as game_name, e.location, e.day, e.time,
e.dual_slot, e.static_encounter_count, e.static_encounter,
e.extra_text, e.stars, e.rods, e.fishing
FROM encounters e
JOIN games g ON e.game_id = g.id
WHERE e.pfic = ?
ORDER BY g.name, e.location
`, pfic);
res.json({ ...details, encounters });
const data = JSON.parse(details.data)
const pokemon = {
"pfic": details.PFIC,
"data": data
}
res.json(pokemon);
} catch (err) {
console.error('Error fetching pokemon details:', err);
res.status(500).json({ error: 'Internal server error' });
@ -204,7 +197,7 @@ app.get('/api/plan', authenticateToken, async (req: AuthRequest, res: Response)
try {
// Read the efficiency plan file
const planData = await fs.readFile(
path.join(__dirname, '../efficiency_plan.json'),
path.join(__dirname, '../plan.json'),
'utf-8'
);
const efficiencyPlan = JSON.parse(planData);
@ -265,8 +258,9 @@ app.get('/api/plan', authenticateToken, async (req: AuthRequest, res: Response)
const debug_pfic = "0010-01-000-0";
// Enhance the plan with evolution methods and account for caught Pokemon
/*
for (const game of efficiencyPlan) {
for (const pokemon of game.pokemon) {
for (const pokemon of game.pokemon.keys()) {
// Set initial catch count
pokemon.catch_count = 1;
if (pokemon.pfic === debug_pfic) {
@ -308,6 +302,7 @@ app.get('/api/plan', authenticateToken, async (req: AuthRequest, res: Response)
}
}
}
*/
await db.close();
res.json(efficiencyPlan);

Loading…
Cancel
Save