diff --git a/scripts/main.gd b/scripts/main.gd index 2eebb25..10d77a3 100644 --- a/scripts/main.gd +++ b/scripts/main.gd @@ -18,6 +18,7 @@ const GoalReward := preload("res://scripts/goal_reward.gd") const RESOURCE_TRENDS := Constants.RESOURCE_TRENDS const ColonyStance := preload("res://scripts/colony_stance.gd") const TileRender := preload("res://scripts/tile_render.gd") +const WorkerCapLogic := preload("res://scripts/worker_cap_logic.gd") @onready var world_grid: GridContainer = %WorldGrid @@ -1060,23 +1061,14 @@ func should_bias_to_food_gathering() -> bool: return level == "low" or level == "starving" func get_worker_cap() -> int: - var cap := Constants.BASE_WORKER_CAP - for build in state.get("builds", []): - if bool(build.complete): - var kind := String(build.kind) - cap += int(Constants.WORKER_CAP_BONUSES.get(kind, 0)) - return cap + return WorkerCapLogic.calculate_worker_cap(state.get("builds", [])) # ── Recruit worker decision (issue #149, links to #133, #135) ───────────────── func can_recruit_worker() -> bool: """Return true if the colony has capacity for another worker.""" - if not state.has("workers"): - return true - var current: int = state.workers.size() - var worker_cap := get_worker_cap() - return current < worker_cap + return WorkerCapLogic.can_recruit(state.get("workers", []), state.get("builds", [])) func recruit_worker() -> void: