Continued FULL_GAME_GOAL. Closed the new-pages gap and wired the authored gear numbers into combat (gear previously had no runtime effect at all). - Regenerated gear as 20 families x 6 slots (weapon/head/chest/gloves/trinket/ boots) with real stat bucket, signature answered and recommended scene, per CONTENT_PLAN 7.1 (was all 120 mislabelled "weapon"). - growth.py / growth_modifiers.gd gained a gear layer: equipped items' authored stat_value feed roster/signature/click/storm; parity gate extended to gear. - gear_actions.py/.gd dual engines (parity): node clears drop fixed gear, owned gear can be equipped per slot, wrong/unowned gear rejected. Drops wired into both slice and world victories; rebuild/new-sky clear gear + equipped. - Skyport 英雄与装备 page: hero selector, authored detail (signature + 4 structured talents with behaviour), 6 gear slots with equip/unequip. loadout_ui_test proves drop->equip->growth change and rebuild reset. - Settings page now uses a STOP ScrollContainer like the other pages (was clipping on short viewports). All gates pass; P2_CHECKS_PASS. prototype/ untracked.
123 lines
4.8 KiB
GDScript
123 lines
4.8 KiB
GDScript
extends SceneTree
|
|
|
|
## Loadout UI: hero detail from authored content + 6 gear slots. Proves the
|
|
## drop -> equip -> growth chain is real (gear stats change combat modifiers).
|
|
|
|
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["unlocked_heroes"] = ["H01", "H02", "H03"]
|
|
ProfileStore.save_profile(gp)
|
|
|
|
shell.show_page_for_test("loadout")
|
|
await process_frame
|
|
var st := shell.get_loadout_state_for_test()
|
|
_check(int(st["gear_rows"]) == 6, "loadout should show 6 gear slots")
|
|
_check(str(st["hero"]) == "H01", "default hero should be H01")
|
|
_check(st["detail"].contains("奥登") or st["detail"].contains("Oden"), "hero detail should show name")
|
|
_check(st["detail"].contains("slot") or st["detail"].contains("槽") or st["detail"].contains("武器"),
|
|
"hero detail should show structured talent purposes")
|
|
_record("open", st)
|
|
|
|
# Switch hero -> detail updates.
|
|
shell.select_loadout_hero_for_test("H02")
|
|
await process_frame
|
|
st = shell.get_loadout_state_for_test()
|
|
_check(str(st["hero"]) == "H02", "hero switch should update selection")
|
|
_check(st["detail"].contains("莉瑞娅") or st["detail"].contains("Lira"), "hero detail should update")
|
|
_record("hero_switch", st)
|
|
|
|
# Gear drops from nodes, then equip into matching slots.
|
|
var d1 := shell.grant_gear_drop_for_test("R1-C01-N01")
|
|
var d2 := shell.grant_gear_drop_for_test("R3-C05-N07")
|
|
_check(bool(d1.get("ok")) and bool(d2.get("ok")), "node clears should drop gear")
|
|
st = shell.get_loadout_state_for_test()
|
|
_check(int(st["owned_gear"]) >= 1, "owned gear should grow")
|
|
_record("drops", {"d1": d1, "d2": d2, "owned": st["owned_gear"]})
|
|
|
|
# Need a weapon (weapon slot); grant several node drops until one appears.
|
|
var weapon_id := ""
|
|
for n in range(1, 40):
|
|
var gid := str(shell.grant_gear_drop_for_test("R1-C01-N%02d" % n).get("gear", ""))
|
|
var owned: Dictionary = shell.get_profile().get("gear", {})
|
|
for g in WorldContent.content().get("gear", []):
|
|
if owned.has(str((g as Dictionary).get("id", ""))) and str((g as Dictionary).get("slot", "")) == "weapon":
|
|
weapon_id = str((g as Dictionary).get("id", ""))
|
|
break
|
|
if not weapon_id.is_empty():
|
|
break
|
|
_check(not weapon_id.is_empty(), "should own at least one weapon")
|
|
|
|
# Equip changes growth modifiers (authoritative numbers actually used).
|
|
var mods_before := shell.get_loadout_growth_for_test()
|
|
var eq := shell.equip_gear_for_test("weapon", weapon_id)
|
|
_check(bool(eq.get("ok")), "equipping an owned weapon should succeed")
|
|
var mods_after := shell.get_loadout_growth_for_test()
|
|
_check(float(mods_after.get("signature_mult", 0.0)) > float(mods_before.get("signature_mult", 0.0)),
|
|
"equipped weapon should raise signature modifier")
|
|
st = shell.get_loadout_state_for_test()
|
|
_check(str((st["equipped"] as Dictionary).get("weapon", "")) == weapon_id, "equipped mapping should persist")
|
|
_record("equip", {"weapon": weapon_id, "eq": eq,
|
|
"before": mods_before.get("signature_mult"), "after": mods_after.get("signature_mult")})
|
|
|
|
# Wrong slot / unowned gear is rejected.
|
|
var bad := shell.equip_gear_for_test("weapon", "G999")
|
|
_check(not bool(bad.get("ok")), "unowned gear should be rejected")
|
|
_record("reject", bad)
|
|
|
|
# Rebuild clears gear and equipped (design 7.2).
|
|
shell.on_prestige_preview_for_test()
|
|
await process_frame
|
|
shell.on_modal_action_for_test("confirm_full_rebuild")
|
|
await process_frame
|
|
var after := shell.get_profile()
|
|
_check((after.get("gear", {}) as Dictionary).is_empty(), "rebuild should clear gear")
|
|
_check((after.get("equipped", {}) as Dictionary).is_empty(), "rebuild should clear equipped")
|
|
_record("rebuild", {"gear": (after.get("gear", {}) as Dictionary).size(),
|
|
"equipped": (after.get("equipped", {}) as Dictionary).size()})
|
|
|
|
root.remove_child(shell)
|
|
shell.free()
|
|
_finish()
|
|
|
|
|
|
func _finish() -> void:
|
|
var passed := _problems.is_empty()
|
|
var report := {"schema": 1, "kind": "windroost_loadout_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("loadout_ui_test.json"), FileAccess.WRITE)
|
|
if f != null:
|
|
f.store_string(JSON.stringify(report, "\t", true)); f.close()
|
|
for e in _steps:
|
|
print("LOADOUT_STEP %s" % JSON.stringify(e))
|
|
if passed:
|
|
print("LOADOUT_PASS")
|
|
else:
|
|
print("LOADOUT_FAIL %s" % "; ".join(_problems))
|
|
quit(0 if passed else 1)
|