Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Items/HealingItem.cs
Deukhoofd e38bb05007
All checks were successful
Build / Build (push) Successful in 3m24s
Move itemscript back to using IPokemon instead of IBattlePokemon
2026-08-28 16:12:19 +02:00

40 lines
1.1 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Items;
[ItemScript("healing_item")]
public class HealingItem : ItemScript
{
private uint _healAmount;
/// <inheritdoc />
public HealingItem(IItem item) : base(item)
{
}
/// <inheritdoc />
public override bool IsItemUsable => true;
/// <inheritdoc />
public override ItemTargetType TargetType => ItemTargetType.OwnPokemon;
/// <inheritdoc />
public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
{
if (parameters == null || !parameters.TryGetValue("heal_amount", out var healAmountObj) ||
healAmountObj is not int healAmount)
{
healAmount = 20;
}
_healAmount = (uint)healAmount;
}
/// <inheritdoc />
public override bool IsTargetValid(IPokemon target) =>
!target.IsFainted && target.CurrentHealth < target.MaxHealth;
/// <inheritdoc />
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
{
target.Heal(_healAmount, customEventHook: eventHook);
}
}