Continued FULL_GAME_GOAL. Closed the last L5 gap: design 11.4's five occasional interactions existed only as text, so none were playable. - low_freq.py / low_freq.gd dual engines (parity over 3 profile tiers): wind echo (every 6 wins), supply buoy (5-tap minigame, no failure), company crate (every 10 nodes + pity), commission (every 2 chapters, no miss penalty), journal (chapter lore + return rewards). All counter-driven — no wall clock, no daily pressure, never interrupts combat. - Side page gained a 4th 偶遇 tab; claims/taps route through the real engines and persist. Added `buoy` profile field with normalized bounds. - interactions_ui_test drives all five through real hooks; parity + UI tests registered in the full gate. Regenerated-artifact ignores added. All gates pass; P2_CHECKS_PASS. prototype/ untracked.
120 lines
4.5 KiB
GDScript
120 lines
4.5 KiB
GDScript
extends SceneTree
|
|
|
|
## Low-frequency interactions UI (design 11.4): counter-driven, no daily
|
|
## pressure, no combat interruption. Drives real shell hooks through all five.
|
|
|
|
var _problems: Array = []
|
|
var _steps: Array = []
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _check(cond: bool, msg: String) -> void:
|
|
if not cond:
|
|
_problems.append(msg)
|
|
|
|
|
|
func _record(name: String, data: Dictionary) -> void:
|
|
var e := data.duplicate()
|
|
e["step"] = name
|
|
_steps.append(e)
|
|
|
|
|
|
func _run() -> void:
|
|
var shell := load("res://scenes/game_root.tscn").instantiate() as GameRoot
|
|
root.add_child(shell)
|
|
await process_frame
|
|
await process_frame
|
|
shell.reset_profile_for_test()
|
|
var gp := shell.get_profile()
|
|
gp["battle_wins"] = 13 # echo x2, buoy available
|
|
gp["completed_chapters"] = 3 # commission x1
|
|
gp["gold"] = 100
|
|
gp["crystal"] = 10
|
|
var nodes: Array = []
|
|
for i in range(1, 11):
|
|
nodes.append("R1-C01-N%02d" % i)
|
|
gp["completed_nodes"] = nodes # crate x1, journal R1-C01 unread
|
|
ProfileStore.save_profile(gp)
|
|
|
|
shell.show_page_for_test("side")
|
|
shell.set_side_tab_for_test("interactions")
|
|
await process_frame
|
|
var st := shell.get_side_state_for_test()
|
|
_check(int(st["rows"]) >= 5, "interactions tab should list available encounters")
|
|
_record("tab", st)
|
|
|
|
# All five systems derive from counters, not wall clock.
|
|
var s := shell.get_lowfreq_status_for_test()
|
|
_check(int((s["echo"] as Dictionary)["available"]) == 2, "echo should offer 2")
|
|
_check(bool((s["buoy"] as Dictionary)["available"]), "buoy should be available")
|
|
_check(int((s["crate"] as Dictionary)["available"]) == 1, "crate should offer 1")
|
|
_check(int((s["commission"] as Dictionary)["available"]) == 1, "commission should offer 1")
|
|
_check((s["journal"] as Dictionary)["unread"].size() >= 1, "journal should have unread chapter")
|
|
_record("status", s)
|
|
|
|
# Wind echo: low-pressure click reward.
|
|
var gold0 := int(shell.get_profile().get("gold", 0))
|
|
var e := shell.claim_echo_for_test()
|
|
_check(bool(e.get("ok")) and int(shell.get_profile().get("gold", 0)) == gold0 + 30, "echo grants gold")
|
|
_check(int((shell.get_lowfreq_status_for_test()["echo"] as Dictionary)["available"]) == 1,
|
|
"echo counter should drop after one claim")
|
|
_record("echo", e)
|
|
|
|
# Supply buoy: 5 taps, no failure.
|
|
var b := shell.start_buoy_for_test()
|
|
_check(bool(b.get("ok")), "buoy should start")
|
|
var taps: Array = []
|
|
for i in range(5):
|
|
taps.append(shell.tap_buoy_for_test())
|
|
_check(bool((taps[4] as Dictionary).get("done")), "buoy should finish on 5th tap")
|
|
_check(int(shell.get_profile().get("crystal", 0)) == 14, "buoy grants 4 crystal")
|
|
_check(not bool(shell.tap_buoy_for_test().get("ok")), "buoy cannot double-claim")
|
|
_record("buoy", {"taps": taps, "crystal": shell.get_profile().get("crystal")})
|
|
|
|
# Crate / commission / journal.
|
|
var cr := shell.claim_crate_for_test()
|
|
_check(bool(cr.get("ok")) and int(shell.get_profile().get("star_fragments", 0)) == 3, "crate grants fragments")
|
|
var co := shell.claim_commission_for_test()
|
|
_check(bool(co.get("ok")), "commission grants gold")
|
|
var jr := shell.claim_journal_for_test("R1-C01")
|
|
_check(bool(jr.get("ok")), "journal chapter should be readable")
|
|
_check(not bool(shell.claim_journal_for_test("R1-C01").get("ok")), "journal is one-time")
|
|
_record("claim_all", {"crate": cr, "commission": co, "journal": jr})
|
|
|
|
# No daily reset / wall clock: status stays stable across a fresh reload.
|
|
ProfileStore.save_profile(shell.get_profile())
|
|
var s2 := shell.get_lowfreq_status_for_test()
|
|
_check(int((s2["echo"] as Dictionary)["available"]) == 1, "echo counter persisted after reload")
|
|
_record("no_daily", {"echo_available": (s2["echo"] as Dictionary)["available"]})
|
|
|
|
shell.set_locale_for_test("en_US")
|
|
await process_frame
|
|
st = shell.get_side_state_for_test()
|
|
_check(not st["summary"].contains("每日"), "en interactions note should be translated")
|
|
_record("en", {"summary": st["summary"]})
|
|
|
|
root.remove_child(shell)
|
|
shell.free()
|
|
_finish()
|
|
|
|
|
|
func _finish() -> void:
|
|
var passed := _problems.is_empty()
|
|
var report := {"schema": 1, "kind": "windroost_interactions_ui_test",
|
|
"overall": "PASS" if passed else "FAIL", "problems": _problems, "steps": _steps}
|
|
var dir := ProjectSettings.globalize_path("res://artifacts")
|
|
DirAccess.make_dir_recursive_absolute(dir)
|
|
var f := FileAccess.open(dir.path_join("interactions_ui_test.json"), FileAccess.WRITE)
|
|
if f != null:
|
|
f.store_string(JSON.stringify(report, "\t", true)); f.close()
|
|
for e in _steps:
|
|
print("INTERACT_STEP %s" % JSON.stringify(e))
|
|
if passed:
|
|
print("INTERACT_PASS")
|
|
else:
|
|
print("INTERACT_FAIL %s" % "; ".join(_problems))
|
|
quit(0 if passed else 1)
|