fix 2
This commit is contained in:
@@ -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'):
|
||||||
target_building = b_name
|
# A missing_dependencies object that is empty means dependencies are met
|
||||||
break
|
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:
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user