using Decimation.Lib.Items;
using Decimation.Lib.Util;
using Decimation.Lib.Util.Builder;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Decimation.Content.Items.Accessories
{
    public class WaspNecklace : DecimationAccessory
    {
        protected override string ItemName => "Wasp Necklace";

        protected override string ItemTooltip => "Releases wasps and increase movement speed after taking damage\n" +
                                                 "Attackers have 20% chances to be poisoned";

        protected override void InitAccessory()
        {
            item.width = 30;
            item.height = 32;
            item.value = Item.buyPrice(gold: 1, silver: 70);
            item.rare = Rarity.Green.GetRarityValue();
        }

        protected override ModRecipe GetRecipe()
        {
            return new RecipeBuilder(this)
                .WithIngredient(ItemID.SweetheartNecklace)
                .WithIngredient(ModContent.ItemType<WaspNest>())
                .WithStation(TileID.TinkerersWorkbench)
                .Build();
        }
    }

    internal class WaspNecklacePoisonEffect : GlobalNPC
    {
        public override void OnHitPlayer(NPC npc, Player target, int damage, bool crit)
        {
            if (target.HasEquippedAccessory(ModContent.ItemType<WaspNecklace>()) && Main.rand.NextBool(5))
                npc.AddBuff(BuffID.Poisoned, 300);

            base.OnHitPlayer(npc, target, damage, crit);
        }
    }
    
}