feat(auto-play): fortify warriors at city during build phase
Warriors now fortify at the city position (+2 def/turn, max +4) instead of sitting idle. This should help them survive enemy attacks while building up to the 4-unit threshold for the attack march. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1feeaccaec
commit
dd40a998df
1 changed files with 20 additions and 5 deletions
|
|
@ -205,6 +205,8 @@ func _play_turn() -> void:
|
|||
|
||||
var units_snapshot: Array = player.units.duplicate()
|
||||
|
||||
var city_pos: Vector2i = player.cities[0].position if not player.cities.is_empty() else Vector2i.ZERO
|
||||
|
||||
if military_count >= 4:
|
||||
# ATTACK PHASE: march all units toward nearest enemy city
|
||||
var target: Vector2i = _find_attack_target(player)
|
||||
|
|
@ -213,14 +215,27 @@ func _play_turn() -> void:
|
|||
print(" ATTACK: %d warriors marching to %s" % [military_count, target])
|
||||
for u: Variant in units_snapshot:
|
||||
if u.is_alive() and u.movement_remaining > 0 and u.get("can_found_city") != true:
|
||||
# Un-fortify before moving
|
||||
u.is_fortified = false
|
||||
u.fortified_turns = 0
|
||||
_move_toward(u, target, game_map)
|
||||
else:
|
||||
# BUILD PHASE: keep units at home, only scout explores
|
||||
# BUILD PHASE: fortify warriors at city, only scout explores
|
||||
for u: Variant in units_snapshot:
|
||||
if u.is_alive() and u.movement_remaining > 0:
|
||||
if u.type_id == "dwarf_scout":
|
||||
_explore(u, player, game_map)
|
||||
# Warriors stay at city for defense
|
||||
if not u.is_alive() or u.movement_remaining <= 0:
|
||||
continue
|
||||
if u.get("can_found_city") == true:
|
||||
continue
|
||||
if u.type_id == "dwarf_scout" and _turn_count <= 15:
|
||||
_explore(u, player, game_map)
|
||||
else:
|
||||
# Fortify at city for defense bonus
|
||||
if u.position == city_pos:
|
||||
u.is_fortified = true
|
||||
u.movement_remaining = 0
|
||||
else:
|
||||
# Move back to city
|
||||
_move_toward(u, city_pos, game_map)
|
||||
|
||||
|
||||
func _try_found_city(player: RefCounted, _game_map: RefCounted) -> void:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue