using System.Collections.Generic;
using Decimation.Content.NPCs.DuneWyrm;
using Decimation.Lib.Items;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Decimation.Content.Items.Boss.DuneWyrm
{
    internal class DesertDessert : DecimationItem
    {
        protected override string ItemName => "Desert Dessert";
        protected override string ItemTooltip => "Summons the Dune Wyrm";

        protected override void Init()
        {
            item.width = 32;
            item.height = 32;
            item.value = Item.buyPrice(0, 0, 13);
            item.useStyle = 4;
            item.useAnimation = 30;
            item.useTime = 30;
            item.consumable = true;

            this.item.maxStack = 20;
        }

        public override bool UseItem(Player player)
        {
            if (player.ZoneDesert)
            {
                if (Main.netMode == 0)
                {
                    Main.PlaySound(15, (int) player.position.X, (int) player.position.Y, 0);
                    NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType<DuneWyrmHead>());
                    return true;
                }

                ModPacket packet = this.mod.GetPacket();
                packet.Write((byte) DecimationModMessageType.SpawnBoss);
                packet.Write(ModContent.NPCType<DuneWyrmHead>());
                packet.Write(player.whoAmI);
                packet.Send();
            }

            return false;
        }

        protected override ModRecipe GetRecipe() //How to craft this item
        {
            ModRecipe recipe = GetNewModRecipe(this, 1, new List<int> {TileID.Anvils});

            recipe.AddIngredient(ItemID.SandBlock, 10);
            recipe.AddIngredient(ItemID.WormTooth, 5);

            return recipe;
        }
    }
}