From 84de7082ecc6a22f40368fd9396497e482dee9e8 Mon Sep 17 00:00:00 2001 From: haunter Date: Sat, 2 May 2026 02:45:42 +0300 Subject: [PATCH] blue fix --- blueprint_engine.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/blueprint_engine.py b/blueprint_engine.py index 3d5a4ef..bdce7e0 100644 --- a/blueprint_engine.py +++ b/blueprint_engine.py @@ -136,7 +136,24 @@ def evaluate_blueprints(conn): continue has_max = b_info.get('has_max_level', False) deps = b_info.get('missing_dependencies') + + # Do not trust the frontend 'enough_resources' flag. Grepolis lazily loads this, + # so for background towns it is almost always stale (False). We calculate it manually! enough = b_info.get('enough_resources') + res = town.get('resources') + if res: + b_wood = b_info.get('wood', 0) + b_stone = b_info.get('stone', 0) + b_iron = b_info.get('iron', 0) + b_pop = b_info.get('pop', 0) + + enough = ( + res.get('wood', 0) >= b_wood and + res.get('stone', 0) >= b_stone and + res.get('iron', 0) >= b_iron and + res.get('population', 0) >= b_pop + ) + log.warning(f"[blueprint] {b_name}: has_max={has_max}, deps={deps}, enough_resources={enough}") if not has_max: