Exemple #1
0
 public bool removeFromMarket(CCommodity cm)
 {
     if (cm.price < wasteThreshold)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
 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);
     }
 }
Exemple #3
0
        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);
        }
Exemple #4
0
 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;
     }
 }
Exemple #5
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);
        }
Exemple #6
0
        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));
        }
Exemple #7
0
 public void forSale(CCommodity cm)
 {
     forSaleCommoditiesDict.Add(cm.objectID, cm);
 }
Exemple #8
0
 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)));
 }