Files
windroost/p2_godot_sample/scripts/ch_authority_probe.gd
T

46 lines
1.7 KiB
GDScript

extends SceneTree
## A4 minimal runtime probe: resolve authority refs inside the real Godot runtime.
## Emits machine-readable values for the Python G4 comparison gate.
const A := preload("res://scripts/ch_authority.gd")
const OUTPUT_PATH := "res://artifacts/ch_authority_gd.json"
func _init() -> void:
_run.call_deferred()
func _run() -> void:
var b: Dictionary = A.binding()
var results: Array = []
for zone in [1, 75, 140, 200]:
results.append({"ref": "monster_boss.hp_at_zone", "zone": zone,
"value": A.hp_at_zone(zone)})
results.append({"ref": "monster_boss.boss_hp_at_zone", "zone": zone,
"value": A.boss_hp_at_zone(zone)})
results.append({"ref": "monster_boss.gold_at_zone", "zone": zone,
"value": A.gold_at_zone(zone)})
for hero in [2, 4, 6]:
results.append({"ref": "hero_dps.base_dps_at_level", "hero_id": hero,
"level": 10, "value": A.base_dps_at_level(hero, 10)})
for id in [1, 2, 3, 5]:
results.append({"ref": "edicts.bonus_by_id", "id": id, "level": 3,
"value": A.outsider_bonus(id, 3)})
var report := {
"source_bound": A.source_bound(),
"families": int(b.get("applied_families", []).size()),
"open_items": (b.get("open_items", []) as Array).size(),
"open_ids": A.OPEN_IDS,
"results": results,
}
var dir := ProjectSettings.globalize_path("res://artifacts")
DirAccess.make_dir_recursive_absolute(dir)
var f := FileAccess.open(OUTPUT_PATH, FileAccess.WRITE)
if f != null:
f.store_string(JSON.stringify(report, "\t", true))
f.close()
print("CH_AUTHORITY_GD source_bound=%s families=%d open=%d cases=%d" % [
str(report["source_bound"]), report["families"], report["open_items"], results.size()])
quit(0 if report["source_bound"] else 1)