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
{
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 override void OnEndTurn(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);
}
}