public void Buy(Player_Model player, Item_Model item, int Amount) { int priceToPay = item.Price * Amount; var seller = Players.Find(x => x.ID == item.PlayerID); if (seller == null) { throw new Exception(); } if (Amount > item.Quantity) { throw new IndexOutOfRangeException(); } else if (Amount == item.Quantity) { player.AddCash(-priceToPay); seller.AddCash(priceToPay); Items.Remove(item); } else { player.AddCash(-priceToPay); seller.AddCash(priceToPay); Items.Remove(item); item.Quantity -= Amount; Items.Add(item); } }
public void MakeOffer(Item_Model item, bool isComercial = false) { if (isComercial) { Items.Insert(0, item); } else { Items.Add(item); } }