Deduct cost from warehouse
This commit is contained in:
@@ -124,6 +124,28 @@ public enum ForgeManager implements Runnable {
|
|||||||
workOrder.production_cost_total.putAll(workOrder.production_cost);
|
workOrder.production_cost_total.putAll(workOrder.production_cost);
|
||||||
workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce));
|
workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce));
|
||||||
|
|
||||||
|
// Deduct gold cost from building
|
||||||
|
|
||||||
|
int strongbox = workOrder.vendor.building.getStrongboxValue();
|
||||||
|
int overflow = strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD);
|
||||||
|
|
||||||
|
if (overflow > 1 || workOrder.production_cost_total.size() > 1) {
|
||||||
|
|
||||||
|
// Deduct total cost from warehouse
|
||||||
|
|
||||||
|
City city = workOrder.vendor.building.getCity();
|
||||||
|
|
||||||
|
if (city == null)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
Warehouse warehouse = workOrder.vendor.building.getCity().warehouse;
|
||||||
|
|
||||||
|
if (warehouse == null)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value));
|
||||||
|
}
|
||||||
|
|
||||||
// Create in-memory items and add to collections
|
// Create in-memory items and add to collections
|
||||||
|
|
||||||
forgeWorkerOrderBatch(workOrder);
|
forgeWorkerOrderBatch(workOrder);
|
||||||
|
|||||||
Reference in New Issue
Block a user