# test_game_button_money_dialog_parity.gd # 检验 40250 浮动任务栏状态红点通知与金币分堆丢弃输入窗 extends SceneTree const GameButtonMoneyDialogSystem = preload("res://game_button_money_dialog_system.gd") func _init() -> void: print("--- 开始测试 40250 浮动任务栏状态红点与金币分堆系统 (test_game_button_money_dialog_parity) ---") var system = GameButtonMoneyDialogSystem.new() var fails: int = 0 var btns = system.game_buttons var money = system.money_dialog # 1. 浮动任务栏按钮状态检验 (新角色: 0 播放时间,有剩余未分配点数) btns.check_game_buttons(5, 1, 0) if not btns.button_visible["STATUS"]: printerr("FAIL: 有未分配属性点时 STATUS 按钮未显示!") fails += 1 if not btns.button_visible["SKILL"]: printerr("FAIL: 有未分配技能点时 SKILL 按钮未显示!") fails += 1 if not btns.button_visible["HELP"]: printerr("FAIL: 0 游戏时长角色 HELP 按钮未显示!") fails += 1 # 老玩家分配完点数后 (stat=0, skill=0, playtime=3600) btns.check_game_buttons(0, 0, 3600) if btns.button_visible["STATUS"] or btns.button_visible["SKILL"] or btns.button_visible["HELP"]: printerr("FAIL: 属性点分配完毕且为老玩家时按钮应隐藏!") fails += 1 # 2. 观战模式按钮与 /observer_exit 指令 btns.set_observer_mode(true) if not btns.button_visible["EXIT_OBSERVER"]: printerr("FAIL: 观战模式下未显示 EXIT_OBSERVER 按钮!") fails += 1 btns.click_exit_observer() if btns.last_chat_packet_sent != "/observer_exit": printerr("FAIL: 退出观战发送指令错误: ", btns.last_chat_packet_sent) fails += 1 btns.set_observer_mode(false) if btns.button_visible["EXIT_OBSERVER"]: printerr("FAIL: 非观战模式下 EXIT_OBSERVER 按钮未隐藏!") fails += 1 # 3. 金币分堆/丢弃输入框坐标吸附计算测试 # 屏幕 1024x768,点击位于中间 (500, 400) # 宽度 170,高度 90 -> pos_x 应为 500 - 85 = 415, pos_y = 400 - 90 - 20 = 290 money.open_dialog(50000, 100, 500, 400, 1024, 768) if not money.is_open: printerr("FAIL: 金币输入框未能打开!") fails += 1 if money.pos_x != 415 or money.pos_y != 290: printerr("FAIL: 金币输入框坐标吸附错误: pos_x=", money.pos_x, " pos_y=", money.pos_y) fails += 1 # 4. 边界屏幕右侧贴边吸附测试 (mouse_x = 1000) money.open_dialog(50000, 100, 1000, 400, 1024, 768) if money.pos_x != (1024 - 170): # 854 printerr("FAIL: 贴右边缘防越界未生效,pos_x=", money.pos_x) fails += 1 # 5. 输入数字与截断测试 (输入 80000,超出最大 50000 -> 截断为 50000) money.input_text("80000") var accepted = money.on_accept() if not accepted or money.last_accepted_value != 50000: printerr("FAIL: 超额金币未能正确截断至 50000,实际: ", money.last_accepted_value) fails += 1 if money.is_open: printerr("FAIL: 接受后对话框未自动关闭!") fails += 1 # 6. 非法字符过滤测试 money.open_dialog(1000, 1, 100, 100) money.input_text("abc12") var bad_accept = money.on_accept() if bad_accept or money.last_accepted_value != 0: printerr("FAIL: 非法非数字输入未能拦截!") fails += 1 if fails == 0: print("PASS: test_game_button_money_dialog_parity (8/8 全部通过)") quit(0) else: printerr("FAILED: test_game_button_money_dialog_parity (", fails, " 项失败)") quit(1)