using ActionGame.GameArtifacts.Models.Items;
using System.Collections.Generic;


namespace ActionGame.GameArtifacts.Models.Game
{
    public class SaveInventoryContainer
    {
        public IList<SaveInventorySlotContainer> InventorySlots { get; set; }
        public SaveInventorySlotContainer Slot1 { get; set; }
        public SaveInventorySlotContainer Slot2 { get; set; }


        public SaveInventoryContainer()
        {
            this.InventorySlots = new List<SaveInventorySlotContainer>();
        }


        public SaveInventoryContainer(Inventory inventory)
        {
            if(inventory.Slot1 != null)
            {
                this.Slot1 = new SaveInventorySlotContainer()
                {
                    ItemKey = inventory.Slot1.Item.Key,
                    Quantity = inventory.Slot1.Quantity
                };
            }

            if (inventory.Slot2 != null)
            {
                this.Slot2 = new SaveInventorySlotContainer()
                {
                    ItemKey = inventory.Slot2.Item.Key,
                    Quantity = inventory.Slot2.Quantity
                };
            }

            this.InventorySlots = new List<SaveInventorySlotContainer>();
            foreach(InventorySlot slot in inventory.InventorySlots)
            {
                SaveInventorySlotContainer saveSlot = new SaveInventorySlotContainer()
                {
                    ItemKey = slot.Item.Key,
                    Quantity = slot.Quantity
                };

                this.InventorySlots.Add(saveSlot);
            }
        }


    }
}
