Apply suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
Mumble 2024-10-07 08:32:17 -07:00 committed by GitHub
parent 3c5323526d
commit 89b3580847
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
import { BattlerTagType } from "#app/enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -36,19 +36,18 @@ describe("Moves - Telekinesis", () => {
it("Telekinesis makes the affected vulnerable to most attacking moves regardless of accuracy", async () => { it("Telekinesis makes the affected vulnerable to most attacking moves regardless of accuracy", async () => {
await game.classicMode.startBattle([ Species.MAGIKARP ]); await game.classicMode.startBattle([ Species.MAGIKARP ]);
const enemyOpponent = game.scene.getEnemyPokemon(); const enemyOpponent = game.scene.getEnemyPokemon()!;
expect(enemyOpponent).toBeDefined();
game.move.select(Moves.TELEKINESIS); game.move.select(Moves.TELEKINESIS);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.getTag(BattlerTagType.TELEKINESIS)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.TELEKINESIS)).toBeDefined();
expect(enemyOpponent?.getTag(BattlerTagType.FLOATING)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.FLOATING)).toBeDefined();
await game.toNextTurn(); await game.toNextTurn();
vi.spyOn(allMoves[Moves.TACKLE], "accuracy", "get").mockReturnValue(0); vi.spyOn(allMoves[Moves.TACKLE], "accuracy", "get").mockReturnValue(0);
game.move.select(Moves.TACKLE); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.hp).toBeLessThan(enemyOpponent?.getMaxHp()!); expect(enemyOpponent.isFullHp()).toBe(false);
}); });
it("Telekinesis makes the affected airborne and immune to most Ground-moves", async () => { it("Telekinesis makes the affected airborne and immune to most Ground-moves", async () => {
@ -59,72 +58,68 @@ describe("Moves - Telekinesis", () => {
game.move.select(Moves.TELEKINESIS); game.move.select(Moves.TELEKINESIS);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.getTag(BattlerTagType.TELEKINESIS)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.TELEKINESIS)).toBeDefined();
expect(enemyOpponent?.getTag(BattlerTagType.FLOATING)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.FLOATING)).toBeDefined();
await game.toNextTurn(); await game.toNextTurn();
vi.spyOn(allMoves[Moves.MUD_SHOT], "accuracy", "get").mockReturnValue(100); vi.spyOn(allMoves[Moves.MUD_SHOT], "accuracy", "get").mockReturnValue(100);
game.move.select(Moves.MUD_SHOT); game.move.select(Moves.MUD_SHOT);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.hp).toEqual(enemyOpponent?.getMaxHp()!); expect(enemyOpponent.isFullHp()).toBe(true);
}); });
it("Telekinesis can still affect Pokemon that have been transformed into invalid Pokemon", async () => { it("Telekinesis can still affect Pokemon that have been transformed into invalid Pokemon", async () => {
game.override.enemyMoveset(Moves.TRANSFORM); game.override.enemyMoveset(Moves.TRANSFORM);
await game.classicMode.startBattle([ Species.DIGLETT ]); await game.classicMode.startBattle([ Species.DIGLETT ]);
const enemyOpponent = game.scene.getEnemyPokemon(); const enemyOpponent = game.scene.getEnemyPokemon()!;
expect(enemyOpponent).toBeDefined();
game.move.select(Moves.TELEKINESIS); game.move.select(Moves.TELEKINESIS);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.getTag(BattlerTagType.TELEKINESIS)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.TELEKINESIS)).toBeDefined();
expect(enemyOpponent?.getTag(BattlerTagType.FLOATING)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.FLOATING)).toBeDefined();
expect(enemyOpponent?.summonData.speciesForm?.speciesId).toBe(Species.DIGLETT); expect(enemyOpponent.summonData.speciesForm?.speciesId).toBe(Species.DIGLETT);
}); });
it("Moves like Smack Down and 1000 Arrows remove all effects of Telekinesis from the target Pokemon", async () => { it("Moves like Smack Down and 1000 Arrows remove all effects of Telekinesis from the target Pokemon", async () => {
await game.classicMode.startBattle([ Species.MAGIKARP ]); await game.classicMode.startBattle([ Species.MAGIKARP ]);
const enemyOpponent = game.scene.getEnemyPokemon(); const enemyOpponent = game.scene.getEnemyPokemon()!;
expect(enemyOpponent).toBeDefined();
game.move.select(Moves.TELEKINESIS); game.move.select(Moves.TELEKINESIS);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.getTag(BattlerTagType.TELEKINESIS)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.TELEKINESIS)).toBeDefined();
expect(enemyOpponent?.getTag(BattlerTagType.FLOATING)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.FLOATING)).toBeDefined();
await game.toNextTurn(); await game.toNextTurn();
game.move.select(Moves.SMACK_DOWN); game.move.select(Moves.SMACK_DOWN);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.getTag(BattlerTagType.TELEKINESIS)).toBeUndefined(); expect(enemyOpponent.getTag(BattlerTagType.TELEKINESIS)).toBeUndefined();
expect(enemyOpponent?.getTag(BattlerTagType.FLOATING)).toBeUndefined(); expect(enemyOpponent.getTag(BattlerTagType.FLOATING)).toBeUndefined();
}); });
it("Ingrain will remove the floating effect of Telekinesis, but not the 100% hit", async () => { it("Ingrain will remove the floating effect of Telekinesis, but not the 100% hit", async () => {
game.override.enemyMoveset([ Moves.SPLASH, Moves.INGRAIN ]); game.override.enemyMoveset([ Moves.SPLASH, Moves.INGRAIN ]);
await game.classicMode.startBattle([ Species.MAGIKARP ]); await game.classicMode.startBattle([ Species.MAGIKARP ]);
const playerPokemon = game.scene.getPlayerPokemon(); const playerPokemon = game.scene.getPlayerPokemon()!;
const enemyOpponent = game.scene.getEnemyPokemon(); const enemyOpponent = game.scene.getEnemyPokemon()!;
expect(enemyOpponent).toBeDefined();
game.move.select(Moves.TELEKINESIS); game.move.select(Moves.TELEKINESIS);
await game.forceEnemyMove(Moves.SPLASH); await game.forceEnemyMove(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.getTag(BattlerTagType.TELEKINESIS)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.TELEKINESIS)).toBeDefined();
expect(enemyOpponent?.getTag(BattlerTagType.FLOATING)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.FLOATING)).toBeDefined();
await game.toNextTurn(); await game.toNextTurn();
vi.spyOn(allMoves[Moves.MUD_SHOT], "accuracy", "get").mockReturnValue(0); vi.spyOn(allMoves[Moves.MUD_SHOT], "accuracy", "get").mockReturnValue(0);
game.move.select(Moves.MUD_SHOT); game.move.select(Moves.MUD_SHOT);
await game.forceEnemyMove(Moves.INGRAIN); await game.forceEnemyMove(Moves.INGRAIN);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyOpponent?.getTag(BattlerTagType.TELEKINESIS)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.TELEKINESIS)).toBeDefined();
expect(enemyOpponent?.getTag(BattlerTagType.INGRAIN)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.INGRAIN)).toBeDefined();
expect(enemyOpponent?.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); expect(enemyOpponent.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined();
expect(enemyOpponent?.getTag(BattlerTagType.FLOATING)).toBeUndefined(); expect(enemyOpponent.getTag(BattlerTagType.FLOATING)).toBeUndefined();
const lastMoveResult = playerPokemon?.getLastXMoves()[0].result; expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
expect(lastMoveResult).toBe(MoveResult.SUCCESS);
}); });
}); });