smogon / pokemon-showdown

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

Refactor Gen 1/Stadium code to eliminate the `modifiedStats` table #5276

Open scheibo opened 5 years ago

scheibo commented 5 years ago

Can you also see if you can eliminate Gen 1's reliance on the modifiedStats table? It probably doesn't need to be separate from storedStats.

Originally posted by @Zarel in https://github.com/Zarel/Pokemon-Showdown/pull/5274#issuecomment-470981380

Marty-D commented 5 years ago

I'm not sure what the idea behind using modifiedStats was, but it seems like we'd still need to use more than one stat table just for Transformed Pokemon. Gen 1 Transform keeps the user's original stats somewhere, and copies the current modified stats of the target, and stores the original stats of the target for the purposes of calculating damage during a critical hit.

scheibo commented 5 years ago

I'm not sure what the idea behind using modifiedStats was, but it seems like we'd still need to use more than one stat table just for Transformed Pokemon.

We currently have baseStoredStats (user's original stats) and storedStats (where the transformed stats would be copied to).

and copies the current modified stats of the target

transformInto currently copies over volatiles and boosts to handle this, but I think this is where Gen 1 is weird (thanks to the Crystal_ discovery) and where the ordering of how boosts got applied relative to status forcing stat recalculation matters? And thus we need some way of tracking that, hence the current modifiedStats table?

and stores the original stats of the target for the purposes of calculating damage during a critical hit.

Do we do this today :S? It seems like we'd need another stats table for that.


From what you're saying, it seems we need at least 3 stats tables (user's original, target's modified + original), though I'm not sure the 3 we currently have cover everything.

Marty-D commented 5 years ago

Yes, I think baseStoredStats, storedStats, and a third table would be necessary just for Transform. The current modifiedStats can be rolled into storedStats safely.

I also think there's probably a bug with how Transform currently calculates stats but I haven't had time to look into it yet. https://www.smogon.com/forums/threads/gen-1-and-tradebacks-dev-post-bugs-here.3524844/page-14#post-8064239