/// <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); }
public void SendGoods(Storage what) { receivedGoods.Subtract(what); }