40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|
|
|
/// <summary>
|
|
/// Rain Dish is an ability that heals the Pokémon for 1/16 of its maximum HP each turn during rain.
|
|
///
|
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Rain_Dish_(Ability)">Bulbapedia - Rain Dish</see>
|
|
/// </summary>
|
|
[Script(ScriptCategory.Ability, "rain_dish")]
|
|
public class RainDish : Script
|
|
{
|
|
private IPokemon? _owner;
|
|
|
|
/// <inheritdoc />
|
|
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;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void OnEndTurn(IBattle battle)
|
|
{
|
|
if (_owner is null)
|
|
return;
|
|
if (battle.WeatherName != ScriptUtils.ResolveName<Weather.Rain>())
|
|
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);
|
|
}
|
|
} |