[P2] Make weather damage round down for consistency (#4559)

* fmake weather damage consistent with the rest of the game

* [test] add  some sandstorm and hail tests
This commit is contained in:
MokaStitcher 2024-10-03 16:33:12 +02:00 committed by GitHub
parent f634b7c044
commit 831efeb6bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 52 additions and 5 deletions

View File

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

View File

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

View File

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