Example #1
0
 private void consumeInputResources(List <Storage> list)
 {
     foreach (Storage next in list)
     {
         inputReservs.subtract(next);
     }
 }
Example #2
0
    /// <summary>
    /// return true if buying is zero
    /// </summary>
    internal bool Buy(Producer buyer, PrimitiveStorageSet buying, Procent buyInTime, PrimitiveStorageSet ofWhat)
    {
        bool buyingIsEmpty = true;

        foreach (Storage what in ofWhat)
        {
            Storage consumeOnThisEteration = new Storage(what.getProduct(), what.get() * buyInTime.get());
            if (consumeOnThisEteration.get() == 0)
            {
                return(true);
            }
            // check if buying still have enoth to subtract consumeOnThisEteration
            if (!buying.has(consumeOnThisEteration))
            {
                consumeOnThisEteration = buying.findStorage(what.getProduct());
            }
            consumeOnThisEteration.multipleInside(Consume(buyer, consumeOnThisEteration, null));

            buying.subtract(consumeOnThisEteration);

            if (buying.findStorage(what.getProduct()).get() > 0)
            {
                buyingIsEmpty = false;
            }
        }
        return(buyingIsEmpty);
    }