More abilities
This commit is contained in:
40
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/RainDish.cs
Normal file
40
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/RainDish.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user