mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-02-22 04:06:51 +00:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import BattleScene from "#app/battle-scene";
|
|
import { applyAbAttrs, PostBiomeChangeAbAttr } from "#app/data/ability";
|
|
import { getRandomWeatherType } from "#app/data/weather";
|
|
import { NextEncounterPhase } from "./next-encounter-phase";
|
|
|
|
export class NewBiomeEncounterPhase extends NextEncounterPhase {
|
|
constructor(scene: BattleScene) {
|
|
super(scene);
|
|
}
|
|
|
|
doEncounter(): void {
|
|
this.scene.playBgm(undefined, true);
|
|
|
|
for (const pokemon of this.scene.getParty()) {
|
|
if (pokemon) {
|
|
pokemon.resetBattleData();
|
|
}
|
|
}
|
|
|
|
for (const pokemon of this.scene.getParty().filter(p => p.isOnField())) {
|
|
applyAbAttrs(PostBiomeChangeAbAttr, pokemon, null);
|
|
}
|
|
|
|
const enemyField = this.scene.getEnemyField();
|
|
const moveTargets: any[] = [ this.scene.arenaEnemy, enemyField ];
|
|
const mysteryEncounter = this.scene.currentBattle?.mysteryEncounter?.introVisuals;
|
|
if (mysteryEncounter) {
|
|
moveTargets.push(mysteryEncounter);
|
|
}
|
|
|
|
this.scene.tweens.add({
|
|
targets: moveTargets.flat(),
|
|
x: "+=300",
|
|
duration: 2000,
|
|
onComplete: () => {
|
|
if (!this.tryOverrideForBattleSpec()) {
|
|
this.doEncounterCommon();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Set biome weather.
|
|
*/
|
|
trySetWeatherIfNewBiome(): void {
|
|
this.scene.arena.trySetWeather(getRandomWeatherType(this.scene.arena), false);
|
|
}
|
|
}
|