Created
April 23, 2023 00:30
-
-
Save leo60228/06a46790ffead4c2fb848eafe0f82f59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {Dex} = require('@pkmn/dex'); | |
const {Generations} = require('@pkmn/data'); | |
const fs = require('fs'); | |
const nonT5File = fs.readFileSync('non_t5.txt').toString().split('\n'); | |
// These species are unobtainable outside of their own generations, but @pkmn/dex doesn't contain | |
// the artificial 'natDexTier' field which allows Pokémon Showdown to track this so we harcode it. | |
// If using @pkmn/sim instead, this list can be replaced with a `d.natDexTier !== 'Illegal'` check. | |
const NATDEX_UNOBTAINABLE_SPECIES = [ | |
'Eevee-Starter', 'Floette-Eternal', 'Pichu-Spiky-eared', 'Pikachu-Belle', 'Pikachu-Cosplay', | |
'Pikachu-Libre', 'Pikachu-PhD', 'Pikachu-Pop-Star', 'Pikachu-Rock-Star', 'Pikachu-Starter', | |
'Eternatus-Eternamax', | |
]; | |
const NATDEX_EXISTS = (d, g) => { | |
// The "National Dex" rules only apply to gen 8+, but this ExistsFn gets called on all generations | |
if (g < 8) return Generations.DEFAULT_EXISTS(d, g); | |
// These checks remain unchanged from the default existence filter | |
if (!d.exists) return false; | |
if (d.kind === 'Ability' && d.id === 'noability') return false; | |
// "National Dex" rules allows for data from the past, but not other forms of nonstandard-ness | |
if ('isNonstandard' in d && d.isNonstandard && d.isNonstandard !== 'Past' && d.isNonstandard !== 'Unobtainable') return false; | |
// Filter out the unobtainable species | |
if (d.kind === 'Species' && NATDEX_UNOBTAINABLE_SPECIES.includes(d.name)) return false; | |
// Nonstandard items other than Z-Crystals and Pokémon-specific items should be filtered | |
return !(d.kind === 'Item' && ['Past', 'Unobtainable'].includes(d.isNonstandard) && | |
!d.zMove && !d.itemUser && !d.forcedForme); | |
}; | |
const gens = new Generations(Dex, NATDEX_EXISTS); | |
const gen9 = gens.get(9); | |
let species = [...gen9.species]; | |
for (let x of nonT5File) { | |
x = x.trim(); | |
if (x === '') continue; | |
const y = gen9.species.get(x); | |
if (!y) throw new Error('couldn\'t get ' + x); | |
const index = species.indexOf(y); | |
if (index === -1) continue; | |
species.splice(index, 1); | |
if (!y.formes) continue; | |
for (const form of y.formes) { | |
const y = gen9.species.get(form); | |
if (!y) throw new Error('couldn\'t get ' + form); | |
const index = species.indexOf(y); | |
if (index === -1) { | |
continue; | |
} | |
species.splice(index, 1); | |
} | |
} | |
species.sort((a, b) => a.bst - b.bst); | |
for (let x of species) { | |
if (x.forme.endsWith('Gmax') || x.forme === 'Totem') continue; | |
console.log(x.name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment