Refactor production logic to use state amounts; update calculate_max_producible function to accept default desired amount
This commit is contained in:
@@ -122,14 +122,14 @@ func produce_hs(entity_id: String, value: float) -> float:
|
||||
## @param entity - entity to produce
|
||||
## @param desired_amount - desired quantity
|
||||
## @return maximum producible amount considering all constraints
|
||||
func calculate_max_producible(entity: OwniverseEntity, desired_amount: float) -> float:
|
||||
func calculate_max_producible(entity: OwniverseEntity, desired_amount: float = 1.0E150) -> float:
|
||||
var max_producible: float = desired_amount
|
||||
|
||||
# Check cost constraints - resources consumed during production
|
||||
for cost_item in entity.cost:
|
||||
if entity.cost[cost_item] == 0:
|
||||
continue
|
||||
var available = current_amount.get(cost_item, 0.0)
|
||||
var available = state.amount.get(cost_item, 0.0)
|
||||
var max_from_cost = floorf(available / entity.cost[cost_item])
|
||||
max_producible = min(max_producible, max_from_cost)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user