Integrate suggested changes

This commit is contained in:
AJ Fontaine 2024-10-04 11:38:01 -04:00
parent 237b3e28fc
commit 29710cf7e6

View File

@ -1,3 +1,5 @@
import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamagePhase } from "#app/phases/damage-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase"; import { MoveEndPhase } from "#app/phases/move-end-phase";
@ -8,7 +10,7 @@ import { Species } from "#enums/species";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest";
describe("Moves - Scale Shot", () => { describe("Moves - Scale Shot", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -30,47 +32,54 @@ describe("Moves - Scale Shot", () => {
.moveset([Moves.SCALE_SHOT]) .moveset([Moves.SCALE_SHOT])
.battleType("single") .battleType("single")
.disableCrits() .disableCrits()
.starterSpecies(Species.MINCCINO)
.ability(Abilities.NO_GUARD) .ability(Abilities.NO_GUARD)
.passiveAbility(Abilities.SKILL_LINK) .passiveAbility(Abilities.SKILL_LINK)
.enemyAbility(Abilities.SHEER_FORCE) .enemyMoveset(Moves.SPLASH)
.enemyPassiveAbility(Abilities.STALL)
.enemyMoveset(Moves.SKILL_SWAP)
.enemyLevel(3); .enemyLevel(3);
}); });
it("applies stat changes after last hit", async () => { it("applies stat changes after last hit", async () => {
game.override.enemySpecies(Species.FORRETRESS); game.override.enemySpecies(Species.FORRETRESS);
await game.classicMode.startBattle();
await game.classicMode.startBattle([Species.MINCCINO]);
const minccino = game.scene.getPlayerPokemon()!; const minccino = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SCALE_SHOT); game.move.select(Moves.SCALE_SHOT);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
//check that stats haven't changed after one or two hits have occurred
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect (minccino?.getStatStage(Stat.DEF)).toBe(0); expect(minccino.getStatStage(Stat.DEF)).toBe(0);
expect (minccino?.getStatStage(Stat.SPD)).toBe(0); expect(minccino.getStatStage(Stat.SPD)).toBe(0);
//check that stats changed on last hit
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect (minccino.getStatStage(Stat.DEF)).toBe(-1); expect(minccino.getStatStage(Stat.DEF)).toBe(-1);
expect (minccino.getStatStage(Stat.SPD)).toBe(1); expect(minccino.getStatStage(Stat.SPD)).toBe(1);
}); });
it("unaffected by sheer force", async () => { it("unaffected by sheer force", async () => {
const moveToCheck = allMoves[Moves.SCALE_SHOT];
const basePower = moveToCheck.power;
game.override.enemySpecies(Species.WOBBUFFET); game.override.enemySpecies(Species.WOBBUFFET);
await game.classicMode.startBattle();
vi.spyOn(moveToCheck, "calculateBattlePower");
await game.classicMode.startBattle([Species.MINCCINO]);
const minccino = game.scene.getPlayerPokemon()!; const minccino = game.scene.getPlayerPokemon()!;
const wobbuffet = game.scene.getEnemyPokemon()!;
wobbuffet.setStat(Stat.HP, 100, true);
wobbuffet.hp = 100;
game.move.select(Moves.SCALE_SHOT); game.move.select(Moves.SCALE_SHOT);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const hpafter1 = wobbuffet.hp;
//effect not nullified by sheer force //effect not nullified by sheer force
expect (minccino.getStatStage(Stat.DEF)).toBe(-1); expect(minccino.getStatStage(Stat.DEF)).toBe(-1);
expect (minccino.getStatStage(Stat.SPD)).toBe(1); expect(minccino.getStatStage(Stat.SPD)).toBe(1);
game.move.select(Moves.SCALE_SHOT);
await game.phaseInterceptor.to(MoveEndPhase); //power not boosted by sheer force
const hpafter2 = wobbuffet.hp; expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower);
//check damage not boosted- make damage before sheer force a little lower than theoretical boosted sheer force damage
expect (100 - hpafter1).toBe(hpafter1 - hpafter2);
}); });
}); });