From c9e6522f1282a59f0f8739948091e6e880fea81b Mon Sep 17 00:00:00 2001 From: haunter Date: Sat, 2 May 2026 00:48:37 +0300 Subject: [PATCH] fix 2 --- blueprint_engine.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/blueprint_engine.py b/blueprint_engine.py index 1b9cec2..7d43e02 100644 --- a/blueprint_engine.py +++ b/blueprint_engine.py @@ -83,19 +83,31 @@ def evaluate_blueprints(conn): if incomplete_buildings: phase_incomplete = True + waiting_for_resources = False + # Try to find a building in this phase that we can upgrade right now for b_name in incomplete_buildings: b_info = build_data.get(b_name) - if b_info and b_info.get('can_upgrade') == True: - target_building = b_name - break + 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 + break + else: + waiting_for_resources = True if target_building: # Found something we can build right now 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: - # Nothing in this phase can be built (missing dependencies, population, or resources) - # We look ahead up to 2 additional phases to unblock it + # ALL incomplete buildings in this phase are blocked by missing dependencies. + # We look ahead up to 2 additional phases to build the required dependencies. blocked_phases += 1 if blocked_phases > 2: break