public void refill_all_potions() { List<Potion> temporary_PTs = new List<Potion>(); for (int i = 0; i < inventory.Count; i++) { if (inventory[i] is Potion) { Potion oldPT = (Potion)inventory[i]; if (oldPT.is_potion_empty()) { Potion nextPT = new Potion(oldPT); nextPT.refill(); temporary_PTs.Add(nextPT); } } } for (int i = inventory.Count - 1; i >= 0; i--) if (inventory[i] is Potion) { Potion P = (Potion)inventory[i]; if (P.is_potion_empty()) inventory.RemoveAt(i); } for (int i = 0; i < temporary_PTs.Count; i++) acquire_potion(temporary_PTs[i]); temporary_PTs.Clear(); }