calc_stats
Calculate final Pokémon stats based on level, IVs, EVs, and nature to optimize battle performance and team building.
Instructions
Cálculo de stats finales (nivel, IVs, EVs, naturaleza).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| evs | No | ||
| ivs | No | ||
| level | No | ||
| name | Yes | ||
| nature | No | serious |
Implementation Reference
- src/index.ts:102-122 (handler)Core handler logic for calc_stats tool: computes final Pokémon stats based on base stats from PokeAPI, IVs, EVs, level, and nature multipliers.const core = await pokeapi.pokemonCore(String(args.name)); const level = Number(args.level || 50); const ivs = Object.assign({hp:31,atk:31,def:31,spa:31,spd:31,spe:31}, args.ivs || {}); const evs = Object.assign({hp:0,atk:0,def:0,spa:0,spd:0,spe:0}, args.evs || {}); const nature = String(args.nature || 'serious'); const bs:any = core.base_stats; const stat=(base:number,iv:number,ev:number, mult:number, isHP=false)=>{ if (isHP) return Math.floor(((2*base + iv + Math.floor(ev/4))*level)/100)+level+10; const val = Math.floor(((2*base + iv + Math.floor(ev/4))*level)/100)+5; return Math.floor(val * mult); }; return jsonContent({ name: core.name, level, nature, stats: { hp: stat(bs.hp,ivs.hp,evs.hp,1,true), atk: stat(bs.atk,ivs.atk,evs.atk,natureMultiplier(nature,'atk')), def: stat(bs.def,ivs.def,evs.def,natureMultiplier(nature,'def')), spa: stat(bs.spa,ivs.spa,evs.spa,natureMultiplier(nature,'spa')), spd: stat(bs.spd,ivs.spd,evs.spd,natureMultiplier(nature,'spd')), spe: stat(bs.spe,ivs.spe,evs.spe,natureMultiplier(nature,'spe')) } });
- src/index.ts:94-100 (schema)Input schema defining parameters for calc_stats: pokemon name (required), level, IVs, EVs, nature.type:'object', properties:{ name:{type:'string'}, level:{type:'integer', default:50}, ivs:{type:'object', default:{}, additionalProperties:{ type:'integer' }}, evs:{type:'object', default:{}, additionalProperties:{ type:'integer' }}, nature:{type:'string', default:'serious'} }, required:['name']
- src/index.ts:93-123 (registration)Registration of the calc_stats tool using registerTool, including schema and inline handler.registerTool('calc_stats', 'Cálculo de stats finales (nivel, IVs, EVs, naturaleza).', { type:'object', properties:{ name:{type:'string'}, level:{type:'integer', default:50}, ivs:{type:'object', default:{}, additionalProperties:{ type:'integer' }}, evs:{type:'object', default:{}, additionalProperties:{ type:'integer' }}, nature:{type:'string', default:'serious'} }, required:['name'] }, async (args:any) => { const core = await pokeapi.pokemonCore(String(args.name)); const level = Number(args.level || 50); const ivs = Object.assign({hp:31,atk:31,def:31,spa:31,spd:31,spe:31}, args.ivs || {}); const evs = Object.assign({hp:0,atk:0,def:0,spa:0,spd:0,spe:0}, args.evs || {}); const nature = String(args.nature || 'serious'); const bs:any = core.base_stats; const stat=(base:number,iv:number,ev:number, mult:number, isHP=false)=>{ if (isHP) return Math.floor(((2*base + iv + Math.floor(ev/4))*level)/100)+level+10; const val = Math.floor(((2*base + iv + Math.floor(ev/4))*level)/100)+5; return Math.floor(val * mult); }; return jsonContent({ name: core.name, level, nature, stats: { hp: stat(bs.hp,ivs.hp,evs.hp,1,true), atk: stat(bs.atk,ivs.atk,evs.atk,natureMultiplier(nature,'atk')), def: stat(bs.def,ivs.def,evs.def,natureMultiplier(nature,'def')), spa: stat(bs.spa,ivs.spa,evs.spa,natureMultiplier(nature,'spa')), spd: stat(bs.spd,ivs.spd,evs.spd,natureMultiplier(nature,'spd')), spe: stat(bs.spe,ivs.spe,evs.spe,natureMultiplier(nature,'spe')) } }); });
- src/stats.ts:17-23 (helper)Helper function natureMultiplier that provides the 1.1/0.9/1.0 multiplier for stats based on Pokémon nature, used in calc_stats handler.export function natureMultiplier(nature: Nature | string, stat: 'atk'|'def'|'spa'|'spd'|'spe'): number { const n = String(nature).toLowerCase(); const mod = natureMods[n] || {}; if (mod.up === stat) return 1.1; if (mod.down === stat) return 0.9; return 1.0; }