[Bug] Fix off-by-one error in damage calc (#2970)

* Fix random damage roll to be 85-100% instead of 85-99%

* Update battle.test.ts to reflect the fix
This commit is contained in:
NightKev 2024-07-11 07:20:23 -07:00 committed by GitHub
parent 991051fa09
commit 6bc191c44e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -1909,7 +1909,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
applyPreAttackAbAttrs(AddSecondStrikeAbAttr, source, this, move, numTargets, new Utils.IntegerHolder(0), twoStrikeMultiplier);
if (!isTypeImmune) {
damage.value = Math.ceil(((((2 * source.level / 5 + 2) * power.value * sourceAtk.value / targetDef.value) / 50) + 2) * stabMultiplier.value * typeMultiplier.value * arenaAttackTypeMultiplier.value * screenMultiplier.value * twoStrikeMultiplier.value * ((this.scene.randBattleSeedInt(15) + 85) / 100) * criticalMultiplier.value);
damage.value = Math.ceil(
((((2 * source.level / 5 + 2) * power.value * sourceAtk.value / targetDef.value) / 50) + 2)
* stabMultiplier.value * typeMultiplier.value * arenaAttackTypeMultiplier.value * screenMultiplier.value * twoStrikeMultiplier.value * ((this.scene.randBattleSeedInt(16) + 85) / 100) * criticalMultiplier.value);
if (isPhysical && source.status && source.status.effect === StatusEffect.BURN) {
if (!move.hasAttr(BypassBurnDamageReductionAttr)) {
const burnDamageReductionCancelled = new Utils.BooleanHolder(false);

View File

@ -151,8 +151,8 @@ describe("Test Battle Phase", () => {
it("test remove random battle seed int", async() => {
for (let i=0; i<10; i++) {
const rand = game.scene.randBattleSeedInt(15);
expect(rand).toBe(14);
const rand = game.scene.randBattleSeedInt(16);
expect(rand).toBe(15);
}
});