feat(scene): Update test cases in auto_play.gd to verify gold rush strategy logic

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-13 06:57:12 -07:00
parent 5f20be6c1d
commit 89f8ecb341

View file

@ -217,6 +217,26 @@ func _play_turn() -> void:
if player.researching.is_empty():
_pick_research(player)
# 0b. Gold rush-buy warriors when gold > 200 and we need military
var mil_pre: int = 0
for u_pre: RefCounted in player.units:
if u_pre.is_alive() and u_pre.get("can_found_city") != true:
mil_pre += 1
var rush_cost: int = 160 # 4x warrior production cost
while player.gold >= rush_cost and mil_pre < city_count * 2:
if not player.cities.is_empty():
var spawn_pos: Vector2i = player.cities[0].position
var unit_script: GDScript = load("res://engine/src/entities/unit.gd")
var new_unit: RefCounted = unit_script.new("warrior", player.index, spawn_pos)
new_unit.id = "rush_%d_%d" % [_turn_count, mil_pre]
new_unit.display_name = "Warrior"
player.units.append(new_unit)
var primary_layer: Dictionary = GameState.get_primary_layer()
primary_layer.get("units", []).append(new_unit)
player.gold -= rush_cost
mil_pre += 1
EventBus.unit_created.emit(new_unit, player.index)
# 1. Found city if we have a settler
if city_count == 0 or _has_settler(player):
_try_found_city(player, game_map)