Future-proof pokedex-moveset for Sword/Shield

This commit is contained in:
Dragon Fire
2020-12-09 21:17:02 -05:00
parent ba7b1d9468
commit 622fb39f98
4 changed files with 9 additions and 3 deletions
+1
View File
@@ -86,6 +86,7 @@
"level": 1
}
],
"moveSetVersion": "red-blue",
"chain": [0],
"missingno": true,
"sprite": "https://cdn.bulbagarden.net/upload/9/98/Missingno_RB.png",
+3 -1
View File
@@ -2,7 +2,8 @@ const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const versions = {
'red-blue': 'Red and Blue',
'ultra-sun-ultra-moon': 'Ultra Sun and Ultra Moon'
'ultra-sun-ultra-moon': 'Ultra Sun and Ultra Moon',
'sword-shield': 'Sword and Shield'
};
module.exports = class PokedexMovesetCommand extends Command {
@@ -56,6 +57,7 @@ module.exports = class PokedexMovesetCommand extends Command {
const data = await this.client.pokemon.fetch(pokemon);
if (!data) return msg.say('Could not find any results.');
if (!data.gameDataCached) await data.fetchGameData();
if (!data.moveSet.length) return msg.say('This Pokémon\'s moves are not yet documented.');
const embed = new MessageEmbed()
.setColor(0xED1C24)
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "123.4.0",
"version": "123.4.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
+4 -1
View File
@@ -48,7 +48,7 @@ module.exports = class Pokemon {
this.height = data.missingno ? data.height : null;
this.weight = data.missingno ? data.weight : null;
this.moveSet = data.missingno ? data.moveSet : [];
this.moveSetVersion = data.missingno ? 'red-blue' : 'ultra-sun-ultra-moon';
this.moveSetVersion = data.missingno ? data.moveSetVersion : null;
this.gameDataCached = data.missingno || false;
this.missingno = data.missingno || false;
this.cry = data.id > store.pokemonCountWithCry
@@ -111,6 +111,9 @@ module.exports = class Pokemon {
sDef: defaultBody.stats.find(stat => stat.stat.name === 'special-defense').base_stat,
spd: defaultBody.stats.find(stat => stat.stat.name === 'speed').base_stat
};
const inSwordShield = defaultBody.moves
.some(move => move.version_group_details.some(mve => mve.version_group.name === 'sword-shield'));
this.moveSetVersion = inSwordShield ? 'sword-shield' : 'ultra-sun-ultra-moon';
for (const move of defaultBody.moves) {
const versionGroup = move.version_group_details.find(mve => mve.version_group.name === this.moveSetVersion);
if (!versionGroup || !versionGroup.level_learned_at) continue;