feat(management): Add culture processing logic to enable turn order and game mechanics based on cultural factors

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-14 16:32:27 -07:00
parent 0eff2bbdca
commit 6d13d6b738

View file

@ -224,6 +224,9 @@ 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
@ -383,9 +386,13 @@ func _process_economy(player: RefCounted, game_map: RefCounted) -> void: # Play
var net: int = income - upkeep
player.gold_per_turn = net
player.gold += net
# Disband units if deeply bankrupt (Civ5-style: allow short-term deficit)
# Only disband at -10 gold or below, giving time to recover
if player.gold < -10 and not player.units.is_empty():
# Disband units if deeply bankrupt (Civ5-style: allow short-term deficit).
# Tolerance scales with tech progress as a proxy for era — early game allows
# ~-5 gold, by mid-game tolerates -20, late game -40. This lets the player
# recover via building marketplace/barter without instant disbanding.
var tech_count: int = player.researched_techs.size() if player.researched_techs != null else 0
var deficit_floor: int = -maxi(5, tech_count * 3)
if player.gold < deficit_floor and not player.units.is_empty():
var disbanded: RefCounted = null
for u: Variant in player.units:
if u != null and u.is_alive() and u.get("can_found_city") != true:
@ -416,6 +423,11 @@ func _process_culture(player: RefCounted, game_map: RefCounted) -> void:
var candidates_json: String = _build_border_candidates_json(c, game_map, player)
var claimed: Vector2i = c.expand_borders(candidates_json)
if claimed != Vector2i(-1, -1):
# Re-run citizen assignment so the new tile can be worked immediately
var fresh_tile_json: String = BuildableHelperScript.build_tile_yields_json(
c, game_map
)
c.auto_assign_citizens(fresh_tile_json)
var tile: Resource = game_map.get_tile(claimed)
if tile != null:
tile.owner = player.index