Files
windroost/p2_godot_sample/scripts/oath_rules_ui_test.gd
T
wushenghua 40c8f86f1e feat: oaths become distinct real rules (stage G, final flat system)
Continued PRODUCTION/51. Oaths were flat "+4% storm/+2% roster each":

- oath_rules.py / .gd: 26 oaths -> 18 distinct combat rules (crit/elemental
  DoT/execute/armor-break/combo/energy/cooldown/ultimate/summon/cleanse/click...)
  + 8 honest out-of-combat meta rules. O14 scoped to ultimate only.
- hero_skill_loader gained active_oaths param (identity preserved); game_root
  injects profile.oaths on the live P3a path.
- test_oath_rules.py PASS 7 checks; check_oath_rules_parity.py PASS 9 cases
  python==gd; run_oath_rules_ui_test.sh PASS in real game_root (O03 adds 4
  poison effects/22 events, O13 cooldown x0.8, meta O09 no change).
- 3 new gates; full P2_CHECKS_PASS (88 gates), identity preserved.

ALL 7 STAGES COMPLETE (A-G). Every previously-flattened system now has real
differentiated mechanisms, dual-engine parity, focused/distinctness gates, and
live-runtime proof: skills, talents, edicts, enemy/boss mechanics, relics, oaths.
Achievements verified to already be genuinely differentiated. prototype/ untracked.
2026-11-19 14:27:13 +08:00

101 lines
3.6 KiB
GDScript

extends SceneTree
## Real-runtime Stage G proof: oaths in the live game shell produce distinct
## skill rewrites (elemental DoT, cooldown, meta untouched).
const OUTPUT_PATH := "res://artifacts/oath_rules_ui_test.json"
const NODE := "R1-C01-N01"
var _problems: Array = []
var _records: Array = []
func _init() -> void:
_run.call_deferred()
func _run_battle(shell: GameRoot, oaths: Dictionary) -> Dictionary:
var profile := shell.get_profile()
profile["gold"] = 0
profile["crystal"] = 0
profile["hero_levels"] = {}
profile["unlocked_heroes"] = ["H05"]
profile["completed_nodes"] = []
profile["claimed_rewards"] = []
profile["talents"] = {}
profile["edicts"] = {}
profile["relics"] = {}
profile["oaths"] = oaths.duplicate()
shell.start_node(NODE)
await process_frame
await process_frame
var battle := shell.get_battle()
if battle == null:
_problems.append("no battle instance")
return {}
var effects: Array = []
var intervals: Array = []
for s in battle.state.get("skill_rt", {}).get("skills", []):
for e in (s as Dictionary).get("effects", []):
effects.append(str((e as Dictionary).get("type", "")))
intervals.append(float((s as Dictionary).get("interval", 0.0)))
battle.set_process(false)
var guard := 0
while not battle.finished and guard < 600:
battle.advance_ticks(1)
guard += 1
var poison_ev := 0
for e in battle.state.get("event_log", []):
if str((e as Dictionary).get("type", "")) == "skill_effect" and str((e as Dictionary).get("primitive", "")) == "poison":
poison_ev += 1
return {"effects": effects, "intervals": intervals, "poison_events": poison_ev,
"result": str(battle.state.get("result", ""))}
func _run() -> void:
var shell := load("res://scenes/game_root.tscn").instantiate() as GameRoot
root.add_child(shell)
await process_frame
await process_frame
var off := await _run_battle(shell, {})
var ele := await _run_battle(shell, {"O03": true}) # 元素: poison
var cd := await _run_battle(shell, {"O13": true}) # 冷却: interval x0.8
var meta := await _run_battle(shell, {"O09": true}) # meta: no change
_records.append({"mode": "off", "data": off})
_records.append({"mode": "O03_element", "data": ele})
_records.append({"mode": "O13_cooldown", "data": cd})
_records.append({"mode": "O09_meta", "data": meta})
if off.is_empty() or ele.is_empty() or cd.is_empty() or meta.is_empty():
_problems.append("missing battle result")
else:
if ele["poison_events"] <= off["poison_events"]:
_problems.append("O03 must add poison events: off=%d element=%d" % [off["poison_events"], ele["poison_events"]])
var off_max := 0.0
var cd_max := 0.0
for x in off["intervals"]:
off_max = maxf(off_max, float(x))
for x in cd["intervals"]:
cd_max = maxf(cd_max, float(x))
if cd_max >= off_max:
_problems.append("O13 must shorten intervals: off=%f cd=%f" % [off_max, cd_max])
if meta["intervals"] != off["intervals"] or meta["effects"] != off["effects"]:
_problems.append("meta oath O09 must not alter combat")
var payload := {"records": _records, "problems": _problems}
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(payload, "\t", true))
f.close()
for rec in _records:
print("OATH_UI %s %s" % [rec["mode"], JSON.stringify(rec["data"])])
if _problems.is_empty():
print("OATH_UI_PASS oaths give distinct rules in real runtime")
else:
print("OATH_UI_FAIL %d problem(s)" % _problems.size())
for p in _problems:
print(" " + p)
quit(0 if _problems.is_empty() else 1)