class_name ChRuntimeContent extends RefCounted ## A5 authority-first runtime accessors (GDScript mirror of ## tools/fullgame/ch_runtime_content.py, verified by the G5 parity gate). ## ## A patched pointer is served by ch_authority.gd ONLY with real dynamic ## context (level / zone). Missing context or an unmappable CH field pushes an ## error and returns NAN -- it never falls back to a product literal or a ## guessed value. Legacy-fixture rows are labelled with an explicit source. const PRODUCT_SOURCE := "full_game_content.json" const LEGACY_SOURCE := "legacy_fixture:mvp_launch_content.json" const CONTENT_PATH := "res://data/full_game_content.json" const ChAuthority = preload("res://scripts/ch_authority.gd") const PATCHED := { "hero base_dps placeholder": ["/heroes/0/base_dps", "/heroes/3/base_dps"], "enemy base_hp placeholder": ["/enemies/0/base_hp"], "boss base_hp placeholder": ["/bosses/0/base_hp"], "node gold placeholder": [ "/nodes/0/gold", "/nodes/10/gold", "/nodes/20/gold", "/nodes/30/gold", "/nodes/40/gold", "/nodes/50/gold", "/nodes/60/gold", "/nodes/70/gold", "/nodes/80/gold", "/nodes/90/gold", "/nodes/100/gold", "/nodes/110/gold", "/events/12/choices/0/gold", "/events/13/choices/0/gold", "/events/14/choices/0/gold", "/events/15/choices/0/gold", "/events/16/choices/0/gold", "/events/17/choices/0/gold", "/events/18/choices/0/gold", "/events/19/choices/0/gold", "/events/20/choices/0/gold", "/events/21/choices/0/gold", "/events/22/choices/0/gold", "/events/23/choices/0/gold", ] } static func _fail(why: String) -> float: push_error("CH_RUNTIME_CONTENT BLOCKED: " + why) return NAN static func source_of(row: Dictionary) -> String: return str(row.get("source", PRODUCT_SOURCE)) static func tag_source(row: Dictionary, source: String) -> Dictionary: var out := row.duplicate() out["source"] = source return out static func _index(kind: String, row: Dictionary) -> int: if source_of(row) != PRODUCT_SOURCE: return -1 var f := FileAccess.open(CONTENT_PATH, FileAccess.READ) if f == null: return -1 var parsed = JSON.parse_string(f.get_as_text()) f.close() if not parsed is Dictionary: return -1 var rows: Array = (parsed as Dictionary).get(kind, []) as Array for i in rows.size(): if str((rows[i] as Dictionary).get("id", "")) == str(row.get("id", "")): return i return -1 static func hero_base_dps(row: Dictionary, level: int = -1) -> float: var idx := _index("heroes", row) var ptr := "/heroes/%d/base_dps" % idx if source_of(row) == PRODUCT_SOURCE and (PATCHED["hero base_dps placeholder"] as Array).has(ptr): if level <= 0: return _fail("hero level context required for %s (no guessed value)" % ptr) return ChAuthority.base_dps_at_level(idx + 1, level) return float(row.get("base_dps", 0.0)) static func enemy_base_hp(row: Dictionary, zone: int = -1) -> float: var idx := _index("enemies", row) var ptr := "/enemies/%d/base_hp" % idx if source_of(row) == PRODUCT_SOURCE and (PATCHED["enemy base_hp placeholder"] as Array).has(ptr): if zone <= 0: return _fail("enemy zone context required for %s (no guessed value)" % ptr) return ChAuthority.hp_at_zone(zone) return float(row.get("base_hp", 0.0)) static func boss_base_hp(row: Dictionary, zone: int = -1) -> float: var idx := _index("bosses", row) var ptr := "/bosses/%d/base_hp" % idx if source_of(row) == PRODUCT_SOURCE and (PATCHED["boss base_hp placeholder"] as Array).has(ptr): if zone <= 0: return _fail("boss zone context required for %s (no guessed value)" % ptr) return ChAuthority.boss_hp_at_zone(zone) return float(row.get("base_hp", 0.0)) static func node_gold(row: Dictionary, zone: int = -1) -> int: var idx := _index("nodes", row) var ptr := "/nodes/%d/gold" % idx if source_of(row) == PRODUCT_SOURCE and (PATCHED["node gold placeholder"] as Array).has(ptr): if zone <= 0: push_error("CH_RUNTIME_CONTENT BLOCKED: node zone context required for %s" % ptr) return -1 return int(ChAuthority.gold_at_zone(zone)) return int(row.get("gold", 0)) static func stat_value(_row: Dictionary, _kind: String = "") -> float: return _fail("C050 ancient/outsider id+level+family absent from product rows") static func counts() -> Dictionary: push_error("CH_RUNTIME_CONTENT BLOCKED: C004 field_map.counts has no authority key") return {} static func relic_rows() -> Array: push_error("CH_RUNTIME_CONTENT BLOCKED: C053 has global gild constants only") return [] static func partner_rows() -> Array: push_error("CH_RUNTIME_CONTENT BLOCKED: C054 has global merc constants only") return []