pokerogue/src/phases/switch-biome-phase.ts
NightKev 9dcb904649
[Misc] Improve enum naming (#5933)
* Rename `Abilities` to `AbilityId`

* Rename `abilities.ts` to `ability-id.ts`

* Rename `Moves` to `MoveId`

* Rename `moves.ts` to `move-id.ts`

* Rename `Species` to `SpeciesId`

* Rename `species.ts` to `species-id.ts`

* Rename `Biome` to `BiomeId`

* Rename `biome.ts` to `biome-id.ts`

* Replace `Abilities` with `AbilityId` in comments

* Replace `Biome` with `BiomeId` in comments

* Replace `Moves` with `MoveId` in comments

* Replace `Species` with `SpeciesId` in comments
2025-06-04 14:54:27 -07:00

70 lines
2.4 KiB
TypeScript

import { globalScene } from "#app/global-scene";
import type { BiomeId } from "#enums/biome-id";
import { getBiomeKey } from "#app/field/arena";
import { BattlePhase } from "./battle-phase";
export class SwitchBiomePhase extends BattlePhase {
private nextBiome: BiomeId;
constructor(nextBiome: BiomeId) {
super();
this.nextBiome = nextBiome;
}
start() {
super.start();
if (this.nextBiome === undefined) {
return this.end();
}
// Before switching biomes, make sure to set the last encounter for other phases that need it too.
globalScene.lastEnemyTrainer = globalScene.currentBattle?.trainer ?? null;
globalScene.lastMysteryEncounter = globalScene.currentBattle?.mysteryEncounter;
globalScene.tweens.add({
targets: [globalScene.arenaEnemy, globalScene.lastEnemyTrainer],
x: "+=300",
duration: 2000,
onComplete: () => {
globalScene.arenaEnemy.setX(globalScene.arenaEnemy.x - 600);
globalScene.newArena(this.nextBiome);
const biomeKey = getBiomeKey(this.nextBiome);
const bgTexture = `${biomeKey}_bg`;
globalScene.arenaBgTransition.setTexture(bgTexture);
globalScene.arenaBgTransition.setAlpha(0);
globalScene.arenaBgTransition.setVisible(true);
globalScene.arenaPlayerTransition.setBiome(this.nextBiome);
globalScene.arenaPlayerTransition.setAlpha(0);
globalScene.arenaPlayerTransition.setVisible(true);
globalScene.tweens.add({
targets: [globalScene.arenaPlayer, globalScene.arenaBgTransition, globalScene.arenaPlayerTransition],
duration: 1000,
delay: 1000,
ease: "Sine.easeInOut",
alpha: (target: any) => (target === globalScene.arenaPlayer ? 0 : 1),
onComplete: () => {
globalScene.arenaBg.setTexture(bgTexture);
globalScene.arenaPlayer.setBiome(this.nextBiome);
globalScene.arenaPlayer.setAlpha(1);
globalScene.arenaEnemy.setBiome(this.nextBiome);
globalScene.arenaEnemy.setAlpha(1);
globalScene.arenaNextEnemy.setBiome(this.nextBiome);
globalScene.arenaBgTransition.setVisible(false);
globalScene.arenaPlayerTransition.setVisible(false);
if (globalScene.lastEnemyTrainer) {
globalScene.lastEnemyTrainer.destroy();
}
this.end();
},
});
},
});
}
}