mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-20 16:42:45 +02:00
* Grabbed reverted changes from stuff
* Added version migrator for rage fist data + deepMergeSpriteData tests
* fixed formattign
* Fied a few
* Fixed constructor (maybe), moved deepCopy and deepMergeSpriteData to own file
`common.ts` is hella bloated so seems legit
* Moved empty moveset verification mapping thing to upgrade script bc i wanted to
* Fixed tests
* test added
* Fixed summondata being cleared inside summonPhase, removed `summonDataPrimer`
like seriously how come no-one checked this
* Fixed test
I forgot that we outsped and oneshot
* Fixed test
* huhjjjjjb
* Hopefully fixed bug
my sanity and homework are paying the price for this lol
* added commented out console.log statement
uncomment to see new berry data
* Fixed migrate script, re-added deprecated attributes out of necessity
* Fixed failing test by not trying to mock rng
* Fixed test
* Fixed tests
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update overrides.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update berry-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update encounter-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update game-data.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Added utility function `randSeedFloat`
basically just `Phaser.math.RND.realInRange(0, 1)`
* Applied review comments, cleaned up code a bit
* Removed unnecessary null checks for turnData and co.
I explicitly made them initialized by default for this very reason
* Added tests for Last Resort regarding moveHistory
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update battle-scene.ts
Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
* Update the-winstrate-challenge-encounter.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update battle-anims.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts comments
* Fixed a few outstanding issues with documentation
* Updated switch summon phase comment
* Re-added BattleSummonData as TempSummonData
* Hppefully fixed -1 sprite scale glitch
* Fixed comment
* Reveted `pokemon-forms.ts`
* Fuxed constructor
* fixed -1 bug
* Revert "Added utility function `randSeedFloat`"
This reverts commit 4c3447c851
.
---------
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
167 lines
5.7 KiB
TypeScript
167 lines
5.7 KiB
TypeScript
import { BattlerIndex } from "#app/battle";
|
|
import { MoveResult } from "#app/field/pokemon";
|
|
import { Abilities } from "#enums/abilities";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
describe("Moves - Last Resort", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
function expectLastResortFail() {
|
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0]).toEqual(
|
|
expect.objectContaining({
|
|
move: Moves.LAST_RESORT,
|
|
result: MoveResult.FAIL,
|
|
}),
|
|
);
|
|
}
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
game.override
|
|
.ability(Abilities.BALL_FETCH)
|
|
.battleStyle("single")
|
|
.disableCrits()
|
|
.enemySpecies(Species.MAGIKARP)
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
.enemyMoveset(Moves.SPLASH);
|
|
});
|
|
|
|
it("should fail unless all other moves (excluding itself) has been used at least once", async () => {
|
|
game.override.moveset([Moves.LAST_RESORT, Moves.SPLASH, Moves.GROWL, Moves.GROWTH]);
|
|
await game.classicMode.startBattle([Species.BLISSEY]);
|
|
|
|
const blissey = game.scene.getPlayerPokemon()!;
|
|
expect(blissey).toBeDefined();
|
|
|
|
// Last resort by itself
|
|
game.move.select(Moves.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expectLastResortFail();
|
|
|
|
// Splash (1/3)
|
|
blissey.pushMoveHistory({ move: Moves.SPLASH, targets: [BattlerIndex.PLAYER] });
|
|
game.move.select(Moves.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expectLastResortFail();
|
|
|
|
// Growl (2/3)
|
|
blissey.pushMoveHistory({ move: Moves.GROWL, targets: [BattlerIndex.ENEMY] });
|
|
game.move.select(Moves.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expectLastResortFail(); // Were last resort itself counted, it would error here
|
|
|
|
// Growth (3/3)
|
|
blissey.pushMoveHistory({ move: Moves.GROWTH, targets: [BattlerIndex.PLAYER] });
|
|
game.move.select(Moves.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0]).toEqual(
|
|
expect.objectContaining({
|
|
move: Moves.LAST_RESORT,
|
|
result: MoveResult.SUCCESS,
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("should disregard virtually invoked moves", async () => {
|
|
game.override
|
|
.moveset([Moves.LAST_RESORT, Moves.SWORDS_DANCE, Moves.ABSORB, Moves.MIRROR_MOVE])
|
|
.enemyMoveset([Moves.SWORDS_DANCE, Moves.ABSORB])
|
|
.ability(Abilities.DANCER)
|
|
.enemySpecies(Species.ABOMASNOW); // magikarp has 50% chance to be okho'd on absorb crit
|
|
await game.classicMode.startBattle([Species.BLISSEY]);
|
|
|
|
// use mirror move normally to trigger absorb virtually
|
|
game.move.select(Moves.MIRROR_MOVE);
|
|
await game.forceEnemyMove(Moves.ABSORB);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(Moves.LAST_RESORT);
|
|
await game.forceEnemyMove(Moves.SWORDS_DANCE); // goes first to proc dancer ahead of time
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
expectLastResortFail();
|
|
});
|
|
|
|
it("should fail if no other moves in moveset", async () => {
|
|
game.override.moveset(Moves.LAST_RESORT);
|
|
await game.classicMode.startBattle([Species.BLISSEY]);
|
|
|
|
game.move.select(Moves.LAST_RESORT);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expectLastResortFail();
|
|
});
|
|
|
|
it("should work if invoked virtually when all other moves have been used", async () => {
|
|
game.override.moveset([Moves.LAST_RESORT, Moves.SLEEP_TALK]).ability(Abilities.COMATOSE);
|
|
await game.classicMode.startBattle([Species.KOMALA]);
|
|
|
|
game.move.select(Moves.SLEEP_TALK);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves(-1)).toEqual([
|
|
expect.objectContaining({
|
|
move: Moves.LAST_RESORT,
|
|
result: MoveResult.SUCCESS,
|
|
virtual: true,
|
|
}),
|
|
expect.objectContaining({
|
|
move: Moves.SLEEP_TALK,
|
|
result: MoveResult.SUCCESS,
|
|
}),
|
|
]);
|
|
});
|
|
|
|
it("should preserve usability status on reload", async () => {
|
|
game.override.moveset([Moves.LAST_RESORT, Moves.SPLASH]).ability(Abilities.COMATOSE);
|
|
await game.classicMode.startBattle([Species.BLISSEY]);
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
await game.doKillOpponents();
|
|
await game.toNextWave();
|
|
|
|
const oldMoveHistory = game.scene.getPlayerPokemon()?.summonData.moveHistory;
|
|
await game.reload.reloadSession();
|
|
|
|
const newMoveHistory = game.scene.getPlayerPokemon()?.summonData.moveHistory;
|
|
expect(oldMoveHistory).toEqual(newMoveHistory);
|
|
|
|
// use last resort and it should kill the karp just fine
|
|
game.move.select(Moves.LAST_RESORT);
|
|
game.scene.getEnemyPokemon()!.hp = 1;
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expect(game.isVictory()).toBe(true);
|
|
});
|
|
|
|
it("should fail if used while not in moveset", async () => {
|
|
game.override.moveset(Moves.MIRROR_MOVE).enemyMoveset([Moves.ABSORB, Moves.LAST_RESORT]);
|
|
await game.classicMode.startBattle([Species.BLISSEY]);
|
|
|
|
// ensure enemy last resort succeeds
|
|
game.move.select(Moves.MIRROR_MOVE);
|
|
await game.forceEnemyMove(Moves.ABSORB);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
game.move.select(Moves.MIRROR_MOVE);
|
|
await game.forceEnemyMove(Moves.LAST_RESORT);
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
expectLastResortFail();
|
|
});
|
|
});
|