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 WaspNest : DecimationAccessory
    {
        protected override string ItemName => "Wasp Nest";
        protected override string ItemTooltip => "Attackers also take damage\n" +
                                                 "Attackers have 50% chances to be poisoned";
        
        protected override void InitAccessory()
        {
            item.width = 32;
            item.height = 30;
            item.value = Item.buyPrice(silver: 10);
            item.rare = Rarity.Blue.GetRarityValue();
        }

        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            player.AddBuff(BuffID.Thorns, 600);

            base.UpdateAccessory(player, hideVisual);
        }

        protected override ModRecipe GetRecipe()
        {
            return new RecipeBuilder(this)
                .WithIngredient(ItemID.BeeWax, 10)
                .WithIngredient(ItemID.Stinger, 15)
                .WithIngredient(ItemID.BottledHoney)
                .WithStation(TileID.WorkBenches)
                .Build();
        }
    }

    internal class WaspNestPoisonEffect : GlobalNPC
    {
        public override void OnHitPlayer(NPC npc, Player target, int damage, bool crit)
        {
            if (target.HasEquippedAccessory(ModContent.ItemType<WaspNest>()) && Main.rand.NextBool(2))
                npc.AddBuff(BuffID.Poisoned, 600);
        }
    }
    
}