From a259ccfc34fbca7b9fdc7dc9f5eee5172791b091 Mon Sep 17 00:00:00 2001 From: AJ Fontaine <36677462+Fontbane@users.noreply.github.com> Date: Sun, 6 Oct 2024 23:29:57 -0400 Subject: [PATCH 1/2] [Beta][Test] Fix Scale Shot flaky test (#4564) Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> --- src/test/moves/scale_shot.test.ts | 57 ++++++++++++++++++------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/test/moves/scale_shot.test.ts b/src/test/moves/scale_shot.test.ts index 2730d05306d..e4d768fa13a 100644 --- a/src/test/moves/scale_shot.test.ts +++ b/src/test/moves/scale_shot.test.ts @@ -1,3 +1,5 @@ +import { BattlerIndex } from "#app/battle"; +import { allMoves } from "#app/data/move"; import { DamagePhase } from "#app/phases/damage-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEndPhase } from "#app/phases/move-end-phase"; @@ -8,7 +10,7 @@ import { Species } from "#enums/species"; import { Stat } from "#enums/stat"; import GameManager from "#test/utils/gameManager"; 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", () => { let phaserGame: Phaser.Game; @@ -30,45 +32,54 @@ describe("Moves - Scale Shot", () => { .moveset([ Moves.SCALE_SHOT ]) .battleType("single") .disableCrits() - .starterSpecies(Species.MINCCINO) .ability(Abilities.NO_GUARD) .passiveAbility(Abilities.SKILL_LINK) - .enemyAbility(Abilities.SHEER_FORCE) - .enemyPassiveAbility(Abilities.STALL) - .enemyMoveset(Moves.SKILL_SWAP) - .enemyLevel(5); + .enemyMoveset(Moves.SPLASH) + .enemyLevel(3); }); it("applies stat changes after last hit", async () => { - await game.classicMode.startBattle([ Species.FORRETRESS ]); + game.override.enemySpecies(Species.FORRETRESS); + + await game.classicMode.startBattle([ Species.MINCCINO ]); const minccino = game.scene.getPlayerPokemon()!; game.move.select(Moves.SCALE_SHOT); + + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(DamagePhase); + + //check that stats haven't changed after one or two hits have occurred await game.phaseInterceptor.to(MoveEffectPhase); - expect (minccino?.getStatStage(Stat.DEF)).toBe(0); - expect (minccino?.getStatStage(Stat.SPD)).toBe(0); + expect(minccino.getStatStage(Stat.DEF)).toBe(0); + expect(minccino.getStatStage(Stat.SPD)).toBe(0); + + //check that stats changed on last hit await game.phaseInterceptor.to(MoveEndPhase); - expect (minccino.getStatStage(Stat.DEF)).toBe(-1); - expect (minccino.getStatStage(Stat.SPD)).toBe(1); + expect(minccino.getStatStage(Stat.DEF)).toBe(-1); + expect(minccino.getStatStage(Stat.SPD)).toBe(1); }); it("unaffected by sheer force", async () => { - await game.classicMode.startBattle([ Species.WOBBUFFET ]); + const moveToCheck = allMoves[Moves.SCALE_SHOT]; + const basePower = moveToCheck.power; + + game.override.enemySpecies(Species.WOBBUFFET); + + vi.spyOn(moveToCheck, "calculateBattlePower"); + + await game.classicMode.startBattle([ Species.MINCCINO ]); 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); await game.phaseInterceptor.to(TurnEndPhase); - const hpafter1 = wobbuffet.hp; + //effect not nullified by sheer force - expect (minccino.getStatStage(Stat.DEF)).toBe(-1); - expect (minccino.getStatStage(Stat.SPD)).toBe(1); - game.move.select(Moves.SCALE_SHOT); - await game.phaseInterceptor.to(MoveEndPhase); - const hpafter2 = wobbuffet.hp; - //check damage not boosted- make damage before sheer force a little lower than theoretical boosted sheer force damage - expect (100 - hpafter1).toBe(hpafter1 - hpafter2); + expect(minccino.getStatStage(Stat.DEF)).toBe(-1); + expect(minccino.getStatStage(Stat.SPD)).toBe(1); + + //power not boosted by sheer force + expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); }); }); From f5fa478eb8afbfda7f7468e6fc535abe7fd1e03c Mon Sep 17 00:00:00 2001 From: Acelynn Zhang <102631387+acelynnzhang@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:01:15 -0500 Subject: [PATCH 2/2] [P1] Fix crash when starting a challenge run after revisiting challenge select screen (#4603) Ensure EncounterPhase initializes correctly at the start of the game after revisting the challenge selection screen. Fixes #4520 --- src/ui/starter-select-ui-handler.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 98a563301e4..9623d78c51e 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -46,6 +46,7 @@ import { StarterContainer } from "#app/ui/starter-container"; import { DropDownColumn, FilterBar } from "#app/ui/filter-bar"; import { ScrollBar } from "#app/ui/scroll-bar"; import { SelectChallengePhase } from "#app/phases/select-challenge-phase"; +import { EncounterPhase } from "#app/phases/encounter-phase"; import { TitlePhase } from "#app/phases/title-phase"; import { Abilities } from "#enums/abilities"; import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters"; @@ -3468,6 +3469,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.scene.clearPhaseQueue(); if (this.scene.gameMode.isChallenge) { this.scene.pushPhase(new SelectChallengePhase(this.scene)); + this.scene.pushPhase(new EncounterPhase(this.scene, false)); } else { this.scene.pushPhase(new TitlePhase(this.scene)); }