Пример #1
0
        /// <summary>
        /// Buying PrimitiveStorageSet, subsidizations allowed
        /// </summary>
        //internal void SellList(Consumer buyer, StorageSet buying, Country subsidizer)
        //{
        //    foreach (Storage item in buying)
        //        if (item.isNotZero())
        //            buy(buyer, item, subsidizer);
        //}

        /// <summary>
        /// Buying needs in circle, by Procent in time
        /// return true if buying is zero (bought all what it wanted)
        /// </summary>
        internal bool Sell(Producer buyer, StorageSet stillHaveToBuy, Procent buyInTime, List <Storage> ofWhat)
        {
            bool buyingIsFinished = true;

            foreach (Storage what in ofWhat)
            {
                Storage consumeOnThisIteration = new Storage(what.Product, what.get() * buyInTime.get());
                if (consumeOnThisIteration.isZero())
                {
                    return(true);
                }

                // check if consumeOnThisIteration is not bigger than stillHaveToBuy
                if (!stillHaveToBuy.has(consumeOnThisIteration))
                {
                    consumeOnThisIteration = stillHaveToBuy.getBiggestStorage(what.Product);
                }
                var reallyBought = Sell(buyer, consumeOnThisIteration, null);

                stillHaveToBuy.Subtract(reallyBought);

                if (stillHaveToBuy.getBiggestStorage(what.Product).isNotZero())
                {
                    buyingIsFinished = false;
                }
            }
            return(buyingIsFinished);
        }
Пример #2
0
        /// <summary>
        /// Based on DSB, shows how much you can get assuming you have enough money
        /// </summary>
        internal Storage HowMuchAvailable(Storage need)
        {
            //float BuyingAmountAvailable = 0;
            return(sentToMarket.getBiggestStorage(need.Product));

            //BuyingAmountAvailable = need.get() / DSB;

            //float DSB = getDemandSupplyBalance(need.Product);
            //float BuyingAmountAvailable = 0;

            //if (DSB < 1f) DSB = 1f;
            //BuyingAmountAvailable = need.get() / DSB;

            //return new Storage(need.Product, BuyingAmountAvailable);
        }
Пример #3
0
        /// <summary>
        /// Based on DSB, shows how much you can get assuming you have enough money
        /// </summary>
        public Storage HowMuchAvailable(Storage need)
        {
            //float BuyingAmountAvailable = 0;
            return(receivedGoods.getBiggestStorage(need.Product));

            //BuyingAmountAvailable = need.get() / DSB;

            //float DSB = getDemandSupplyBalance(need.Product);
            //float BuyingAmountAvailable = 0;

            //if (DSB < 1f) DSB = 1f;
            //BuyingAmountAvailable = need.get() / DSB;

            //return new Storage(need.Product, BuyingAmountAvailable);
        }
Пример #4
0
 internal Procent getConsumptionProcent(Product product, Country country)
 {
     // getBiggestStorage here are duplicated in this.consume() (convertToBiggestStorageProduct())
     return(new Procent(consumption.getBiggestStorage(product), getRealNeeds(country, product), false));
 }