示例#1
0
        public void RemovePotion(HealingPotion potion)
        {
            List <int> markItemForDeletion = new List <int>();

            for (int i = 0; i < Inventory.Count; i++)
            {
                if (Inventory[i].Details.ID == potion.ID)
                {
                    Inventory[i].Quantity -= 1;
                    if (Inventory[i].Quantity == 0)
                    {
                        markItemForDeletion.Add(i);
                    }
                }
            }
            for (int i = markItemForDeletion.Count - 1; i >= 0; i--)
            {
                Inventory.RemoveAt(markItemForDeletion[i]);
            }
        }