[Bug] Fix weather effects to work on the first turn of being cast (#1503)
* update weather phase so weather effects proc properly * remove redundant weather replace phase logic --------- Co-authored-by: ImperialSympathizer <imperialsympathizer@gmail.com>
This commit is contained in:
parent
b1c208cd86
commit
3b852c5bf2
|
@ -5,7 +5,7 @@ import * as Utils from "../utils";
|
|||
import PokemonSpecies, { getPokemonSpecies } from "../data/pokemon-species";
|
||||
import { Species } from "../data/enums/species";
|
||||
import { Weather, WeatherType, getTerrainClearMessage, getTerrainStartMessage, getWeatherClearMessage, getWeatherStartMessage } from "../data/weather";
|
||||
import { CommonAnimPhase, WeatherEffectPhase } from "../phases";
|
||||
import { CommonAnimPhase } from "../phases";
|
||||
import { CommonAnim } from "../data/battle-anims";
|
||||
import { Type } from "../data/type";
|
||||
import Move from "../data/move";
|
||||
|
@ -302,11 +302,9 @@ export class Arena {
|
|||
this.weather = weather ? new Weather(weather, hasPokemonSource ? 5 : 0) : null;
|
||||
|
||||
if (this.weather) {
|
||||
this.scene.tryReplacePhase(phase => phase instanceof WeatherEffectPhase && phase.weather.weatherType === oldWeatherType, new WeatherEffectPhase(this.scene, this.weather));
|
||||
this.scene.unshiftPhase(new CommonAnimPhase(this.scene, undefined, undefined, CommonAnim.SUNNY + (weather - 1)));
|
||||
this.scene.queueMessage(getWeatherStartMessage(weather));
|
||||
} else {
|
||||
this.scene.tryRemovePhase(phase => phase instanceof WeatherEffectPhase && phase.weather.weatherType === oldWeatherType);
|
||||
this.scene.queueMessage(getWeatherClearMessage(oldWeatherType));
|
||||
}
|
||||
|
||||
|
|
|
@ -2194,9 +2194,7 @@ export class TurnStartPhase extends FieldPhase {
|
|||
}
|
||||
|
||||
|
||||
if (this.scene.arena.weather) {
|
||||
this.scene.pushPhase(new WeatherEffectPhase(this.scene, this.scene.arena.weather));
|
||||
}
|
||||
this.scene.pushPhase(new WeatherEffectPhase(this.scene));
|
||||
|
||||
for (const o of order) {
|
||||
if (field[o].status && field[o].status.isPostTurn()) {
|
||||
|
@ -2379,6 +2377,10 @@ export class CommonAnimPhase extends PokemonPhase {
|
|||
this.targetIndex = targetIndex;
|
||||
}
|
||||
|
||||
setAnimation(anim: CommonAnim) {
|
||||
this.anim = anim;
|
||||
}
|
||||
|
||||
start() {
|
||||
new CommonBattleAnim(this.anim, this.getPokemon(), this.targetIndex !== undefined ? (this.player ? this.scene.getEnemyField() : this.scene.getPlayerField())[this.targetIndex] : this.getPokemon()).play(this.scene, () => {
|
||||
this.end();
|
||||
|
@ -3202,12 +3204,22 @@ export class StatChangePhase extends PokemonPhase {
|
|||
export class WeatherEffectPhase extends CommonAnimPhase {
|
||||
public weather: Weather;
|
||||
|
||||
constructor(scene: BattleScene, weather: Weather) {
|
||||
super(scene, undefined, undefined, CommonAnim.SUNNY + (weather.weatherType - 1));
|
||||
this.weather = weather;
|
||||
constructor(scene: BattleScene) {
|
||||
super(scene, undefined, undefined, CommonAnim.SUNNY + ((scene?.arena?.weather?.weatherType || WeatherType.NONE) - 1));
|
||||
this.weather = scene?.arena?.weather;
|
||||
}
|
||||
|
||||
start() {
|
||||
// Update weather state with any changes that occurred during the turn
|
||||
this.weather = this.scene?.arena?.weather;
|
||||
|
||||
if (!this.weather) {
|
||||
this.end();
|
||||
return;
|
||||
}
|
||||
|
||||
this.setAnimation(CommonAnim.SUNNY + (this.weather.weatherType - 1));
|
||||
|
||||
if (this.weather.isDamaging()) {
|
||||
|
||||
const cancelled = new Utils.BooleanHolder(false);
|
||||
|
|
Loading…
Reference in New Issue