rrcampbell-exe / who-would-win

A cross-universe combat simulator for fans of Pokémon and Dungeons & Dragons.
https://rrcampbell-exe.github.io/who-would-win/
1 stars 0 forks source link

Pokémon Attack Power of Null #8

Closed rrcampbell-exe closed 3 years ago

rrcampbell-exe commented 3 years ago

Description

Currently, when a pokémon winds up with an attack power of null, pokémon choice function is run again from the very top. This causes a slowdown in the retrieval of pokémon data.

Possible Solutions

Un-nesting fetch calls to Poké API and making data available across functions would mean only the move needs to be chosen again, not the whole pokémon.

Prospective Future Issue

Using the solution above would create scenarios where pokémon with move power values of null for all moves end up in an endless loop, searching for a move with power associated with it. For example, Ditto only uses transform.

rrcampbell-exe commented 3 years ago

Issue Closed

Rather than asking if pokeInfo.pokeAttackPower was equal to null, I instead asked if data.power was true. If true, then pokeInfo.pokeAttackPower = data.power. If data.power was false, then rerun pokeMoveFetch(pokeInfo.pokeName).