namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "techno_blast")]
public class TechnoBlast : Script, IScriptChangeMoveType
{
    /// <inheritdoc />
    public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? moveType)
    {
        var heldItem = move.User.HeldItem;
        if (heldItem == null)
            return;
        var typeLibrary = target.Library.StaticLibrary.Types;

        moveType = heldItem.Name.ToString().ToLowerInvariant() switch
        {
            "burn_drive" when typeLibrary.TryGetTypeIdentifier("fire", out var fire) => fire,
            "chill_drive" when typeLibrary.TryGetTypeIdentifier("ice", out var ice) => ice,
            "douse_drive" when typeLibrary.TryGetTypeIdentifier("water", out var water) => water,
            "shock_drive" when typeLibrary.TryGetTypeIdentifier("electric", out var electric) => electric,
            _ => moveType,
        };
    }
}