/// <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()); }
/// <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)); }
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)); }
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)); }
public Storage getSentToMarket(Product product) { return(sentToMarket.getFirstStorage(product)); }
internal Value getConsumption(Product prod) { return(consumption.getFirstStorage(prod)); }