fix(@projects/@magic-civilization): 🐛 add food storage check in growth logic
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
dcbf38151a
commit
a04eb63595
2 changed files with 4 additions and 34 deletions
|
|
@ -630,8 +630,9 @@ func _play_turn() -> void:
|
|||
var tile_json: String = BuildableHelperScript.build_tile_yields_json(c, game_map)
|
||||
var cy: Dictionary = c.get_yields(tile_json)
|
||||
var food_surplus: float = float(cy.get("food", 0)) - float(c.population) * 2.0
|
||||
print(" [%s] pop=%d food=%+.1f prod=%.0f tiles=%d bld=%d" % [
|
||||
c.city_name, c.population, food_surplus,
|
||||
var food_stored: float = c.get_food_stored() if c.has_method("get_food_stored") else -1.0
|
||||
print(" [%s] pop=%d food=%+.1f stored=%.1f prod=%.0f tiles=%d bld=%d" % [
|
||||
c.city_name, c.population, food_surplus, food_stored,
|
||||
float(cy.get("production", 0)), c.owned_tiles.size(), c.buildings.size(),
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -224,42 +224,11 @@ func _process_growth(player: RefCounted) -> void: # Player
|
|||
continue
|
||||
var tile_json: String = BuildableHelperScript.build_tile_yields_json(c, game_map)
|
||||
var prev_pop: int = c.population
|
||||
# Small cities prioritize food growth; pop 4+ uses balanced Default focus
|
||||
if c.population < 4 and c.has_method("set_focus"):
|
||||
c.set_focus("food")
|
||||
c.process_growth(tile_json)
|
||||
if c.population != prev_pop:
|
||||
# Re-assign citizens to tiles after growth or starvation
|
||||
c.auto_assign_citizens(tile_json)
|
||||
if c.population > prev_pop:
|
||||
EventBus.city_grew.emit(c, c.population)
|
||||
else:
|
||||
EventBus.city_starved.emit(c, c.population)
|
||||
|
||||
|
||||
func _sum_city_building_effect(city: CityScript, effect_type: String) -> int:
|
||||
## Sum a building effect type for a single city (e.g., "production", "gold", "science").
|
||||
var total: int = 0
|
||||
for building_id: Variant in city.buildings:
|
||||
var bdata: Dictionary = DataLoader.get_building(str(building_id))
|
||||
if bdata.is_empty():
|
||||
continue
|
||||
for effect: Dictionary in bdata.get("effects", []):
|
||||
if effect.get("type", "") == effect_type:
|
||||
total += int(effect.get("value", 0))
|
||||
return total
|
||||
|
||||
|
||||
func _sum_city_building_effect_float(city: CityScript, effect_type: String) -> float:
|
||||
var total: float = 0.0
|
||||
for building_id: Variant in city.buildings:
|
||||
var bdata: Dictionary = DataLoader.get_building(str(building_id))
|
||||
if bdata.is_empty():
|
||||
continue
|
||||
for effect: Dictionary in bdata.get("effects", []):
|
||||
if effect.get("type", "") == effect_type:
|
||||
total += float(effect.get("value", 0))
|
||||
return total
|
||||
EventBus.city_grew.emit(c, c.population)
|
||||
|
||||
|
||||
func _sum_city_building_effect(city: CityScript, effect_type: String) -> int:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue