mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 08:22:22 +02:00
Add Mega Evolution Field
This commit is contained in:
@@ -37,6 +37,7 @@ module.exports = class Pokemon {
|
||||
return {
|
||||
id: variety.pokemon.name,
|
||||
name: name || null,
|
||||
mega: data.missingno ? false : null,
|
||||
default: variety.is_default,
|
||||
types: data.missingno ? variety.types : [],
|
||||
abilities: data.missingno ? variety.abilities : []
|
||||
@@ -82,6 +83,11 @@ module.exports = class Pokemon {
|
||||
return 'standard';
|
||||
}
|
||||
|
||||
get mega() {
|
||||
if (!this.gameDataCached) return null;
|
||||
return this.varieties.filter(variety => variety.mega);
|
||||
}
|
||||
|
||||
get displayID() {
|
||||
if (this.missingno) return '???';
|
||||
return this.id.toString().padStart(3, '0');
|
||||
@@ -140,7 +146,9 @@ module.exports = class Pokemon {
|
||||
for (const variety of this.varieties) {
|
||||
if (variety.id === defaultVariety.id) continue;
|
||||
const { body } = await request.get(`https://pokeapi.co/api/v2/pokemon/${variety.id}`);
|
||||
const { body: formBody } = await request.get(`https://pokeapi.co/api/v2/pokemon-form/${variety.id}`);
|
||||
variety.types.push(...body.types.map(type => firstUpperCase(type.type.name)));
|
||||
variety.mega = formBody.is_mega || false;
|
||||
for (const ability of body.abilities) {
|
||||
const { body: abilityBody } = await request.get(ability.ability.url);
|
||||
variety.abilities.push(abilityBody.names.find(name => name.language.name === 'en').name);
|
||||
|
||||
Reference in New Issue
Block a user