smogon / damage-calc

Pokemon games damage calculator
https://calc.pokemonshowdown.com
MIT License
391 stars 367 forks source link

Stealth Rock and Spikes issue #303

Closed Zarel closed 5 years ago

Zarel commented 5 years ago

https://twitter.com/LarsHabermann1/status/1120796616393396225

Your damage calc is broken. It isn't calculating with stealth rocks or spikes anymore.

Told you something would break, @AustinXII

AustinXII commented 5 years ago

@Zarel already fixed and updated on the main calc (thanks TI). Tbf this was apparently broken for weeks and no one complained somehow, even after I got people who play constantly to test with it 🤦‍♂️. This actually broke with my refactor because of a forgotten “!” and not because of the recent changes that got uploaded

AustinXII commented 5 years ago

Oh it’s because I’m remembering wrong, I guess my refactor did get pushed after the toggle abilities. I just assumed it was at the same-ish time since I asked you to update after I did the refactor but I guess you didn’t and did it by yourself a few days before, whoops.

AustinXII commented 5 years ago

It might be an annoyance but I may start adding versions on the calc page so I know how caught up main is. It would make pinpointing what actually broke something a lot easier since the calc can go months without a sync

neilfewellsteiner commented 4 years ago

I've noticed that damage from hazards and leech seed are not included in the damage rolls. How do you obtain this information using the @smogon/calc API? I wrote a test case to show what I mean:


var calc = require("@smogon/calc"); 
var assert = require("assert");
// Example Sets
var Kyurem = new calc.Pokemon(8, 'Kyurem', {
        level: 100,
        ability: 'Pressure',
        item: 'Choice Specs',
        nature: 'Timid', 
        evs: {spa: 252, def: 4, spe: 252},
        moves: ['Ice Beam', 'Freeze Dry', 'Earth Power', 'Draco Meteor'] 
    });   
var Excadrill = new calc.Pokemon(8, 'Excadrill', {
        level: 100,
        ability: 'Mold Breaker',
        item: 'Leftovers',
        nature: 'Careful', 
        evs: {hp: 252, spd: 252, atk: 4},
        moves: ['Iron Head', 'Rapid Spin', 'Stealth Rock', 'Earthquake'] 
    });
// Result with Stealth Rock
var resultSR = calc.calculate(8, Excadrill, Kyurem, 
new calc.Move(8, 'Earthquake'), 
new calc.Field({defenderSide: {isSR: true}}));
// Result without Stealth Rock
var resultNoSR = calc.calculate(8, Excadrill, Kyurem, 
new calc.Move(8, 'Earthquake'));
// Assert each damage roll in Stealth Rock result
// is different from the damage roll in hazardless result
for(var i = 0; i < resultSR.damage.length; i++) {
    assert(resultSR.damage[i] != resultNoSR.damage[i]);
}
scheibo commented 4 years ago

Hi @neilfewellsteiner - love that you wrote a test, super helpful!

Stealth Rock damage is not (and should not) be included in the damage roll, it occurs when the mon switches in and is separate from the damage caused by the move, Currently the calculator accounts for the SR damage from switching in while calculating OHKO chance, which is not programmatically available in a machine readable way with the current package (it is included in the desc of the Result)

neilfewellsteiner commented 4 years ago

Hello @scheibo , thank you for the quick reply. I did not realize that each result object has a desc() method, which provides information about hazards, leech seed, and other field effects.