public void Add(IContent content) { var exists = Contents.Find(c => c.ContentLink.CompareToIgnoreWorkID(content.ContentLink)); if (exists != null) { Contents.Remove(exists); } Contents.Add(content); }
public void TakeFromContainer(User sender) { List <Item> dc = DecodeContents(); if (Contents.Count > 0) { sender.Connection.SendMessage("The container has: "); foreach (Item i in dc) { sender.Connection.SendMessage($"{i.Name}"); } sender.Connection.SendMessage("What would you like to take?"); string takeItem = sender.Connection.ReadMessage(); var item = Contents.Find(t => CommandUtils.FuzzyEquals(t.Actual.Name, takeItem)); if (item == null) { sender.Connection.SendMessage($"There is no {item.Actual.Name} in the container."); } else { sender.Inventory.AddToInventory(item.Actual); sender.Connection.SendMessage($"The {item.Actual.Name} has been added to your inventory."); CurrentCapacity -= item.Actual.Weight; Contents.Remove(item); } } else { sender.Connection.SendMessage($"The {Name} is empty."); } if (CurrentCapacity < 0) { CurrentCapacity = 0; } }