LegendaryPKMN/ivcalc

Hidden Power calculation using only IV input

Closed this issue · 2 comments

If you load a fresh version of the calculator (whether by going to the page for the first time or refreshing the page) and input a set of IVs, check the "Lock Median" option, and click "Calculate Hidden Power", the calculation never finishes, with the status display showing only "Calculating Hidden Power..."

If you follow the same steps with the GenIII-V calculator, the calculation does finish and you get Hidden Power's type and power for those IVs.

The calculation finishes on the modern (XY) calculator only if the IVs were generated by inputting a Pokémon's stat values.

After doing some tests, I believe the problem is caused by p.sortnum(); on line 915, a remnant of the pre-GenVI code for calculating Hidden Power's base power. When the function display_hp() is called at line 927, p is undefined, causing p.sortnum(); in display_hp() to fail and as a result display_hp() never completes. However, when display_hp() is called at line 962, p is defined (on line 931), allowing display_hp() to complete.

I've found two potential fixes:

  • Uncommenting line 926, giving p a value of [60]
  • p.sortnum(); could be commented out in display_hp() since the value of p is no longer used
Arty2 commented

@Snowysauce Thank you for the bug hunting! Do you think you could submit a pull request for that one?

I submitted a pull request as requested. I chose to make the second fix and comment out p.sortnum(); on line 915.