- add ch_runtime_content.py/.gd: patched pointers require real level/zone; unmappable families (C004/C050/C053/C054) raise instead of guessing - remove field_map.counts silent product-literal fallback in ch_authority.py - label frozen launch fixture source; add disposition map and G5 gate - keep UI, battle HUD, locale, OPEN items and gameplay literals untouched G3 12/12, G4 9 families/160 pointers/open 8, G5 92 dispositions PASS
119 lines
3.1 KiB
GDScript
119 lines
3.1 KiB
GDScript
class_name LaunchContent
|
|
extends RefCounted
|
|
|
|
## Read-only view of the frozen P3a launch content file.
|
|
##
|
|
## All ids, waves and rewards come from the data pack via
|
|
## `tools/build_launch_content.py`; this class only indexes them.
|
|
|
|
const CONTENT_PATH := "res://data/mvp_launch_content.json"
|
|
|
|
## A5: the frozen P3a launch fixture is compatibility data, not the CH
|
|
## authority path. Call sites must be able to name its source explicitly.
|
|
const SOURCE := "legacy_fixture:mvp_launch_content.json"
|
|
|
|
static func source() -> String:
|
|
return SOURCE
|
|
|
|
static var _cache: Dictionary = {}
|
|
|
|
|
|
static func content() -> Dictionary:
|
|
if not _cache.is_empty():
|
|
return _cache
|
|
var file := FileAccess.open(CONTENT_PATH, FileAccess.READ)
|
|
if file == null:
|
|
push_error("Launch content missing: %s" % CONTENT_PATH)
|
|
return {}
|
|
var parsed = JSON.parse_string(file.get_as_text())
|
|
file.close()
|
|
if not parsed is Dictionary:
|
|
return {}
|
|
_cache = parsed
|
|
return _cache
|
|
|
|
|
|
static func heroes() -> Array:
|
|
return content().get("heroes", [])
|
|
|
|
|
|
static func enemies() -> Array:
|
|
return content().get("enemies", [])
|
|
|
|
|
|
static func nodes() -> Array:
|
|
return content().get("nodes", [])
|
|
|
|
|
|
static func node(node_id: String) -> Dictionary:
|
|
for row in nodes():
|
|
if str(row.get("id", "")) == node_id:
|
|
return row
|
|
return {}
|
|
|
|
|
|
static func hero(hero_id: String) -> Dictionary:
|
|
for row in heroes():
|
|
if str(row.get("id", "")) == hero_id:
|
|
return row
|
|
return {}
|
|
|
|
|
|
static func enemy(enemy_id: String) -> Dictionary:
|
|
if str(enemy_id).begins_with("B-"):
|
|
return content().get("boss", {})
|
|
for row in enemies():
|
|
if str(row.get("id", "")) == enemy_id:
|
|
return row
|
|
return {}
|
|
|
|
|
|
static func node_ids() -> Array[String]:
|
|
var ids: Array[String] = []
|
|
for row in nodes():
|
|
ids.append(str(row.get("id", "")))
|
|
return ids
|
|
|
|
|
|
## Build a battle scenario for a node from its first wave.
|
|
## Later waves are handled by the game root as successive battles.
|
|
static func scenario_for_node(node_id: String, wave_index: int = 0) -> Dictionary:
|
|
var row := node(node_id)
|
|
if row.is_empty():
|
|
return {}
|
|
var waves: Array = row.get("waves", [])
|
|
if wave_index >= waves.size():
|
|
return {}
|
|
var enemy_ids: Array = waves[wave_index]
|
|
var scale := float(row.get("hp_scale", 1.0))
|
|
var scaled_enemies: Array = []
|
|
var enemy_specs: Dictionary = {}
|
|
for enemy_id in enemy_ids:
|
|
var id := str(enemy_id)
|
|
scaled_enemies.append(id)
|
|
var spec := enemy(id)
|
|
enemy_specs[id] = {
|
|
"hp": float(spec.get("hp", spec.get("base_hp", 0.0))),
|
|
"armor": float(spec.get("armor", 1.0)),
|
|
"shield": float(spec.get("shield_max", 0.0)),
|
|
"weak_tag": str(spec.get("weak_tag", "")),
|
|
"rebuild_at": spec.get("rebuild_at", []),
|
|
"rebuild_amount": float(spec.get("rebuild_amount", 0.0)),
|
|
}
|
|
var visible: Array = []
|
|
for hero_row in heroes():
|
|
visible.append(str(hero_row.get("id", "")))
|
|
return {
|
|
"id": node_id,
|
|
"node_id": node_id,
|
|
"reward_id": str(row.get("reward_id", "")),
|
|
"wave_index": wave_index,
|
|
"mode": "auto" if str(row.get("type", "")) == "normal" else "semi",
|
|
"enemy_ids": scaled_enemies,
|
|
"enemy_specs": enemy_specs,
|
|
"visible_hero_ids": visible,
|
|
"input_events": [],
|
|
"timeout_seconds": float(row.get("timeout_sec", 45.0)),
|
|
"hp_scale": scale,
|
|
}
|