using UnityEngine;

public class SimpleSword : Weapon
{
    [Header("Sword Settings")]
    public WeaponItem weaponItemData; // Reference to the ScriptableObject data

    public SimpleSword() : base()
    {
        weaponName = "Simple Sword";
        description = "A basic sword.";
        attackSpeed = 1.0f; // Example: 1 second between shots
        weaponModel = null; // Assign a 3D model if available
    }

    public override int MinDamage => weaponItemData != null ? weaponItemData.minDamage : 1;

    public override int MaxDamage => weaponItemData != null ? weaponItemData.maxDamage : 6;

    public override int Range => weaponItemData != null ? weaponItemData.range : 2;

    public override int WeaponModifier { get => weaponModifier; set => weaponModifier = value; }

    /// <summary>
    /// Initialize this weapon from a WeaponItem ScriptableObject
    /// </summary>
    /// <param name="itemData">The WeaponItem data to use</param>
    public void InitializeFromItem(WeaponItem itemData)
    {
        if (itemData == null) return;

        weaponItemData = itemData;
        weaponName = itemData.itemName;
        description = itemData.description;
        attackSpeed = itemData.attackSpeed;
        weaponModifier = itemData.weaponModifier;
        baseWeaponModifier = itemData.weaponModifier;
        weaponModel = itemData.model3D;

        Debug.Log($"SimpleSword initialized from item data: {weaponName}");
    }
}
