pokerogue/src/phases/new-biome-encounter-phase.ts
Sirz Benjie ff44cbfa97
[Refactor] Refactor ability file part 1 (#5589)
* Move ability.ts to subfolder

* Extract types out of ability.ts

* Update imports in ability.ts and friends

* Cleanup imports in ability.ts

* Re-add imports lost during sort

* Update imports forgotten during rebase

* Re-import proper type from enums

* Update biome.jsonc

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Add commit to force tests to rerun

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-04-15 14:08:35 +00:00

47 lines
1.4 KiB
TypeScript

import { globalScene } from "#app/global-scene";
import { applyAbAttrs, PostBiomeChangeAbAttr } from "#app/data/abilities/ability";
import { getRandomWeatherType } from "#app/data/weather";
import { NextEncounterPhase } from "./next-encounter-phase";
export class NewBiomeEncounterPhase extends NextEncounterPhase {
doEncounter(): void {
globalScene.playBgm(undefined, true);
for (const pokemon of globalScene.getPlayerParty()) {
if (pokemon) {
pokemon.resetBattleData();
pokemon.customPokemonData.resetHitReceivedCount();
}
}
for (const pokemon of globalScene.getPlayerParty().filter(p => p.isOnField())) {
applyAbAttrs(PostBiomeChangeAbAttr, pokemon, null);
}
const enemyField = globalScene.getEnemyField();
const moveTargets: any[] = [globalScene.arenaEnemy, enemyField];
const mysteryEncounter = globalScene.currentBattle?.mysteryEncounter?.introVisuals;
if (mysteryEncounter) {
moveTargets.push(mysteryEncounter);
}
globalScene.tweens.add({
targets: moveTargets.flat(),
x: "+=300",
duration: 2000,
onComplete: () => {
if (!this.tryOverrideForBattleSpec()) {
this.doEncounterCommon();
}
},
});
}
/**
* Set biome weather.
*/
trySetWeatherIfNewBiome(): void {
globalScene.arena.trySetWeather(getRandomWeatherType(globalScene.arena));
}
}