namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
///
/// Rain Dish is an ability that heals the Pokémon for 1/16 of its maximum HP each turn during rain.
///
/// Bulbapedia - Rain Dish
///
[Script(ScriptCategory.Ability, "rain_dish")]
public class RainDish : Script
{
private IPokemon? _owner;
///
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IPokemon pokemon)
throw new ArgumentException("RainDish script can only be added to a Pokemon.", nameof(source));
_owner = pokemon;
}
///
public override void OnEndTurn(IScriptSource owner, IBattle battle)
{
if (_owner is null)
return;
if (battle.WeatherName != ScriptUtils.ResolveName())
return;
var healAmount = _owner.MaxHealth / 16;
if (healAmount <= 0)
return;
EventBatchId batchId = new();
battle.EventHook.Invoke(new AbilityTriggerEvent(_owner)
{
BatchId = batchId,
});
_owner.Heal(healAmount, batchId: batchId);
}
}