namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; /// /// Hydration is an ability that heals status conditions if it is raining at the end of the turn. /// /// Bulbapedia - Hydration /// [Script(ScriptCategory.Ability, "hydration")] public class Hydration : Script, IScriptOnEndTurn { private IPokemon? _pokemon; /// public override void OnAddedToParent(IScriptSource source) { if (source is not IPokemon pokemon) throw new InvalidOperationException("Hydration can only be added to a Pokemon script source."); _pokemon = pokemon; } /// public void OnEndTurn(IScriptSource owner, IBattle battle) { if (_pokemon is null) return; if (battle.WeatherName != ScriptUtils.ResolveName()) return; if (_pokemon.StatusScript.IsEmpty) return; EventBatchId batchId = new(); battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon) { BatchId = batchId, }); _pokemon.ClearStatus(batchId); } }