139 lines
5.5 KiB
GDScript
139 lines
5.5 KiB
GDScript
extends SceneTree
|
|
|
|
const Content = preload("res://fg4/content_registry.gd")
|
|
|
|
var failures: Array[String] = []
|
|
var rejected_cases := 0
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
|
|
func run_test() -> void:
|
|
verify_combined_authority()
|
|
verify_rg03_rows_preserved()
|
|
verify_rg04_disclosures()
|
|
verify_negative_boundaries()
|
|
if failures.is_empty():
|
|
print("ABG_FG4_RG04_CONTENT_OK equipment=40 artifacts=8 enemies=12 bosses=2 contracts=2 markets=24 routes=72 clause_kinds=3 pressure_families=4 bilingual=true rg03_rows_unchanged=true bosses_executable=2 negative_cases=%d" % rejected_cases)
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func verify_combined_authority() -> void:
|
|
var first := Content.snapshot()
|
|
var second := Content.snapshot()
|
|
var validation := Content.validate(first)
|
|
expect(validation.ok, "combined graph validates: %s" % str(validation.errors))
|
|
expect(first == second, "combined snapshot is byte-identical")
|
|
expect(first.equipment.filter(func(row): return id_number(row.id) >= 121).size() == 40, "EQ-121..160 resolve")
|
|
expect(first.artifacts.filter(func(row): return id_number(row.id) >= 23).size() == 8, "AR-023..030 resolve")
|
|
expect(first.enemies.filter(func(row): return String(row.id).begins_with("EN-R4-")).size() == 12, "EN-R4-01..12 resolve")
|
|
expect(first.bosses.filter(func(row): return String(row.id).begins_with("BO-R4-")).size() == 2, "both RG-04 Bosses resolve")
|
|
expect(first.region4.id == "RG-04", "Quillroot Region resolves")
|
|
expect(first.contract3.id == "CTR-R4-01" and first.contract3.boss_id == "BO-R4-01", "first Quillroot Contract is exact")
|
|
expect(first.contract4.id == "CTR-R4-02" and first.contract4.boss_id == "BO-R4-02", "second Quillroot Contract is exact")
|
|
var bosses := Content.rows_by_id(first, "bosses")
|
|
expect(bosses["BO-R4-01"].executable and bosses["BO-R4-02"].executable, "both Quillroot Bosses are executable")
|
|
|
|
|
|
func verify_rg03_rows_preserved() -> void:
|
|
var raw = JSON.parse_string(FileAccess.get_file_as_string("res://fg4/catalog.json"))
|
|
var content := Content.snapshot()
|
|
expect(raw is Dictionary, "RG-03 raw authority loads")
|
|
if not raw is Dictionary:
|
|
return
|
|
for family in ["equipment", "artifacts", "enemies", "bosses"]:
|
|
var expected: Array = raw[family]
|
|
var actual: Array = content[family].slice(0, expected.size())
|
|
actual = actual.map(func(row): return without_enrichment(row))
|
|
expect(actual == expected, "%s RG-03 rows remain byte-equivalent" % family)
|
|
|
|
|
|
func verify_rg04_disclosures() -> void:
|
|
var content := Content.snapshot()
|
|
var clause_kinds := {}
|
|
var pressure_families := {}
|
|
var usage := {}
|
|
for enemy in content.enemies:
|
|
if String(enemy.id).begins_with("EN-R4-"):
|
|
usage[String(enemy.id)] = 0
|
|
for route_key in ["rg04_routes", "rg04_contract2_routes"]:
|
|
for route in content[route_key]:
|
|
clause_kinds[String(route.archive_clause.kind)] = true
|
|
pressure_families[String(route.copy_disclosure.pressure_family)] = true
|
|
expect(has_copy(route.archive_clause.obey_result), "%s has bilingual obey result" % route.id)
|
|
expect(has_copy(route.archive_clause.break_result), "%s has bilingual break result" % route.id)
|
|
expect(route.response_tags.size() >= 3, "%s has multiple rational responses" % route.id)
|
|
for enemy_id in route.enemy_ids:
|
|
usage[String(enemy_id)] += 1
|
|
expect(sorted_keys(clause_kinds) == ["alternate", "preserve", "repeat"], "all three clause kinds recur")
|
|
expect(sorted_keys(pressure_families) == ["clause", "cleanse_trap", "copy", "redirect"], "all four pressure families recur")
|
|
for enemy_id in usage:
|
|
expect(usage[enemy_id] >= 2, "%s appears in at least two authored routes" % enemy_id)
|
|
|
|
|
|
func verify_negative_boundaries() -> void:
|
|
var bad_source := Content.snapshot()
|
|
bad_source.rg04_source.prototype_catalog_sha256 = "wrong"
|
|
expect_rejected(bad_source, "RG-04 source drift")
|
|
var missing_translation := Content.snapshot()
|
|
missing_translation.equipment[40].effect.zh_CN = ""
|
|
expect_rejected(missing_translation, "missing RG-04 translation")
|
|
var disabled_boss := Content.snapshot()
|
|
disabled_boss.bosses[3].executable = false
|
|
expect_rejected(disabled_boss, "Redaction Hart execution disabled")
|
|
var bad_clause := Content.snapshot()
|
|
bad_clause.rg04_markets[0].archive_clause.kind = "ignore"
|
|
expect_rejected(bad_clause, "unknown archive clause")
|
|
var bad_copy := Content.snapshot()
|
|
bad_copy.rg04_contract2_markets[0].copy_disclosure.resolve_tick = 1
|
|
expect_rejected(bad_copy, "copy timing before warning")
|
|
var bad_reward := Content.snapshot()
|
|
bad_reward.rg04_routes[0].reward_coin += 1
|
|
expect_rejected(bad_reward, "RG-04 reward drift")
|
|
var foreign_enemy := Content.snapshot()
|
|
foreign_enemy.rg04_contract2_markets[0].enemy_sets[0][0] = "EN-R3-01"
|
|
expect_rejected(foreign_enemy, "foreign Region enemy")
|
|
|
|
|
|
func without_enrichment(row: Dictionary) -> Dictionary:
|
|
var result := row.duplicate(true)
|
|
result.erase("execution_key")
|
|
result.erase("mechanic_signature")
|
|
return result
|
|
|
|
|
|
func id_number(identifier: String) -> int:
|
|
return int(identifier.rsplit("-", false, 1)[-1])
|
|
|
|
|
|
func sorted_keys(values: Dictionary) -> Array:
|
|
var result: Array = values.keys()
|
|
result.sort()
|
|
return result
|
|
|
|
|
|
func has_copy(value) -> bool:
|
|
return (
|
|
value is Dictionary
|
|
and not String(value.get("en", "")).is_empty()
|
|
and not String(value.get("zh_CN", "")).is_empty()
|
|
)
|
|
|
|
|
|
func expect_rejected(content: Dictionary, label: String) -> void:
|
|
var rejected := not bool(Content.validate(content).ok)
|
|
expect(rejected, "%s rejects" % label)
|
|
if rejected:
|
|
rejected_cases += 1
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("FG-4 RG-04 content: %s" % message)
|