using UnityEngine;

public class SampleItemCreator : MonoBehaviour
{
    [Header("Create Sample Items")]
    [SerializeField] private bool createSampleItems = false;

    void Start()
    {
        if (createSampleItems)
        {
            CreateSampleWeapons();
            CreateSampleArmor();
            CreateSampleMiscItems();
        }
    }

    [ContextMenu("Create Sample Weapons")]
    void CreateSampleWeapons()
    {
        // Simple Sword
        var simpleSword = ScriptableObject.CreateInstance<WeaponItem>();
        simpleSword.itemName = "Simple Sword";
        simpleSword.description = "A basic sword for beginners.";
        simpleSword.minDamage = 1;
        simpleSword.maxDamage = 6;
        simpleSword.range = 2;
        simpleSword.weaponModifier = 0;
        simpleSword.attackSpeed = 1.0f;
        simpleSword.weaponType = WeaponType.Sword;
        simpleSword.weaponClassName = "SimpleSword";
        simpleSword.goldCost = 10;
        simpleSword.searchTags = new string[] { "sword", "melee", "blade", "basic" };

        // Simple Bow
        var simpleBow = ScriptableObject.CreateInstance<WeaponItem>();
        simpleBow.itemName = "Simple Bow";
        simpleBow.description = "A basic bow for shooting arrows.";
        simpleBow.minDamage = 1;
        simpleBow.maxDamage = 6;
        simpleBow.range = 100;
        simpleBow.weaponModifier = 0;
        simpleBow.attackSpeed = 2.0f;
        simpleBow.weaponType = WeaponType.Bow;
        simpleBow.weaponClassName = "SimpleBow";
        simpleBow.goldCost = 15;
        simpleBow.searchTags = new string[] { "bow", "ranged", "arrow", "basic" };

        // Iron Sword (upgraded)
        var ironSword = ScriptableObject.CreateInstance<WeaponItem>();
        ironSword.itemName = "Iron Sword";
        ironSword.description = "A well-crafted iron sword with better balance.";
        ironSword.minDamage = 2;
        ironSword.maxDamage = 8;
        ironSword.range = 2;
        ironSword.weaponModifier = 1;
        ironSword.attackSpeed = 1.0f;
        ironSword.weaponType = WeaponType.Sword;
        ironSword.weaponClassName = "SimpleSword"; // Still uses SimpleSword for now
        ironSword.rarity = ItemRarity.Uncommon;
        ironSword.goldCost = 25;
        ironSword.searchTags = new string[] { "sword", "melee", "blade", "iron", "metal" };

        // Composite Bow (upgraded)
        var compositeBow = ScriptableObject.CreateInstance<WeaponItem>();
        compositeBow.itemName = "Composite Bow";
        compositeBow.description = "A bow made of multiple materials for increased power.";
        compositeBow.minDamage = 2;
        compositeBow.maxDamage = 8;
        compositeBow.range = 120;
        compositeBow.weaponModifier = 1;
        compositeBow.attackSpeed = 1.8f;
        compositeBow.weaponType = WeaponType.Bow;
        compositeBow.weaponClassName = "SimpleBow"; // Still uses SimpleBow for now
        compositeBow.rarity = ItemRarity.Uncommon;
        compositeBow.goldCost = 35;
        compositeBow.searchTags = new string[] { "bow", "ranged", "arrow", "composite" };

        Debug.Log("Sample weapons created (in memory only - save as assets to persist)");
    }

    [ContextMenu("Create Sample Armor")]
    void CreateSampleArmor()
    {
        // Leather Helmet
        var leatherHelmet = ScriptableObject.CreateInstance<ArmorItem>();
        leatherHelmet.itemName = "Leather Helmet";
        leatherHelmet.description = "Basic head protection made of leather.";
        leatherHelmet.armorClass = 1;
        leatherHelmet.armorType = ArmorType.Light;
        leatherHelmet.armorSlot = ArmorSlot.Head;
        leatherHelmet.goldCost = 5;
        leatherHelmet.searchTags = new string[] { "helmet", "head", "leather", "light" };

        // Leather Vest
        var leatherVest = ScriptableObject.CreateInstance<ArmorItem>();
        leatherVest.itemName = "Leather Vest";
        leatherVest.description = "A simple leather vest providing basic protection.";
        leatherVest.armorClass = 2;
        leatherVest.dexterityModifier = 1;
        leatherVest.armorType = ArmorType.Light;
        leatherVest.armorSlot = ArmorSlot.Chest;
        leatherVest.goldCost = 12;
        leatherVest.searchTags = new string[] { "vest", "chest", "leather", "light" };

        // Iron Chainmail
        var ironChainmail = ScriptableObject.CreateInstance<ArmorItem>();
        ironChainmail.itemName = "Iron Chainmail";
        ironChainmail.description = "Chainmail made of iron rings, offering good protection.";
        ironChainmail.armorClass = 4;
        ironChainmail.dexterityModifier = -1;
        ironChainmail.armorType = ArmorType.Medium;
        ironChainmail.armorSlot = ArmorSlot.Chest;
        ironChainmail.rarity = ItemRarity.Uncommon;
        ironChainmail.goldCost = 30;
        ironChainmail.searchTags = new string[] { "chainmail", "chest", "iron", "medium", "mail" };

        Debug.Log("Sample armor created (in memory only - save as assets to persist)");
    }

    [ContextMenu("Create Sample Misc Items")]
    void CreateSampleMiscItems()
    {
        // Health Potion
        var healthPotion = ScriptableObject.CreateInstance<MiscellaneousItem>();
        healthPotion.itemName = "Health Potion";
        healthPotion.description = "Restores 15 health points when consumed.";
        healthPotion.isConsumable = true;
        healthPotion.isStackable = true;
        healthPotion.maxStackSize = 10;
        healthPotion.healthRestore = 15;
        healthPotion.goldCost = 3;
        healthPotion.searchTags = new string[] { "potion", "health", "healing", "consumable" };

        // Rope
        var rope = ScriptableObject.CreateInstance<MiscellaneousItem>();
        rope.itemName = "Hemp Rope";
        rope.description = "50 feet of sturdy hemp rope.";
        rope.isConsumable = false;
        rope.isStackable = true;
        rope.maxStackSize = 5;
        rope.silverCost = 8;
        rope.searchTags = new string[] { "rope", "hemp", "utility", "tool" };

        Debug.Log("Sample miscellaneous items created (in memory only - save as assets to persist)");
    }
}
