team_analysis
Analyze Pokémon team defensive synergies using type effectiveness data from PokeAPI to identify strengths and weaknesses in team composition.
Instructions
Sinergias defensivas del equipo (usa tipos de PokeAPI y tabla de tipos).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| team | Yes |
Implementation Reference
- src/index.ts:201-218 (handler)Handler function for 'team_analysis' tool: fetches types for each Pokemon in the team, computes defensive weaknesses, resistances, and immunities against all Pokemon types using type matchups.}, async (args:any) => { const team = args.team as { name:string }[]; const roster = await Promise.all(team.map(async m => { const core = await pokeapi.pokemonCore(m.name); return { name: core.name, types: core.types }; })); const allTypes = ['normal','fire','water','electric','grass','ice','fighting','poison','ground','flying','psychic','bug','rock','ghost','dragon','dark','steel','fairy']; const totals: Record<string,{weak:number,resist:number,immune:number}> = Object.fromEntries(allTypes.map(t => [t,{weak:0,resist:0,immune:0}])) as any; for (const r of roster) { for (const atk of allTypes) { const mult = await pokeapi.typeMultiplier(atk, r.types); if (mult === 0) totals[atk].immune++; else if (mult > 1) totals[atk].weak++; else if (mult < 1) totals[atk].resist++; } } return jsonContent({ roster, totals }); });
- src/index.ts:198-200 (schema)Input schema for the 'team_analysis' tool, requiring a 'team' array of objects each with a 'name' property (Pokemon names).type:'object', properties:{ team:{ type:'array', items:{ type:'object', properties:{ name:{type:'string'} }, required:['name'] }, minItems:1, maxItems:6 } }, required:['team']
- src/index.ts:197-218 (registration)Registration of the 'team_analysis' tool using registerTool, including inline schema and handler.registerTool('team_analysis', 'Sinergias defensivas del equipo (usa tipos de PokeAPI y tabla de tipos).', { type:'object', properties:{ team:{ type:'array', items:{ type:'object', properties:{ name:{type:'string'} }, required:['name'] }, minItems:1, maxItems:6 } }, required:['team'] }, async (args:any) => { const team = args.team as { name:string }[]; const roster = await Promise.all(team.map(async m => { const core = await pokeapi.pokemonCore(m.name); return { name: core.name, types: core.types }; })); const allTypes = ['normal','fire','water','electric','grass','ice','fighting','poison','ground','flying','psychic','bug','rock','ghost','dragon','dark','steel','fairy']; const totals: Record<string,{weak:number,resist:number,immune:number}> = Object.fromEntries(allTypes.map(t => [t,{weak:0,resist:0,immune:0}])) as any; for (const r of roster) { for (const atk of allTypes) { const mult = await pokeapi.typeMultiplier(atk, r.types); if (mult === 0) totals[atk].immune++; else if (mult > 1) totals[atk].weak++; else if (mult < 1) totals[atk].resist++; } } return jsonContent({ roster, totals }); });