diff --git a/scripts/build-snapshot.mjs b/scripts/build-snapshot.mjs index 743dec2..6645359 100644 --- a/scripts/build-snapshot.mjs +++ b/scripts/build-snapshot.mjs @@ -192,9 +192,8 @@ async function main() { }; }; const bstOf = (st) => st.hp + st.atk + st.def + st.spa + st.spd + st.spe; - const sameShape = (a, b) => - a.types.join() === b.types.join() && a.bst === b.bst && - a.stats.hp === b.stats.hp && a.stats.spe === b.stats.spe && a.stats.atk === b.stats.atk; + const abilKey = (pk) => pk.abilities.map((a) => a.ability.name).sort().join(','); + const statKey = (st) => `${st.hp}/${st.atk}/${st.def}/${st.spa}/${st.spd}/${st.spe}`; console.log(`Fetching ${ids.length} species (stats, typings, flags, forms) …`); const species = await mapLimit(ids, CONCURRENCY, async (id) => { @@ -204,6 +203,8 @@ async function main() { ]); const stats = statMap(pk); const baseTypes = pk.types.slice().sort((a, b) => a.slot - b.slot).map((t) => t.type.name); + const baseAbil = abilKey(pk); + const baseStatKey = statKey(stats); // Non-default varieties = forms (megas, G-max, regional, alt formes). const variantSlugs = (sp.varieties || []) @@ -231,10 +232,14 @@ async function main() { height: fp.height, weight: fp.weight, }; - // Drop purely-cosmetic forms (identical stats & typing, no named category). - if (cat === 'other' && sameShape(entry, { types: baseTypes, bst: bstOf(stats), stats })) { - continue; - } + // Drop purely-cosmetic forms: same typing, stats AND abilities as the + // base, and not a named category (mega/gmax/regional/primal). + const cosmetic = + cat === 'other' && + ftypes.join() === baseTypes.join() && + statKey(fstats) === baseStatKey && + abilKey(fp) === baseAbil; + if (cosmetic) continue; forms.push(entry); }