diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 26dd9eb94cf..f826093348b 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -1774,7 +1774,7 @@ export class PokemonExpBoosterModifier extends PokemonHeldItemModifier { } apply(args: any[]): boolean { - (args[1] as Utils.NumberHolder).value = Math.floor((args[1] as Utils.NumberHolder).value * (1 + (this.getStackCount() * this.boostMultiplier))); + (args[1] as Utils.NumberHolder).value += (this.getStackCount() * this.boostMultiplier); return true; } diff --git a/src/phases.ts b/src/phases.ts index b1b64015393..0bbef602d17 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -3927,7 +3927,9 @@ export class VictoryPhase extends PokemonPhase { expMultiplier = Overrides.XP_MULTIPLIER_OVERRIDE; } const pokemonExp = new Utils.NumberHolder(expValue * expMultiplier); - this.scene.applyModifiers(PokemonExpBoosterModifier, true, partyMember, pokemonExp); + const modifierBonusExp = new Utils.NumberHolder(1); + this.scene.applyModifiers(PokemonExpBoosterModifier, true, partyMember, modifierBonusExp); + pokemonExp.value *= modifierBonusExp.value; partyMemberExp.push(Math.floor(pokemonExp.value)); } diff --git a/src/test/items/exp_booster.test.ts b/src/test/items/exp_booster.test.ts new file mode 100644 index 00000000000..c2d357056d0 --- /dev/null +++ b/src/test/items/exp_booster.test.ts @@ -0,0 +1,40 @@ +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import Phase from "phaser"; +import GameManager from "#app/test/utils/gameManager"; +import overrides from "#app/overrides"; +import { Abilities } from "#app/enums/abilities.js"; +import { PokemonExpBoosterModifier } from "#app/modifier/modifier.js"; +import * as Utils from "#app/utils"; + +describe("EXP Modifier Items", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phase.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + + vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.BALL_FETCH); + vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.BALL_FETCH); + vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true); + }); + + it("EXP booster items stack additively", async() => { + vi.spyOn(overrides, "STARTING_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "LUCKY_EGG"}, {name: "GOLDEN_EGG"}]); + await game.startBattle(); + + const partyMember = game.scene.getPlayerPokemon(); + const modifierBonusExp = new Utils.NumberHolder(1); + partyMember.scene.applyModifiers(PokemonExpBoosterModifier, true, partyMember, modifierBonusExp); + expect(modifierBonusExp.value).toBe(2.4); + }, 20000); +});