extends SceneTree # 三选一覆盖层 UI 直验套件(迭代 7 T5-hotfix 转正;迭代 10 追加批随面迁移改写)—— # 原守 node_overlay.show_reward_items;奖励节点三选一与通关三选一合并共用 BonusPickOverlay 后, # 本套件改守共用面的「功能存在 ≠ 功能可达」盲区:选择外发/强制确认两段式/替换子面板两路/结果态。 # 运行:godot --headless --path game --script res://tests/unit/presentation/reward_overlay_test.gd(expect 0) # T6 收口批:断言走 test_kit 计数(Kit.check)+ 失败即停早退协议保留(顺序状态机——坏态下后继断言无效)。 const Kit := preload("res://tests/unit/test_kit.gd") # 断言 + 失败即停(原直写 print FAIL + quit(1) + return 样板单点化——早退语义逐位保持) func _req(desc: String, ok: bool) -> bool: Kit.check(desc, ok) if not ok: quit(1) return false return true func _initialize() -> void: call_deferred("_run") func _run() -> void: var ov = load("res://presentation/views/bonus_pick_overlay.gd").new() root.add_child(ov) var picked := [] var replaced := [] var continued := [] ov.pick_confirmed.connect(func(id: String): picked.append(id)) ov.replace_chosen.connect(func(tag: int): replaced.append(tag)) ov.continue_pressed.connect(func(): continued.append(true)) # ① 选择态:三卡呈现、确认钮隐藏(两段式——点选前不给确认) ov.open_pick("第 1 层通过!", [ {"id": "attack", "text": "攻击力提升\n攻击 +1"}, {"id": "gp", "text": "金币袋\n金币 +20"}, {"id": "ap", "text": "行动点提升\n每战首轮 AP +1"}, ]) var btns := 0 for c in ov._choice_box.get_children(): if c is Button: btns += 1 if not _req("选择态应三卡呈现且确认/继续隐藏(btns=%d)" % btns, ov.visible and btns == 3 and not ov._confirm_btn.visible and not ov._continue_btn.visible): return # ② 点选→高亮→确认外发(真实按钮路径);确认前改选以最后点选为准 ov.press_card(0) ov.press_card(1) ov.press_confirm() if not _req("点选确认未外发 pick_confirmed(gp)(%s)" % str(picked), ov._confirm_btn.visible and picked.size() == 1 and String(picked[0]) == "gp"): return # ③ 替换子面板:丢旧收新与放弃新件两路外发(通关渠道=携带序号 / 节点渠道=库存句柄——tag 直通) ov.open_replace([{"index": 0, "item_id": "probe_dust", "display_name": "显影尘"}], "爆破工兵包", 1, 1) var replace_btns := 0 for c in ov._replace_box.get_children(): if c is Button: replace_btns += 1 if not _req("替换面板应 2 钮(N+1 选 N+放弃)且三卡隐藏(btns=%d)" % replace_btns, replace_btns == 2 and not ov._choice_box.visible): return var replaced_first := false for c in ov._replace_box.get_children(): if c is Button: c.pressed.emit() replaced_first = true break if not _req("丢旧收新未外发 replace_chosen(0)(%s)" % str(replaced), replaced_first and replaced.size() == 1 and int(replaced[0]) == 0): return # ④ 结果态:继续钮点亮、唯一出口 ov.show_result("已选择:攻击力提升 · 攻击 +1") if not _req("结果态应点亮继续且收替换面板", ov._continue_btn.visible and not ov._replace_box.visible): return ov.press_continue() if not _req("继续未外发 continue_pressed", continued.size() == 1): return ov.close_pick() if not _req("close_pick 应收屏", not ov.visible): return quit(Kit.finish("reward_verify", "PASS — 三卡两段式/确认外发/替换两路/结果态/收屏 全过"))