Update harsh sun, heavy rain, and heavy winds to turn off if their respective abilities are no longer on the field

pull/280/head
gMak64 2024-04-24 18:24:10 -04:00 committed by Benjamin Odom
parent 3cc990f5d2
commit eeb20bbd34
2 changed files with 47 additions and 0 deletions

View File

@ -1620,6 +1620,16 @@ export class PreSwitchOutHealAbAttr extends PreSwitchOutAbAttr {
}
}
export class PreSwitchOutWeatherChangeAbAttr extends PreSwitchOutAbAttr {
applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
if (pokemon.scene.arena.weather?.isImmutable()) {
return pokemon.scene.arena.weather?.isAbilityOnField(pokemon.scene) ? false : pokemon.scene.arena.trySetWeather(WeatherType.NONE, true);
}
return false;
}
}
export class PreStatChangeAbAttr extends AbAttr {
applyPreStatChange(pokemon: Pokemon, passive: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise<boolean> {
return false;
@ -3320,12 +3330,15 @@ export function initAbilities() {
.unimplemented(),
new Ability(Abilities.PRIMORDIAL_SEA, 6)
.attr(PostSummonWeatherChangeAbAttr, WeatherType.HEAVY_RAIN)
.attr(PreSwitchOutWeatherChangeAbAttr)
.attr(PostBiomeChangeWeatherChangeAbAttr, WeatherType.HEAVY_RAIN),
new Ability(Abilities.DESOLATE_LAND, 6)
.attr(PostSummonWeatherChangeAbAttr, WeatherType.HARSH_SUN)
.attr(PreSwitchOutWeatherChangeAbAttr)
.attr(PostBiomeChangeWeatherChangeAbAttr, WeatherType.HARSH_SUN),
new Ability(Abilities.DELTA_STREAM, 6)
.attr(PostSummonWeatherChangeAbAttr, WeatherType.STRONG_WINDS)
.attr(PreSwitchOutWeatherChangeAbAttr)
.attr(PostBiomeChangeWeatherChangeAbAttr, WeatherType.STRONG_WINDS),
new Ability(Abilities.STAMINA, 7)
.attr(PostDefendStatChangeAbAttr, (target, user, move) => move.category !== MoveCategory.STATUS, BattleStat.DEF, 1),

View File

@ -7,6 +7,7 @@ import * as Utils from "../utils";
import BattleScene from "../battle-scene";
import { SuppressWeatherEffectAbAttr } from "./ability";
import { TerrainType } from "./terrain";
import { Abilities } from "./enums/abilities";
export enum WeatherType {
NONE,
@ -116,6 +117,39 @@ export class Weather {
return false;
}
isAbilityOnField(scene: BattleScene): boolean {
const field = scene.getField(true);
let abilitiesOnField = 0;
for (let pokemon of field) {
let ability = pokemon.getAbility();
switch (this.weatherType) {
case WeatherType.HARSH_SUN:
if (ability.id === Abilities.DESOLATE_LAND)
abilitiesOnField++
if (pokemon.hasPassive() && pokemon.getPassiveAbility().id === Abilities.DESOLATE_LAND)
abilitiesOnField++
break;
case WeatherType.HEAVY_RAIN:
if (ability.id === Abilities.PRIMORDIAL_SEA)
abilitiesOnField++
if (pokemon.hasPassive() && pokemon.getPassiveAbility().id === Abilities.PRIMORDIAL_SEA)
abilitiesOnField++
break;
case WeatherType.STRONG_WINDS:
if (ability.id === Abilities.DELTA_STREAM)
abilitiesOnField++
if (pokemon.hasPassive() && pokemon.getPassiveAbility().id === Abilities.DELTA_STREAM)
abilitiesOnField++
break;
default:
break;
}
}
return abilitiesOnField > 1;
}
}
export function getWeatherStartMessage(weatherType: WeatherType): string {