diff --git a/src/phases/weather-effect-phase.ts b/src/phases/weather-effect-phase.ts index 73de44389d0..b48ee342780 100644 --- a/src/phases/weather-effect-phase.ts +++ b/src/phases/weather-effect-phase.ts @@ -44,7 +44,7 @@ export class WeatherEffectPhase extends CommonAnimPhase { return; } - const damage = Math.ceil(pokemon.getMaxHp() / 16); + const damage = Utils.toDmgValue(pokemon.getMaxHp() / 16); this.scene.queueMessage(getWeatherDamageMessage(this.weather?.weatherType!, pokemon)!); // TODO: are those bangs correct? pokemon.damageAndUpdate(damage, HitResult.EFFECTIVE, false, false, true); diff --git a/src/test/arena/weather_hail.test.ts b/src/test/arena/weather_hail.test.ts index 31d20be2ded..2070e40dbcc 100644 --- a/src/test/arena/weather_hail.test.ts +++ b/src/test/arena/weather_hail.test.ts @@ -39,7 +39,7 @@ describe("Weather - Hail", () => { await game.phaseInterceptor.to("TurnEndPhase"); game.scene.getField(true).forEach(pokemon => { - expect(pokemon.hp).toBeLessThan(pokemon.getMaxHp() - Math.floor(pokemon.getMaxHp() / 16)); + expect(pokemon.hp).toBe(pokemon.getMaxHp() - Math.max(Math.floor(pokemon.getMaxHp() / 16), 1)); }); }); @@ -56,6 +56,20 @@ describe("Weather - Hail", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp()); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp() - Math.floor(enemyPokemon.getMaxHp() / 16)); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - Math.max(Math.floor(enemyPokemon.getMaxHp() / 16), 1)); + }); + + it("does not inflict damage to Ice type Pokemon", async () => { + await game.classicMode.startBattle([Species.CLOYSTER]); + + game.move.select(Moves.SPLASH); + + await game.phaseInterceptor.to("TurnEndPhase"); + + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; + + expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp()); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - Math.max(Math.floor(enemyPokemon.getMaxHp() / 16), 1)); }); }); diff --git a/src/test/arena/weather_sandstorm.test.ts b/src/test/arena/weather_sandstorm.test.ts index 91188de6985..2419ca11b70 100644 --- a/src/test/arena/weather_sandstorm.test.ts +++ b/src/test/arena/weather_sandstorm.test.ts @@ -1,4 +1,6 @@ import { WeatherType } from "#app/data/weather"; +import { Abilities } from "#app/enums/abilities"; +import { Stat } from "#app/enums/stat"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; @@ -37,7 +39,7 @@ describe("Weather - Sandstorm", () => { await game.phaseInterceptor.to("TurnEndPhase"); game.scene.getField(true).forEach(pokemon => { - expect(pokemon.hp).toBeLessThan(pokemon.getMaxHp() - Math.floor(pokemon.getMaxHp() / 16)); + expect(pokemon.hp).toBe(pokemon.getMaxHp() - Math.max(Math.floor(pokemon.getMaxHp() / 16), 1)); }); }); @@ -53,6 +55,37 @@ describe("Weather - Sandstorm", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp()); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp() - Math.floor(enemyPokemon.getMaxHp() / 16)); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - Math.max(Math.floor(enemyPokemon.getMaxHp() / 16), 1)); + }); + + it("does not inflict damage to Rock, Ground and Steel type Pokemon", async () => { + game.override + .battleType("double") + .enemySpecies(Species.SANDSHREW) + .ability(Abilities.BALL_FETCH) + .enemyAbility(Abilities.BALL_FETCH); + + await game.classicMode.startBattle([Species.ROCKRUFF, Species.KLINK]); + + game.move.select(Moves.SPLASH, 0); + game.move.select(Moves.SPLASH, 1); + + await game.phaseInterceptor.to("TurnEndPhase"); + + game.scene.getField(true).forEach(pokemon => { + expect(pokemon.hp).toBe(pokemon.getMaxHp()); + }); + }); + + it("increases Rock type Pokemon Sp.Def by 50%", async () => { + await game.classicMode.startBattle([Species.ROCKRUFF]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + const playerSpdef = playerPokemon.getStat(Stat.SPDEF); + expect(playerPokemon.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(playerSpdef * 1.5)); + + const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemySpdef = enemyPokemon.getStat(Stat.SPDEF); + expect(enemyPokemon.getEffectiveStat(Stat.SPDEF)).toBe(enemySpdef); }); });