pokerogue/src/phases/next-encounter-phase.ts
Bertie690 6d90649b92
[Refactor/Bug/Ability] Reworked BattleData, fixed Rage Fist, Harvest, Belch + Implemented Cud Chew (#5655)
* 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>
2025-05-02 00:06:07 -05:00

85 lines
2.7 KiB
TypeScript

import { globalScene } from "#app/global-scene";
import { EncounterPhase } from "./encounter-phase";
/**
* The phase between defeating an encounter and starting another wild wave.
* Handles generating, loading and preparing for it.
*/
export class NextEncounterPhase extends EncounterPhase {
start() {
super.start();
}
doEncounter(): void {
globalScene.playBgm(undefined, true);
// Reset all player transient wave data/intel before starting a new wild encounter.
// We exclusively reset wave data here as wild waves are considered one continuous "battle"
// for lack of an arena transition.
for (const pokemon of globalScene.getPlayerParty()) {
if (pokemon) {
pokemon.resetWaveData();
}
}
globalScene.arenaNextEnemy.setBiome(globalScene.arena.biomeType);
globalScene.arenaNextEnemy.setVisible(true);
const enemyField = globalScene.getEnemyField();
const moveTargets: any[] = [
globalScene.arenaEnemy,
globalScene.arenaNextEnemy,
globalScene.currentBattle.trainer,
enemyField,
globalScene.lastEnemyTrainer,
];
const lastEncounterVisuals = globalScene.lastMysteryEncounter?.introVisuals;
if (lastEncounterVisuals) {
moveTargets.push(lastEncounterVisuals);
}
const nextEncounterVisuals = globalScene.currentBattle.mysteryEncounter?.introVisuals;
if (nextEncounterVisuals) {
const enterFromRight = nextEncounterVisuals.enterFromRight;
if (enterFromRight) {
nextEncounterVisuals.x += 500;
globalScene.tweens.add({
targets: nextEncounterVisuals,
x: "-=200",
duration: 2000,
});
} else {
moveTargets.push(nextEncounterVisuals);
}
}
globalScene.tweens.add({
targets: moveTargets.flat(),
x: "+=300",
duration: 2000,
onComplete: () => {
globalScene.arenaEnemy.setBiome(globalScene.arena.biomeType);
globalScene.arenaEnemy.setX(globalScene.arenaNextEnemy.x);
globalScene.arenaEnemy.setAlpha(1);
globalScene.arenaNextEnemy.setX(globalScene.arenaNextEnemy.x - 300);
globalScene.arenaNextEnemy.setVisible(false);
if (globalScene.lastEnemyTrainer) {
globalScene.lastEnemyTrainer.destroy();
}
if (lastEncounterVisuals) {
globalScene.field.remove(lastEncounterVisuals, true);
globalScene.lastMysteryEncounter!.introVisuals = undefined;
}
if (!this.tryOverrideForBattleSpec()) {
this.doEncounterCommon();
}
},
});
}
/**
* Do nothing (since this is simply the next wave in the same biome).
*/
trySetWeatherIfNewBiome(): void {}
}