public bool removeFromMarket(CCommodity cm) { if (cm.price < wasteThreshold) { return(true); } else { return(false); } }
void sellTo(COfferToBuy otb, CCommodity cm) { if (otb.quantity >= cm.quantity) { otb.myConsumer.offerSuccess(otb, cm.quantity); cm.myProducer.sold(cm, cm.quantity); } else { cm.myProducer.sold(cm, otb.quantity); otb.myConsumer.offerSuccess(otb, otb.quantity); } }
void shipToMarket() { //Spawn CCommodity and ship to market CCommodity shp = new CCommodity(); shp.myProducer = this; shp.onMarketAt = CMainTicker.gameDateTime; shp.price = price; shp.produceName = produceName; shp.quantity = currentInStock; shp.spoilTime = CMainTicker.gameDateTime.Add(spoilTime); currentShipped += currentInStock; totalShipped += currentInStock; currentInStock = 0; itemsShipped.Add(shp.objectID, shp); myMarket.forSale(shp); }
public void sold(CCommodity cm, double q) { if (q < cm.quantity) { totalSold += q; currentShipped -= q; totalIncome += cm.price * q; cm.quantity -= q; } else { totalSold += cm.quantity; currentShipped -= cm.quantity; totalIncome += cm.price * cm.quantity; itemsShipped.Remove(cm.objectID); cm.quantity = 0; } }
public CCommodity buy(double offeredPrice) { CCommodity found = null; foreach (CCommodity item in forSaleCommoditiesDict.Values) { if (offeredPrice >= item.price) { found = item; break; } } if (found != null) { forSaleCommoditiesDict.Remove(found.objectID); found.myProducer.sold(found, found.quantity); } return(found); }
public double buy(double offeredPrice, double quantity) { CCommodity found = null; double tmpQ = 0; foreach (CCommodity item in forSaleCommoditiesDict.Values) { if (offeredPrice >= item.price) { found = item; break; } } if (found != null) { tmpQ = found.quantity; if (found.quantity <= quantity) { forSaleCommoditiesDict.Remove(found.objectID); } found.myProducer.sold(found, quantity); } return(Math.Min(tmpQ, quantity)); }
public void forSale(CCommodity cm) { forSaleCommoditiesDict.Add(cm.objectID, cm); }
public double getPrice(CCommodity tc) { //A straight reduction in price from intro on market to spoildate return(price * (((tc.spoilTime - CMainTicker.gameDateTime).TotalSeconds) / ((tc.spoilTime - tc.onMarketAt).TotalSeconds))); }