-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ability][Checkup][Bug] Defeatist checkup + getHpRatio() precision im…
…proved (#450) * Wrote documentation for revised functions with new parameters / uses. * Fixed decimal value parameters * Wrote Defeatist test. * Beta Merge Part 2 * Readded fix to Potion generation. * Forgot about hyper potions * getHpRatio is now unrounded * Forgot to save a file before committing. * Apply suggestions from code review Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com> --------- Co-authored-by: frutescens <info@laptop> Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>
- Loading branch information
1 parent
e94599e
commit 4a73632
Showing
3 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Abilities } from "#enums/abilities"; | ||
import { MoveId } from "#enums/move-id"; | ||
import { Species } from "#enums/species"; | ||
import { GameManager } from "#test/testUtils/gameManager"; | ||
import Phaser from "phaser"; | ||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; | ||
import { Stat } from "#enums/stat"; | ||
|
||
describe("Abilities - Defeatist", () => { | ||
let phaserGame: Phaser.Game; | ||
let game: GameManager; | ||
|
||
beforeAll(() => { | ||
phaserGame = new Phaser.Game({ | ||
type: Phaser.HEADLESS, | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
game.phaseInterceptor.restoreOg(); | ||
}); | ||
|
||
beforeEach(() => { | ||
game = new GameManager(phaserGame); | ||
game.override | ||
.moveset([MoveId.SPLASH]) | ||
.ability(Abilities.DEFEATIST) | ||
.battleType("single") | ||
.disableCrits() | ||
.enemySpecies(Species.MAGIKARP) | ||
.enemyAbility(Abilities.BALL_FETCH) | ||
.enemyMoveset(MoveId.SPLASH); | ||
}); | ||
|
||
it.each([ | ||
{ statName: "attack", stat: Stat.ATK }, | ||
{ statName: "special attack", stat: Stat.SPATK }, | ||
])("should halve the user's $statName if the user's HP is at or below 50%", async ({ stat }) => { | ||
await game.classicMode.startBattle([Species.FEEBAS]); | ||
const playerPokemon = game.field.getPlayerPokemon(); | ||
const expectedStat = Math.floor(playerPokemon.getStat(stat as number) / 2); | ||
playerPokemon.hp = 1; | ||
const defeatistStat = playerPokemon.getEffectiveStat(stat as number); | ||
|
||
expect(playerPokemon.getHpRatio()).toBeLessThanOrEqual(0.5); | ||
expect(defeatistStat).toBe(expectedStat); | ||
}); | ||
|
||
it.each([ | ||
{ statName: "attack", stat: Stat.ATK }, | ||
{ statName: "special attack", stat: Stat.SPATK }, | ||
])("should have no effect on $statName if the user's HP is above 50%", async ({ stat }) => { | ||
await game.classicMode.startBattle([Species.FEEBAS]); | ||
const playerPokemon = game.field.getPlayerPokemon(); | ||
const expectedStat = playerPokemon.getStat(stat as number); | ||
const defeatistStat = playerPokemon.getEffectiveStat(stat as number); | ||
|
||
expect(playerPokemon.getHpRatio()).toBeGreaterThan(0.5); | ||
expect(defeatistStat).toBe(expectedStat); | ||
}); | ||
}); |