Make EXP boosting items stack additively and not multiplicatively (#3094)

Fixes #2040
This commit is contained in:
NightKev 2024-07-22 07:47:56 -07:00 committed by GitHub
parent cc6b424813
commit ecbf7570b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 2 deletions

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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);
});