Continued FULL_GAME_GOAL. Structured talents had real stat/stat_value in the pack but runtime growth still used the flat slice fallback, so authored numbers never reached combat. Closed that gap on the full-game path only. - growth.py: optional talent_stats in compute_modifiers + cached load_talent_stats()/compute_full_game_modifiers(). GDScript compute() takes the same optional authored stats and buckets click/signature/global; slice calls with no stats keep the flat +3%/+2% identity fallback. - World node launch now uses authored stats; added a shell hook so the runtime test proves slot-1 click and slot-3 signature buckets are active. - New cross-language parity gate over 5 profiles proves python==gd and that authored modifiers differ from the flat fallback. Registered in full gate. Existing growth/parity tests unchanged and green; P2_CHECKS_PASS. prototype/ untracked.
139 lines
5.6 KiB
GDScript
139 lines
5.6 KiB
GDScript
extends SceneTree
|
|
|
|
## Full-game expedition world UI (L5 runtime). Proves the 600-node world is a
|
|
## real playable navigator: region -> chapter -> node, lock rules, launch, real
|
|
## battle finish routing, progress/reward persistence, and zh/en labels.
|
|
|
|
const OUTPUT_PATH := "res://artifacts/world_map_ui_test.json"
|
|
|
|
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["highest_node"] = 25
|
|
gp["gold"] = 500
|
|
gp["crystal"] = 10
|
|
gp["unlocked_heroes"] = ["H01", "H02", "H03"]
|
|
# Authored talent stats: slot 1 feeds the click bucket, slot 3 the
|
|
# signature bucket. The flat slice fallback would leave click at 1.0.
|
|
gp["talents"] = {"T-H01-01": true, "T-H01-03": true}
|
|
ProfileStore.save_profile(gp)
|
|
shell.refresh_pages_for_test()
|
|
|
|
# Open the world page through the same routing the player uses.
|
|
shell.show_page_for_test("world")
|
|
await process_frame
|
|
var st := shell.get_world_state_for_test()
|
|
var counts := shell.get_world_counts_for_test()
|
|
_check(int(counts.get("nodes", 0)) == 600, "world pack must have 600 nodes")
|
|
_check(int(st["region_count"]) == 5, "world page should show 5 regions")
|
|
_check(int(st["chapter_count"]) == 12, "R1 should show 12 chapters")
|
|
_check(int(st["node_count"]) == 10, "a chapter should show 10 nodes")
|
|
_check(str(st["node"]) == "R1-C01-N01", "first node should be R1-C01-N01")
|
|
_check(st["detail"].contains("破风码头"), "zh detail should show theme")
|
|
_record("open", {"state": st, "counts": counts})
|
|
|
|
# Navigate to region 3 / chapter 5 -> node order 281 is still locked.
|
|
shell.select_world_region_for_test("R3")
|
|
shell.select_world_chapter_for_test("R3-C05")
|
|
st = shell.get_world_state_for_test()
|
|
_check(str(st["node"]) == "R3-C05-N01", "chapter selection should pick first node")
|
|
_check(not shell.is_world_node_available_for_test("R3-C05-N01"),
|
|
"node 281 should be locked while highest_node=25")
|
|
_record("navigate", {"state": st})
|
|
|
|
# Advance progress -> node becomes available, zone detail updates.
|
|
gp = shell.get_profile()
|
|
gp["highest_node"] = 285
|
|
ProfileStore.save_profile(gp)
|
|
shell.refresh_pages_for_test()
|
|
shell.show_page_for_test("world")
|
|
shell.select_world_node_for_test("R3-C05-N01")
|
|
await process_frame
|
|
_check(shell.is_world_node_available_for_test("R3-C05-N01"),
|
|
"node 281 should unlock at highest_node=285")
|
|
st = shell.get_world_state_for_test()
|
|
_check(not st["detail"].contains("尚未解锁"), "unlocked detail should not show lock")
|
|
_record("unlock", {"state": st})
|
|
|
|
# Launch the node -> real battle instance in world mode.
|
|
var gold_before := int(shell.get_profile().get("gold", 0))
|
|
shell.launch_world_node_for_test("R3-C05-N01")
|
|
await process_frame
|
|
_check(shell.is_world_mode_for_test(), "launch should enter world battle mode")
|
|
var mods := shell.get_world_growth_modifiers_for_test()
|
|
_check(float(mods.get("click_mult", 1.0)) > 1.0, "authored talent should feed click bucket")
|
|
_check(float(mods.get("signature_mult", 1.0)) > 1.0, "authored talent should feed signature bucket")
|
|
_record("launch", {"node": "R3-C05-N01", "world_mode": true, "mods": mods})
|
|
|
|
# Force a win through the real battle_finished signal -> shell routing.
|
|
shell.force_world_battle_result_for_test("win")
|
|
await process_frame
|
|
var after := shell.get_profile()
|
|
var completed: Array = after.get("completed_nodes", [])
|
|
_check(completed.has("R3-C05-N01"), "win should mark node completed")
|
|
_check(int(after.get("gold", 0)) > gold_before, "win should grant gold")
|
|
_check(int(after.get("highest_node", 0)) >= 281, "win should advance highest_node")
|
|
_check(int(after.get("completed_chapters", 0)) >= 1, "win should count chapter")
|
|
_check(int(after.get("completed_regions", 0)) >= 1, "win should count region")
|
|
_check(int(after.get("total_essence_earned", 0)) > 0, "win should feed prestige essence source")
|
|
_check(not shell.is_world_mode_for_test(), "finish should leave world battle mode")
|
|
_record("win", {"gold": after.get("gold"), "highest": after.get("highest_node"),
|
|
"chapters": after.get("completed_chapters"), "regions": after.get("completed_regions")})
|
|
|
|
# Modal 'world' action returns to the navigator.
|
|
shell.on_modal_action_for_test("world")
|
|
await process_frame
|
|
_check(shell.get_modal_visible_for_test() == false, "world action should close modal")
|
|
|
|
# English locale labels (no raw Chinese on the world page).
|
|
shell.set_locale_for_test("en_US")
|
|
await process_frame
|
|
st = shell.get_world_state_for_test()
|
|
_check(not st["detail"].contains("岩脉"), "en detail should not contain Chinese theme")
|
|
_record("en", {"detail": st["detail"]})
|
|
|
|
root.remove_child(shell)
|
|
shell.free()
|
|
_finish()
|
|
|
|
|
|
func _finish() -> void:
|
|
var passed := _problems.is_empty()
|
|
var report := {"schema": 1, "kind": "windroost_world_map_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("world_map_ui_test.json"), FileAccess.WRITE)
|
|
if f != null:
|
|
f.store_string(JSON.stringify(report, "\t", true)); f.close()
|
|
for e in _steps:
|
|
print("WORLD_UI_STEP %s" % JSON.stringify(e))
|
|
if passed:
|
|
print("WORLD_UI_PASS")
|
|
else:
|
|
print("WORLD_UI_FAIL %s" % "; ".join(_problems))
|
|
quit(0 if passed else 1)
|