76 lines
3.2 KiB
GDScript
76 lines
3.2 KiB
GDScript
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)
|
||
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 ov.visible != true or btns != 3 or ov._confirm_btn.visible or ov._continue_btn.visible:
|
||
print("[reward_verify] FAIL — 选择态应三卡呈现且确认/继续隐藏(btns=%d)" % btns)
|
||
quit(1)
|
||
return
|
||
# ② 点选→高亮→确认外发(真实按钮路径);确认前改选以最后点选为准
|
||
ov.press_card(0)
|
||
ov.press_card(1)
|
||
ov.press_confirm()
|
||
if ov._confirm_btn.visible != true or picked.size() != 1 or String(picked[0]) != "gp":
|
||
print("[reward_verify] FAIL — 点选确认未外发 pick_confirmed(gp)(%s)" % str(picked))
|
||
quit(1)
|
||
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 replace_btns != 2 or ov._choice_box.visible:
|
||
print("[reward_verify] FAIL — 替换面板应 2 钮(N+1 选 N+放弃)且三卡隐藏(btns=%d)" % replace_btns)
|
||
quit(1)
|
||
return
|
||
for c in ov._replace_box.get_children():
|
||
if c is Button:
|
||
c.pressed.emit()
|
||
break
|
||
if replaced.size() != 1 or int(replaced[0]) != 0:
|
||
print("[reward_verify] FAIL — 丢旧收新未外发 replace_chosen(0)(%s)" % str(replaced))
|
||
quit(1)
|
||
return
|
||
# ④ 结果态:继续钮点亮、唯一出口
|
||
ov.show_result("已选择:攻击力提升 · 攻击 +1")
|
||
if ov._continue_btn.visible != true or ov._replace_box.visible:
|
||
print("[reward_verify] FAIL — 结果态应点亮继续且收替换面板")
|
||
quit(1)
|
||
return
|
||
ov.press_continue()
|
||
if continued.size() != 1:
|
||
print("[reward_verify] FAIL — 继续未外发 continue_pressed")
|
||
quit(1)
|
||
return
|
||
ov.close_pick()
|
||
if ov.visible:
|
||
print("[reward_verify] FAIL — close_pick 应收屏")
|
||
quit(1)
|
||
return
|
||
print("[reward_verify] PASS — 三卡两段式/确认外发/替换两路/结果态/收屏 全过")
|
||
quit(0)
|