This commit is contained in:
2026-05-02 00:48:37 +03:00
parent 1cb5dca3c2
commit c9e6522f12

View File

@@ -83,19 +83,31 @@ def evaluate_blueprints(conn):
if incomplete_buildings: if incomplete_buildings:
phase_incomplete = True phase_incomplete = True
waiting_for_resources = False
# Try to find a building in this phase that we can upgrade right now # Try to find a building in this phase that we can upgrade right now
for b_name in incomplete_buildings: for b_name in incomplete_buildings:
b_info = build_data.get(b_name) b_info = build_data.get(b_name)
if b_info and b_info.get('can_upgrade') == True: if b_info and not b_info.get('has_max_level'):
# A missing_dependencies object that is empty means dependencies are met
deps = b_info.get('missing_dependencies')
if not deps:
if b_info.get('enough_resources') != False:
target_building = b_name target_building = b_name
break break
else:
waiting_for_resources = True
if target_building: if target_building:
# Found something we can build right now # Found something we can build right now
break break
elif waiting_for_resources:
# We meet the dependencies for at least one building, but lack resources.
# We should wait for resources to accumulate instead of spending them on future phases.
break
else: else:
# Nothing in this phase can be built (missing dependencies, population, or resources) # ALL incomplete buildings in this phase are blocked by missing dependencies.
# We look ahead up to 2 additional phases to unblock it # We look ahead up to 2 additional phases to build the required dependencies.
blocked_phases += 1 blocked_phases += 1
if blocked_phases > 2: if blocked_phases > 2:
break break