doshidak / showdex

Pokémon Showdown extension that harnesses the power of parabolic calculus to strategically extract your opponents' Elo.
GNU Affero General Public License v3.0
104 stars 18 forks source link

Eviolite isn't accounted for in the damage calculations themselves #61

Closed doshidak closed 1 year ago

doshidak commented 1 year ago

Reported by:

NFE (Not Fully Evolved) Pokémon holding an Eviolite, which applies a 50% boost to both DEF and SPD, doesn't seem to be accounted for in the damage calculations.

doshidak commented 1 year ago

Fixed in commit f8d2e7c.

In the gen78 mechanics file of @smogon/calc, there's a re-lookup of the Pokémon's species:

if ((defender.hasItem('Eviolite') && gen.species.get(toID(defender.name))?.nfe) ||
      (!hitsPhysical && defender.hasItem('Assault Vest'))) {

Specifically, the re-lookup occurs when gen.species.get(toID(defender.name))?.nfe is checked.

Since v1.0.3, the Generation object from @pkmn/data and @pkmn/dex has been completely replaced with Showdown's global Dex object. This object does not contain the nfe property in the species data Dex.species.get() returns, hence the aforementioned check fails, preventing Eviolite from applying.

The fix was to override the Dex.species.get() object that the Pokemon constructor from @smogon/calc receives and populate the nfe field of the expected Specie object using the pre-existing notFullyEvolved() utility.

This override does not affect the global Dex object by design and re-overrides each time the "Generation" object is returned by getGenDexForFormat(). (In quotes since this utility is more of a polyfill for the expected Generation object based off Showdown's global Dex object.)