예제 #1
0
        internal StorageSet getBuildNeeds()
        {
            //return new Storage(Product.Food, 40f);
            // thats weird place
            StorageSet result = new StorageSet();

            result.set(new Storage(Product.Grain, 40f));
            //TODO!has connection in pop.invest!!
            //if (whoCanProduce(Product.Gold) == this)
            //        result.Set(new Storage(Product.Wood, 40f));
            return(result);
        }
예제 #2
0
        /// <summary>
        /// Result > 1 mean demand is higher, price should go up   Result fewer 1 mean supply is higher, price should go down
        /// based on last turn data
        ///</summary>
        internal float getDemandSupplyBalance(Product product)
        {
            //Debug.Log("I'm in DSBBalancer, dateOfDSB = " + dateOfDSB);
            float balance;

            if (dateOfDSB != Game.date)
            // recalculate DSBbuffer
            {
                //Debug.Log("Recalculation of DSB started");
                foreach (Storage nextProduct in marketPrice)
                {
                    if (nextProduct.getProduct().isTradable())
                    {
                        getProductionTotal(product, false);  // for pre-turn initialization
                        getTotalConsumption(product, false); // for pre-turn initialization
                        float supply = getMarketSupply(nextProduct.getProduct(), false).get();
                        float demand = getBouthOnMarket(nextProduct.getProduct(), false).get();

                        //if (supply == 0 && demand == 0) // both zero
                        //    balance = Options.MarketInfiniteDSB;
                        //else
                        //{
                        if (supply == 0)
                        {
                            balance = Options.MarketInfiniteDSB; // supply zero
                        }
                        else
                        {
                            if (demand == 0)                     // demand zero
                            {
                                balance = Options.MarketZeroDSB; // otherwise - furniture bag
                            }
                            else
                            {
                                balance = demand / supply;
                            }
                        }
                        //}
                        DSBbuffer.set(new Storage(nextProduct.getProduct(), balance));
                    }
                }
                dateOfDSB.set(Game.date);
            }
            return(DSBbuffer.getFirstStorage(product).get());
        }
예제 #3
0
 /// <summary>
 /// Only goods sent to market
 /// Based  on last turn data
 /// </summary>
 internal Storage getMarketSupply(Product product, bool takeThisTurnData)
 {
     if (takeThisTurnData)
     {
         return(recalculateProductForSellers(product, x => x.getSentToMarket(product)));
     }
     if (dateOfgetSupplyOnMarket != Game.date)
     {
         //recalculate supply buffer
         foreach (Storage recalculatingProduct in marketPrice)
         {
             if (recalculatingProduct.getProduct().isTradable())
             {
                 var result = recalculateProductForSellers(recalculatingProduct.getProduct(), x => x.getSentToMarket(recalculatingProduct.getProduct()));
                 supplyOnMarket.set(new Storage(recalculatingProduct.getProduct(), result));
             }
         }
         dateOfgetSupplyOnMarket.set(Game.date);
     }
     return(supplyOnMarket.getFirstStorage(product));
 }
예제 #4
0
 internal Storage getTotalConsumption(Product product, bool takeThisTurnData)
 {
     if (takeThisTurnData)
     {
         return(recalculateProductForConsumers(product, x => x.getConsumed()));
     }
     if (dateOfgetTotalConsumption != Game.date)
     {
         //recalculate buffer
         foreach (Storage recalculatingProduct in marketPrice)
         {
             if (recalculatingProduct.getProduct().isTradable())
             {
                 var result = recalculateProductForConsumers(recalculatingProduct.getProduct(), x => x.getConsumed());
                 totalConsumption.set(new Storage(recalculatingProduct.getProduct(), result));
             }
         }
         dateOfgetTotalConsumption.set(Game.date);
     }
     return(totalConsumption.getFirstStorage(product));
 }
예제 #5
0
        internal Storage getBouthOnMarket(Product product, bool takeThisTurnData)
        {
            if (takeThisTurnData)
            {
                // recalculate only 1 product
                return(recalculateProductForBuyers(product, x => x.getConsumedInMarket()));
            }
            if (dateOfgetBought != Game.date)
            {
                //recalculate all products
                foreach (Storage recalculatingProduct in marketPrice)
                {
                    if (recalculatingProduct.getProduct().isTradable())
                    {
                        var result = recalculateProductForConsumers(recalculatingProduct.getProduct(), x => x.getConsumedInMarket());

                        bought.set(new Storage(recalculatingProduct.getProduct(), result));
                    }
                }
                dateOfgetBought.set(Game.date);
            }
            return(bought.getFirstStorage(product));
        }
예제 #6
0
        static FactoryType()
        {
            new FactoryType("Forestry", new Storage(Product.Wood, 2f), false);
            new FactoryType("Gold pit", new Storage(Product.Gold, 2f), true);
            new FactoryType("Metal pit", new Storage(Product.MetalOre, 2f), true);
            new FactoryType("Coal pit", new Storage(Product.Coal, 3f), true);
            new FactoryType("Cotton farm", new Storage(Product.Cotton, 2f), false);
            new FactoryType("Quarry", new Storage(Product.Stone, 2f), true);
            new FactoryType("Orchard", new Storage(Product.Fruit, 2f), false);
            new FactoryType("Fishery", new Storage(Product.Fish, 2f), false);
            new FactoryType("Tobacco farm", new Storage(Product.Tobacco, 2f), false);

            new FactoryType("Oil rig", new Storage(Product.Oil, 2f), true);
            new FactoryType("Rubber plantation", new Storage(Product.Rubber, 1f), false);

            StorageSet resourceInput = new StorageSet();

            resourceInput.set(new Storage(Product.Grain, 1f));
            new FactoryType("Barnyard", new Storage(Product.Cattle, 2f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Lumber, 1f));
            new FactoryType("Furniture factory", new Storage(Product.Furniture, 2f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Wood, 1f));
            new FactoryType("Sawmill", new Storage(Product.Lumber, 2f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Fuel, 0.5f));
            resourceInput.set(new Storage(Product.MetalOre, 2f));
            new FactoryType("Metal smelter", new Storage(Product.Metal, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Fibers, 1f));
            new FactoryType("Weaver factory", new Storage(Product.Clothes, 2f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Fuel, 0.5f));
            resourceInput.set(new Storage(Product.Stone, 2f));
            new FactoryType("Cement factory", new Storage(Product.Cement, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Sugar, 1f));
            new FactoryType("Distillery", new Storage(Product.Liquor, 2f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Metal, 1f));
            new FactoryType("Smithery", new Storage(Product.ColdArms, 2f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Stone, 1f));
            resourceInput.set(new Storage(Product.Metal, 1f));
            new FactoryType("Ammunition factory", new Storage(Product.Ammunition, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Lumber, 1f));
            resourceInput.set(new Storage(Product.Metal, 1f));
            new FactoryType("Firearms factory", new Storage(Product.Firearms, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Lumber, 1f));
            resourceInput.set(new Storage(Product.Metal, 1f));
            new FactoryType("Artillery factory", new Storage(Product.Artillery, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Oil, 1f));
            new FactoryType("Oil refinery", new Storage(Product.MotorFuel, 2f), resourceInput);


            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Metal, 1f));
            new FactoryType("Machinery factory", new Storage(Product.Machinery, 2f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Machinery, 1f));
            resourceInput.set(new Storage(Product.Metal, 1f));
            resourceInput.set(new Storage(Product.Rubber, 1f));
            new FactoryType("Car factory", new Storage(Product.Cars, 6f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Machinery, 1f));
            resourceInput.set(new Storage(Product.Metal, 1f));
            resourceInput.set(new Storage(Product.Artillery, 1f));
            new FactoryType("Tank factory", new Storage(Product.Tanks, 6f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Lumber, 1f));
            resourceInput.set(new Storage(Product.Metal, 1f));
            resourceInput.set(new Storage(Product.Machinery, 1f));
            new FactoryType("Airplane factory", new Storage(Product.Airplanes, 6f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.set(new Storage(Product.Metal, 1f));
            resourceInput.set(new Storage(Product.Oil, 1f));
            resourceInput.set(new Storage(Product.Rubber, 1f));
            new FactoryType("Electronics factory", new Storage(Product.Electronics, 6f), resourceInput);
        }
예제 #7
0
 //internal void ForceDSBRecalculation()
 //{
 //    //dateOfDSB--;//!!! Warning! This need to be uncommented to work properly
 //    getDemandSupplyBalance(null);
 //}
 /// <summary>
 /// per 1 unit
 /// </summary>
 public void SetDefaultPrice(Product pro, float inprice)
 {
     marketPrice.set(new Storage(pro, inprice));
 }