diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index 66d00d950d2..adcf93f7adf 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -4813,7 +4813,7 @@ export class MoodyAbAttr extends PostTurnAbAttr { if (!simulated) { if (canRaise.length > 0) { const raisedStat = canRaise[pokemon.randBattleSeedInt(canRaise.length)]; - canLower = canRaise.filter(s => s !== raisedStat); + canLower = canLower.filter(s => s !== raisedStat); globalScene.phaseManager.unshiftNew("StatStageChangePhase", pokemon.getBattlerIndex(), true, [raisedStat], 2); } if (canLower.length > 0) { diff --git a/test/abilities/moody.test.ts b/test/abilities/moody.test.ts index d1f8aa2e351..b7882c15ced 100644 --- a/test/abilities/moody.test.ts +++ b/test/abilities/moody.test.ts @@ -84,4 +84,40 @@ describe("Abilities - Moody", () => { expect(decreasedStat).toBeTruthy(); expect(decreasedStat.length).toBe(1); }); + + it("should only try to increase a stat stage by 1 if the stat stage is not at 6", async () => { + await game.classicMode.startBattle(); + + const playerPokemon = game.field.getPlayerPokemon(); + + // Set all stat stages to 6 + vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(6)); + + // Set one of the stat stages to -6 + const raisedStat = EFFECTIVE_STATS[playerPokemon.randBattleSeedInt(EFFECTIVE_STATS.length)]; + playerPokemon.setStatStage(raisedStat, -6); + + game.move.select(MoveId.SPLASH); + await game.toNextTurn(); + + expect(playerPokemon.getStatStage(raisedStat), "should increase only the stat that is not at stage 6").toBe(-4); + }); + + it("should only try to decrease a stat stage by 1 if the stat stage is not at -6", async () => { + await game.classicMode.startBattle(); + + const playerPokemon = game.field.getPlayerPokemon(); + + // Set all stat stages to -6 + vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(-6)); + + // Set one of the stat stages to 6 + const raisedStat = EFFECTIVE_STATS[playerPokemon.randBattleSeedInt(EFFECTIVE_STATS.length)]; + playerPokemon.setStatStage(raisedStat, 6); + + game.move.select(MoveId.SPLASH); + await game.toNextTurn(); + + expect(playerPokemon.getStatStage(raisedStat), "should decrease only the stat that is not at stage -6").toBe(5); + }); });