forked from pagefaultgames/pokerogue
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Stop random trainers from spawning near fixed battles (page…
…faultgames#2610) * Stop trainer spawns on evil team and E4 floors * Thanks Xavion * change "floors" to "wave" in coment * at test for not spawning 3 waves within fixed trainer battle * remove out-commented code * apply code formatting * Updated test and make sure isWaveTrainer returns a boolean * Update comment --------- Co-authored-by: Felix Staud <[email protected]>
- Loading branch information
1 parent
0d9dd1d
commit f932768
Showing
3 changed files
with
73 additions
and
2 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,52 @@ | ||
import { GameMode, GameModes, getGameMode } from "#app/game-mode.js"; | ||
import { | ||
afterEach, | ||
beforeAll, | ||
beforeEach, | ||
describe, | ||
expect, | ||
it, | ||
vi, | ||
} from "vitest"; | ||
import GameManager from "./utils/gameManager"; | ||
import * as Utils from "../utils"; | ||
describe("game-mode", () => { | ||
let phaserGame: Phaser.Game; | ||
let game: GameManager; | ||
beforeAll(() => { | ||
phaserGame = new Phaser.Game({ | ||
type: Phaser.HEADLESS, | ||
}); | ||
}); | ||
afterEach(() => { | ||
game.phaseInterceptor.restoreOg(); | ||
vi.resetAllMocks(); | ||
}); | ||
beforeEach(() => { | ||
game = new GameManager(phaserGame); | ||
}); | ||
describe("classic", () => { | ||
let classicGameMode: GameMode; | ||
beforeEach(() => { | ||
classicGameMode = getGameMode(GameModes.CLASSIC); | ||
}); | ||
it("does NOT spawn trainers within 3 waves of fixed battle", () => { | ||
const { arena } = game.scene; | ||
/** set wave 16 to be a fixed trainer fight meaning wave 13-19 don't allow trainer spawns */ | ||
vi.spyOn(classicGameMode, "isFixedBattle").mockImplementation( | ||
(n: number) => (n === 16 ? true : false) | ||
); | ||
vi.spyOn(arena, "getTrainerChance").mockReturnValue(1); | ||
vi.spyOn(Utils, "randSeedInt").mockReturnValue(0); | ||
expect(classicGameMode.isWaveTrainer(11, arena)).toBeFalsy(); | ||
expect(classicGameMode.isWaveTrainer(12, arena)).toBeTruthy(); | ||
expect(classicGameMode.isWaveTrainer(13, arena)).toBeFalsy(); | ||
expect(classicGameMode.isWaveTrainer(14, arena)).toBeFalsy(); | ||
expect(classicGameMode.isWaveTrainer(15, arena)).toBeFalsy(); | ||
// Wave 16 is a fixed trainer battle | ||
expect(classicGameMode.isWaveTrainer(17, arena)).toBeFalsy(); | ||
expect(classicGameMode.isWaveTrainer(18, arena)).toBeFalsy(); | ||
expect(classicGameMode.isWaveTrainer(19, arena)).toBeFalsy(); | ||
}); | ||
}); | ||
}); |