fix(game): 🐛 lint fixes applied auto_play.gd
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
758126d75f
commit
6c0f108bc8
3 changed files with 72 additions and 17 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"generated_at": "2026-05-09T19:50:42Z",
|
||||
"generated_at": "2026-05-09T19:57:18Z",
|
||||
"totals": {
|
||||
"done": 178,
|
||||
"in_progress": 1,
|
||||
|
|
|
|||
|
|
@ -86,3 +86,24 @@ removal reduces that category.
|
|||
|
||||
- Full file-splitting of deferred files (tracked per-file in future objectives)
|
||||
- Refactoring auto_play.gd (blocked on p0-26 Rust port)
|
||||
|
||||
## 2026-05-09 inline progress
|
||||
|
||||
Reduced violation count from 56 → 41 (15 fixed) without specialist dispatch:
|
||||
|
||||
- `auto_play.gd` 14 → 1 violation (only `max-file-lines` remains — needs file split, blocked on p0-26 Rust port).
|
||||
- Mixed-tabs-and-spaces fix at lines 867-868 (tab+space→tab indent).
|
||||
- Duplicated-load fix: `combat_resolver.gd` was loaded twice via `load()` in
|
||||
attack-adjacent-enemy + attack-adjacent-city paths; promoted to a single
|
||||
`const CombatResolverScript: GDScript = preload(...)` at the top.
|
||||
- 9 max-line-length fixes across `auto_play.gd` (mechanical: split print
|
||||
args across lines, hoist inline ternaries to multi-line if blocks, extract
|
||||
long array literals into local vars).
|
||||
|
||||
Remaining 41 violations break down: 22 max-line-length (mechanical),
|
||||
10 max-file-lines (10 files exceed 500 lines — each needs a refactor),
|
||||
6 class-definitions-order (audio_manager.gd / tech_web.gd / culture_web.gd),
|
||||
1 no-elif-return (unit_renderer.gd:380), 1 load-constant-name,
|
||||
1 function-variable-name. The mechanical max-line-length fixes can land in
|
||||
another inline pass; the 10 max-file-lines blockers need per-file
|
||||
extraction objectives or a project-wide max-file-lines lint relaxation.
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ const ImprovementManagerScript = preload(
|
|||
const HappinessScript = preload("res://engine/src/modules/empire/happiness.gd")
|
||||
const ItemSystemScript = preload("res://engine/src/modules/management/item_system.gd")
|
||||
const SaveManagerScript = preload("res://engine/src/core/save_manager.gd")
|
||||
const CombatResolverScript: GDScript = preload(
|
||||
"res://engine/src/modules/combat/combat_resolver.gd"
|
||||
)
|
||||
|
||||
var _improvement_manager: RefCounted = null
|
||||
|
||||
|
|
@ -432,7 +435,9 @@ func _on_improvement_completed(tile: Vector2i, type: String) -> void:
|
|||
|
||||
func _on_city_building_completed(city: Variant, building_id: String) -> void:
|
||||
var owner_idx: int = int(city.owner) if city != null and city.get("owner") != null else -1
|
||||
var city_name: String = str(city.city_name) if city != null and city.get("city_name") != null else ""
|
||||
var city_name: String = ""
|
||||
if city != null and city.get("city_name") != null:
|
||||
city_name = str(city.city_name)
|
||||
_append_event({
|
||||
"type": "city_building_completed",
|
||||
"player": owner_idx,
|
||||
|
|
@ -481,7 +486,10 @@ func _on_victory(player_index: int, victory_type: String) -> void:
|
|||
# turn_stats line from _outcome, and without this override the line
|
||||
# persists as "in_progress" even though a winner was declared.
|
||||
_outcome = "victory"
|
||||
print("AutoPlay: VICTORY! Player %d wins via %s on turn %d" % [player_index, victory_type, _turn_count])
|
||||
print(
|
||||
"AutoPlay: VICTORY! Player %d wins via %s on turn %d"
|
||||
% [player_index, victory_type, _turn_count]
|
||||
)
|
||||
_append_event({
|
||||
"type": "victory",
|
||||
"player": player_index,
|
||||
|
|
@ -647,7 +655,10 @@ func _process(_delta: float) -> void:
|
|||
var prev_turn: int = GameState.turn_number
|
||||
if prev_turn < _max_turns:
|
||||
GameState.turn_number = _max_turns
|
||||
print("AutoPlay: invoking score-victory fallback (turn_number %d→%d, limit %d)" % [prev_turn, GameState.turn_number, _max_turns])
|
||||
print(
|
||||
"AutoPlay: invoking score-victory fallback (turn_number %d→%d, limit %d)"
|
||||
% [prev_turn, GameState.turn_number, _max_turns]
|
||||
)
|
||||
vm.check_all(GameState.get_game_map())
|
||||
print("AutoPlay: fallback complete, victory=%s winner=%d" % [_victory, _victory_winner])
|
||||
_screenshot("final_turn_%03d" % _turn_count)
|
||||
|
|
@ -1036,7 +1047,9 @@ 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
|
||||
var city_pos: Vector2i = Vector2i.ZERO
|
||||
if not player.cities.is_empty():
|
||||
city_pos = player.cities[0].position
|
||||
|
||||
var intel: Dictionary = _get_enemy_intel()
|
||||
var enemy_mil: int = intel.get("military", 0)
|
||||
|
|
@ -1141,7 +1154,10 @@ func _play_turn() -> void:
|
|||
for u: Variant in units_snapshot:
|
||||
if u.is_alive() and u.get("can_found_city") != true:
|
||||
unit_positions.append(str(u.position))
|
||||
print(" ATTACK: %d warriors at %s -> target %s" % [military_count, ", ".join(unit_positions), target])
|
||||
print(
|
||||
" ATTACK: %d warriors at %s -> target %s"
|
||||
% [military_count, ", ".join(unit_positions), target]
|
||||
)
|
||||
for u: Variant in units_snapshot:
|
||||
if not u.is_alive() or u.movement_remaining <= 0:
|
||||
continue
|
||||
|
|
@ -1383,7 +1399,9 @@ func _score_site(pos: Vector2i, game_map: RefCounted) -> float:
|
|||
var y: Dictionary = tile.get_yields(-1)
|
||||
score += float(y.get("food", 0)) * 2.0 + float(y.get("production", 0)) * 1.5
|
||||
for n: Vector2i in HexUtilsScript.get_neighbors(pos):
|
||||
var norm: Vector2i = HexUtilsScript.normalize_position(n, game_map.width, game_map.height, game_map.wrap_mode)
|
||||
var norm: Vector2i = HexUtilsScript.normalize_position(
|
||||
n, game_map.width, game_map.height, game_map.wrap_mode
|
||||
)
|
||||
var nt: Resource = game_map.get_tile(norm)
|
||||
if nt == null:
|
||||
continue
|
||||
|
|
@ -1440,7 +1458,10 @@ func _manage_production(city: Variant) -> void:
|
|||
if _turn_count <= 5 or _turn_count % 20 == 0:
|
||||
var q_size: int = city.production_queue.size()
|
||||
var item: String = city.production_queue[0].get("id", "") if q_size > 0 else "none"
|
||||
print(" [PROD] %s: queue=%d item=%s progress=%d" % [city.city_name, q_size, item, city.production_progress])
|
||||
print(
|
||||
" [PROD] %s: queue=%d item=%s progress=%d"
|
||||
% [city.city_name, q_size, item, city.production_progress]
|
||||
)
|
||||
if city.production_queue.is_empty():
|
||||
var gs: Node = get_node("/root/GameState")
|
||||
var player: RefCounted = gs.get_current_player()
|
||||
|
|
@ -1463,7 +1484,12 @@ func _manage_production(city: Variant) -> void:
|
|||
# tier_peak/peak_unit_tier across 5-seed validation. Filler-only override
|
||||
# preserves the production chain while still firing wonders.
|
||||
var low_pri_filler: Array = ["warrior", "monument"]
|
||||
if (built in low_pri_filler) and city_count >= 1 and Array(city.buildings).size() >= 3 and city.has_building("forge"):
|
||||
if (
|
||||
(built in low_pri_filler)
|
||||
and city_count >= 1
|
||||
and Array(city.buildings).size() >= 3
|
||||
and city.has_building("forge")
|
||||
):
|
||||
var existing: Array = Array(city.buildings)
|
||||
var has_wonder: bool = false
|
||||
for bld_id: String in existing:
|
||||
|
|
@ -1586,7 +1612,10 @@ func _next_building(city: Variant, player: Variant, city_count: int, has_founder
|
|||
var tl: Resource = gm.get_tile(tp) if gm != null else null
|
||||
if tl == null:
|
||||
continue
|
||||
if str(tl.get("improvement")) == "" and tl.biome_id in ["grassland", "plains", "forest", "boreal_forest", "jungle", "tundra"]:
|
||||
var biome_ok: bool = tl.biome_id in [
|
||||
"grassland", "plains", "forest", "boreal_forest", "jungle", "tundra"
|
||||
]
|
||||
if str(tl.get("improvement")) == "" and biome_ok:
|
||||
unimproved_food += 1
|
||||
for tp2: Vector2i in city.get_worked_tiles():
|
||||
var tl2: Resource = gm.get_tile(tp2) if gm != null else null
|
||||
|
|
@ -1692,7 +1721,8 @@ func _next_building(city: Variant, player: Variant, city_count: int, has_founder
|
|||
continue
|
||||
var era_w: int = int(wb.get("era", 1))
|
||||
# Score band: era 1 wonder ~ 5.5, era 5 wonder ~ 11.5, era 10 wonder ~ 19
|
||||
# (× 0.4-1.6 personality) — competitive with cavalry (5) → ironwarden (8) → forge_titan (12) → mithril_vanguard (18).
|
||||
# (× 0.4-1.6 personality) — competitive with cavalry (5) →
|
||||
# ironwarden (8) → forge_titan (12) → mithril_vanguard (18).
|
||||
scores[wid] = (4.0 + era_w * 1.5) * w_axis
|
||||
|
||||
# Log top-3 each time production is selected — emergent strategy visibility
|
||||
|
|
@ -2099,9 +2129,11 @@ func _try_attack_adjacent(unit: Variant, game_map: RefCounted) -> void:
|
|||
continue
|
||||
var dist: int = HexUtilsScript.hex_distance(unit.position, enemy.position)
|
||||
if dist <= 1:
|
||||
print(" ATTACKING: %s at %s -> enemy at %s (dist=%d)" % [unit.type_id, unit.position, enemy.position, dist])
|
||||
var resolver_script: GDScript = load("res://engine/src/modules/combat/combat_resolver.gd")
|
||||
var resolver: RefCounted = resolver_script.new()
|
||||
print(
|
||||
" ATTACKING: %s at %s -> enemy at %s (dist=%d)"
|
||||
% [unit.type_id, unit.position, enemy.position, dist]
|
||||
)
|
||||
var resolver: RefCounted = CombatResolverScript.new()
|
||||
resolver.resolve(unit, enemy, game_map, all_units)
|
||||
unit.movement_remaining = 0
|
||||
return
|
||||
|
|
@ -2113,9 +2145,11 @@ func _try_attack_adjacent(unit: Variant, game_map: RefCounted) -> void:
|
|||
for c: Variant in p.cities:
|
||||
var dist: int = HexUtilsScript.hex_distance(unit.position, c.position)
|
||||
if dist <= 1:
|
||||
print(" ATTACKING CITY: %s at %s -> city at %s (dist=%d)" % [unit.type_id, unit.position, c.position, dist])
|
||||
var resolver_script: GDScript = load("res://engine/src/modules/combat/combat_resolver.gd")
|
||||
var resolver: RefCounted = resolver_script.new()
|
||||
print(
|
||||
" ATTACKING CITY: %s at %s -> city at %s (dist=%d)"
|
||||
% [unit.type_id, unit.position, c.position, dist]
|
||||
)
|
||||
var resolver: RefCounted = CombatResolverScript.new()
|
||||
resolver.resolve(unit, c, game_map, all_units)
|
||||
unit.movement_remaining = 0
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue