feat(management): Implement Golden Age bonuses for production and gold income in turn_processor.gd and add test coverage in auto_play.gd

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-13 06:11:25 -07:00
parent 63a5cbbff2
commit 5b0a3c7e62
2 changed files with 23 additions and 3 deletions

View file

@ -12,7 +12,7 @@ var _frame: int = 0
var _state: String = "wait_main_menu"
var _output_dir: String = "/tmp"
var _turn_count: int = 0
var _max_turns: int = 500
var _max_turns: int = 300
var _victory: bool = false
var _world_map: Node = null
var _founded_city: bool = false
@ -193,10 +193,24 @@ func _play_turn() -> void:
var gold: int = player.get("gold") if player.get("gold") != null else 0
var techs: int = player.researched_techs.size()
var tiles: int = 0
var buildings: int = 0
for c: Variant in player.cities:
tiles += c.owned_tiles.size()
print(" Turn %d: %d units, %d cities, h=%d, g=%d, t=%d, tiles=%d" % [
_turn_count, unit_count, city_count, happiness, gold, techs, tiles
buildings += c.buildings.size()
var golden: bool = player.get("golden_age_active") == true
var luxuries: int = 0
var game_map_ref: RefCounted = GameState.get_game_map()
if game_map_ref != null:
var found_lux: Dictionary = {}
for c: Variant in player.cities:
for tp: Vector2i in c.owned_tiles:
var tl: Resource = game_map_ref.get_tile(tp)
if tl != null and tl.resource_id != "" and tl.resource_id not in found_lux:
found_lux[tl.resource_id] = true
luxuries = found_lux.size()
print(" Turn %d: u=%d c=%d h=%d g=%d t=%d tiles=%d b=%d lux=%d ga=%s" % [
_turn_count, unit_count, city_count, happiness, gold, techs, tiles,
buildings, luxuries, "Y" if golden else "N"
])
# 0. Pick research if idle

View file

@ -67,6 +67,9 @@ func _process_production(player: RefCounted) -> void: # Player
# Unhappy penalty: -25% production when happiness < 0
if player.happiness < 0:
prod_modifier *= 0.75
# Golden Age: +20% production
if player.golden_age_active:
prod_modifier *= 1.2
for city_ref: RefCounted in player.cities:
if not city_ref is CityScript:
@ -329,6 +332,9 @@ func _process_economy(player: RefCounted, game_map: RefCounted) -> void: # Play
var tile_json: String = BuildableHelperScript.build_tile_yields_json(c, game_map)
var yields: Dictionary = c.get_yields(tile_json)
income += int(yields.get("gold", 0))
# Golden Age: +20% gold income
if player.golden_age_active:
income = int(income * 1.2)
# Unit upkeep: 1 gold per military unit
var upkeep: int = 0
for u: Variant in player.units: