feat(ai): ✨ add unit catalog builder for tactical state
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
b5d67f77ff
commit
ec6387c2c7
1 changed files with 32 additions and 0 deletions
|
|
@ -220,9 +220,41 @@ static func _build_tactical_state(focal: RefCounted) -> Dictionary:
|
|||
"turn": int(GameState.turn_number),
|
||||
"map": {"width": width, "height": height, "tiles": tiles},
|
||||
"players": players,
|
||||
"unit_catalog": _build_unit_catalog(),
|
||||
}
|
||||
|
||||
|
||||
static func _build_unit_catalog() -> Array:
|
||||
# Emit the unit catalog for `tactical::production::pick_best_melee` (p0-39).
|
||||
# Populated from DataLoader's unit pack; tier-2+ units carry
|
||||
# `tech_required` which the Rust helper filters against each player's
|
||||
# `researched_techs`. All unit kinds included — Rust filters by
|
||||
# `unit_type == "military"` at selection time.
|
||||
var out: Array = []
|
||||
var data: Dictionary = DataLoader.get_data("units")
|
||||
if data == null:
|
||||
return out
|
||||
for uid: String in data.keys():
|
||||
var entry: Dictionary = data.get(uid, {})
|
||||
if entry == null or entry.is_empty():
|
||||
continue
|
||||
var tier_raw: int = int(entry.get("tier", 1))
|
||||
var tech_raw: String = String(entry.get("tech_required", ""))
|
||||
var tech_dict_val: Dictionary = {}
|
||||
if tech_raw.is_empty():
|
||||
tech_dict_val = {"tech_required": null}
|
||||
else:
|
||||
tech_dict_val = {"tech_required": tech_raw}
|
||||
var item: Dictionary = {
|
||||
"id": String(entry.get("id", uid)),
|
||||
"tier": tier_raw,
|
||||
"unit_type": String(entry.get("unit_type", "military")),
|
||||
}
|
||||
item.merge(tech_dict_val)
|
||||
out.append(item)
|
||||
return out
|
||||
|
||||
|
||||
static func _tile_to_dict(game_map: RefCounted, col: int, row: int) -> Dictionary:
|
||||
var tile: Resource = game_map.get_tile(Vector2i(col, row))
|
||||
if tile == null:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue