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

Apply active hazards to switched out pokemon before running damage calc #127

Closed Fubs closed 1 year ago

Fubs commented 1 year ago

I think it would be useful to have a toggle-able option to make the damage calc take into account hazards damage.

For example, this test case from @smogon/calc prints: 0 SpA Abomasnow Helping Hand Blizzard vs. 32 HP / 0 SpD Hoopa-Unbound through Light Screen with an ally\'s Friend Guard: 50-59 (16.1 - 19%) -- 91.4% chance to 3HKO after Stealth Rock, 1 layer of Spikes, hail damage, Leech Seed damage, and Grassy Terrain recovery

From this issue on the @smogon/calc package, it looks like this information is available but only in the description string of calculate(). So this would probably require parsing out the "91.4%" and "3HKO" from that description string.

doshidak commented 1 year ago

yooo it's fubwubs! Nice to see you here c:

Hmmmmm, hazards damage should be applying in the KO% (but not DMG) if you've selected a Pokémon that's switched out in the calc, unless it's not working again LOL. (Also noticed in your example that it's doubles, so could be broken for doubles only, maybe?)

I'm using the n & chance values from the output object of result.kochance() (result being the object returned from calculate()) to format the KO% values that users see. Unless I'm tripping balls, what I'm understanding is that the n & chance values don't include hazards damage, right? :o

In other words, say there are Stealth Rocks on my side and one of my switched-out Pokémon will be OHKO'd by one of my opponent's moves with Stealth Rocks, but 2HKO'd without. I'm assuming the calc currently says "2HKO" here for the KO%, not accounting for Stealth Rocks. If that's the case, that shouldn't happen, so I'll definitely be looking into that.

Funny enough, the values from the DMG column in the calc are derived from the string in your example (which is the output of result.desc()). The @smogon/calc API doesn't expose the percentages either, so I extract them from the description hehe.

But anyways, just brainstorming here a bit before I dig into the weeds lol. I should check if hazards are working properly anyways. Thanks for your great detective work!

Fubs commented 1 year ago

I just re-tested this and the KO% actually does work correctly as you described. (case i tested was: stealth rock up, specs charizard using overheat showed 53.8-63.6% dmg and OHKO vs a 100% hp switched-out charizard)

Seems that this is working fine. Thanks for clarifying