smogon / pokemon-showdown

Pokémon battle simulator.
https://pokemonshowdown.com
MIT License
4.67k stars 2.72k forks source link

Bug: getting ID of species.battleOnly when it's an array #10291

Open andrebastosdias opened 2 months ago

andrebastosdias commented 2 months ago

https://github.com/smogon/pokemon-showdown/blob/9ec7c4a3fde49e3a2a4c5d09e690aa38059aff9e/sim/dex-species.ts#L464-L467

I created a mod where I set isNonstandard = "Past" for all Zygarde forms. However, I didn't manually set tier, doublesTier, and natDexTier to Illegal. When Zygarde-Complete attempts to derive the tiers from its base forms, it converts the array ["Zygarde", "Zygarde-10%"] into an ID. Consequently, it ends up trying to fetch the tier of an undefined element, causing a crash.

I'm unsure if this is the only part of the code affected, but it seems somewhat inefficient to have to set the tiers of all non-standard to Illegal just to avoid this bug (although this currently only impacts Zygarde-Complete and Necrozma-Ultra). Setting the tiers to Illegal avoids entering this part of the code.