/// <summary> /// Process selling cargo to a merchant /// </summary> /// <param name="ship">The ship doing the selling</param> /// <param name="warehouse">The merchant doing the buying</param> /// <param name="assets">The player's wealth</param> /// <param name="id">The cargo to sell</param> /// <param name="count">The amount to sell</param> /// <returns>Successfulness</returns> public static bool ProcessSell(CargoHold ship, Warehouse warehouse, PlayerAssets assets, Cargoes id, int count) { int price = warehouse.GetBuyPrice(id, count); if (warehouse.cash < price) { return(false); } if (warehouse.GetWantQuantity(id) == 0) { return(false); } if (ship.GetItemCount(id) < count) { return(false); } ship.Remove(id, count); warehouse.ModifyBuyingWare(id, -count); assets.ModifyCash(price); warehouse.ModifyCash(-price); if (!CargoManager.GetCargo(id).legal) { assets.ModifyReputation(price); } return(true); }
private void UpdateSelectedItem() { if (_selectedItem < _itemList.Count) { PurchaseItem item = _itemList[_selectedItem]; CargoList.CargoEntry cargo = CargoManager.GetCargo(item.ware.id); _selectedWareNameLabel.text = cargo.name; _sellerHoldLabel.text = item.ware.count.ToString(); _playerHoldLabel.text = _ship.GetItemCount(cargo.cargo).ToString(); } }