Initial set up for item use

This commit is contained in:
2025-01-10 11:11:50 +01:00
parent 85ea31f7cd
commit 0518499a4c
23 changed files with 305 additions and 59 deletions

View File

@@ -0,0 +1,40 @@
using System.Collections.Generic;
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Items;
[ItemScript("healing_item")]
public class HealingItem : ItemScript
{
private uint _healAmount;
/// <inheritdoc />
public override bool IsItemUsable => true;
/// <inheritdoc />
public override bool RequiresTarget => true;
/// <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;
/// <inheritdoc />
public override void OnUseWithTarget(IPokemon target)
{
target.Heal(_healAmount);
}
}