21 marketId = commodity.getMarket().getId();
22 commodityId = commodity.getId();
23 supplyPrice = Math.round(commodity.getMarket().getSupplyPrice(commodity.getId(), 1,
true));
24 demandPrice = Math.round(commodity.getMarket().getDemandPrice(commodity.getId(), 1,
true));
35 demand = commodity.getDemand().getDemandValue();
40 float stockpile = com.getStockpile();
41 float after = stockpile * stockpileMult;
43 float diff = (after - stockpile) * com.getUtilityOnMarket();
45 supplyPrice = Math.round(com.getMarket().getSupplyPriceAssumingExistingTransaction(
46 com.getId(), 1, diff,
true));
47 demandPrice = Math.round(com.getMarket().getDemandPriceAssumingExistingTransaction(
48 com.getId(), 1, diff,
true));
64 float testSupplyPrice = supplyPrice;
65 float testDemandPrice = demandPrice;
70 if (priceFlat != 0 || pricePercent != 0) {
72 testSupplyPrice = Math.round(commodity.getMarket().getSupplyPrice(commodity.getId(), 1,
true) * (1f + pricePercent / 100f) + priceFlat);
73 testDemandPrice = Math.round(commodity.getMarket().getDemandPrice(commodity.getId(), 1,
true) * (1f + pricePercent / 100f) + priceFlat);
81 testSupplyPrice = Math.round(commodity.getMarket().getSupplyPrice(commodity.getId(), 1,
true));
82 testDemandPrice = Math.round(commodity.getMarket().getDemandPrice(commodity.getId(), 1,
true));
84 supplyPrice = testSupplyPrice;
85 demandPrice = testDemandPrice;
92 amt = (int) (testSupplyPrice + testDemandPrice) / 2;
95 amt = (int) testSupplyPrice;
98 amt = (int) testDemandPrice;
101 amt = (int) Misc.getRounded(amt);
129 public void updateType(
float priceFlat,
float pricePercent) {
132 CommodityStatTracker stats =
new CommodityStatTracker();
133 float testSupplyPrice = supplyPrice;
134 float testDemandPrice = demandPrice;
139 if (priceFlat != 0 || pricePercent != 0) {
140 testSupplyPrice = Math.round(commodity.getMarket().getSupplyPrice(commodity.getId(), 1,
true) * (1f + pricePercent / 100f) + priceFlat);
141 testDemandPrice = Math.round(commodity.getMarket().getDemandPrice(commodity.getId(), 1,
true) * (1f + pricePercent / 100f) + priceFlat);
144 if (stats.isSupplyPriceSignificant(commodity, Misc.getRounded(testSupplyPrice))) {
145 type = PriceType.CHEAP;
146 }
else if (stats.isDemandPriceSignificant(commodity, Misc.getRounded(testDemandPrice))) {
147 type = PriceType.EXPENSIVE;
149 type = PriceType.NORMAL;
173 if ((
getType() == PriceType.CHEAP)
174 && commodity.getStockpile() < 100)
return false;
176 if ((
getType() == PriceType.NORMAL)
177 && commodity.getStockpile() + commodity.getDemand().getDemandValue() < 100)
return false;
179 if (
getType() == PriceType.EXPENSIVE && commodity.getDemand().getDemandValue() < 100)
return false;