Files
mtgodot-poc/project/test_whisper_chat_parity.gd
T
shenandshen 66d217b313 feat(client): 完成40250客户端核心功能1:1对齐与桥梁高度采样修复
- 桥梁与静态物体高度采样修复:
  - 严格对齐 40250 CMapOutdoor::GetHeight 与 CAttributeInstance::GetHeight
  - 解析 .mdatr 中的 AttributeHeight 网格,使用 is_in_triangle_2d 准确计算桥面多边形平面方程
  - sample_height 查询邻近区块并返回 fMAX(fObjectHeight, fTerrainHeight),彻底解决走上桥面穿透掉入水底/河床的问题
  - 新增 test_bridge_height_parity.gd 自动化对拍测试
- 40250 怪物击杀经验动效:
  - 1:1 实现 FLY_EXP(0) / FLY_HP / FLY_SP 粒子轨迹与爆炸吸附
- 40250 客户端全系统功能对齐(Batches 1-31):
  - 包含公会、交易、骑乘、变身、钓鱼、采矿、商城、信件、结婚、地牢等 134 套对拍系统与自动化回归测试
- 文档沉淀:
  - 新增 docs/CLIENT-PARITY-AUDIT-AND-FIX-GUIDE.md 客户端对拍缺陷发现与修复工程指南
2026-09-19 08:51:25 -07:00

113 lines
4.3 KiB
GDScript

# test_whisper_chat_parity.gd —— 40250 独立私聊窗口与任务栏闪烁通知回归测试
extends SceneTree
const SystemClass = preload("res://whisper_chat_system.gd")
var _passed: int = 0
var _failed: int = 0
func _assert(cond: bool, msg: String) -> void:
if cond:
_passed += 1
print(" [PASS] %s" % msg)
else:
_failed += 1
printerr(" [FAIL] %s" % msg)
func _init() -> void:
print("\n=== Running test_whisper_chat_parity (Batch 27 Direction 2) ===")
_test_conversation_lifecycle()
_test_taskbar_blinking_notification()
_test_gamemaster_identification()
_test_ignore_blacklist_filtering()
_test_bidirectional_messaging()
print("\n=== Result: %d Passed, %d Failed ===" % [_passed, _failed])
if _failed == 0:
print("ALL TESTS PASSED!\n")
else:
printerr("SOME TESTS FAILED!\n")
quit(0 if _failed == 0 else 1)
func _test_conversation_lifecycle() -> void:
print("\n--- Test 1: Conversation Lifecycle (Open / Minimize / Close) ---")
var w = SystemClass.new("Hero")
var conv = w.open_conversation("Alice")
_assert(conv != null, "Opened conversation with Alice")
_assert(conv.state == SystemClass.DialogState.VISIBLE, "Conversation is VISIBLE")
w.minimize_conversation("Alice")
_assert(conv.state == SystemClass.DialogState.MINIMIZED, "Conversation MINIMIZED to taskbar")
w.close_conversation("Alice")
_assert(conv.state == SystemClass.DialogState.CLOSED, "Conversation CLOSED")
func _test_taskbar_blinking_notification() -> void:
print("\n--- Test 2: Taskbar Blinking & Unread Count ---")
var w = SystemClass.new("Hero")
# Receive message from Bob without active window
var r = w.receive_whisper("Bob", "Hello there!")
_assert(r["delivered"] == true, "Message delivered")
_assert(r["triggered_blink"] == true, "Triggered taskbar blinking notification")
var conv = w.conversations["Bob"]
_assert(conv.is_blinking == true, "Bob's conversation is blinking")
_assert(conv.unread_count == 1, "Unread count is 1")
# Receive second message
w.receive_whisper("Bob", "Are you there?")
_assert(conv.unread_count == 2, "Unread count increased to 2")
# Open conversation: should clear blinking and unread count
w.open_conversation("Bob")
_assert(conv.is_blinking == false, "Blinking cleared upon opening")
_assert(conv.unread_count == 0, "Unread count reset to 0")
_assert(conv.state == SystemClass.DialogState.VISIBLE, "Conversation state restored to VISIBLE")
func _test_gamemaster_identification() -> void:
print("\n--- Test 3: Game Master [GM] Identification ---")
var w = SystemClass.new("Hero")
var r = w.receive_whisper("[GM]Admin", "Server maintenance in 10 minutes.")
_assert(r["delivered"] == true, "GM message delivered")
var conv = w.conversations["[GM]Admin"]
_assert(conv.is_gamemaster == true, "Identified as Game Master")
_assert(conv.history[0].is_gm == true, "Message tagged with is_gm flag")
func _test_ignore_blacklist_filtering() -> void:
print("\n--- Test 4: Ignore Blacklist Filtering ---")
var w = SystemClass.new("Hero")
# Blacklist Spammer
var is_ign = w.toggle_ignore_target("Spammer")
_assert(is_ign == true, "Spammer added to ignore blacklist")
_assert(w.is_ignored("Spammer") == true, "Spammer is ignored")
# Receive whisper from Spammer
var r = w.receive_whisper("Spammer", "Buy gold cheap!")
_assert(r["delivered"] == false, "Spammer whisper rejected")
_assert(r["blocked_by_ignore"] == true, "Blocked by ignore filter")
_assert(w.get_blinking_conversations().is_empty(), "No blinking notifications triggered for ignored user")
# Un-ignore Spammer
var is_ign_again = w.toggle_ignore_target("Spammer")
_assert(is_ign_again == false, "Spammer removed from ignore blacklist")
var r2 = w.receive_whisper("Spammer", "Now you can hear me")
_assert(r2["delivered"] == true, "Whisper delivered after un-ignoring")
func _test_bidirectional_messaging() -> void:
print("\n--- Test 5: Bidirectional Messaging History ---")
var w = SystemClass.new("Hero")
w.send_whisper("Alice", "Hey Alice, let's do Demon Tower!")
w.current_time += 10
w.receive_whisper("Alice", "Sure, meet at DT entrance!")
var conv = w.conversations["Alice"]
_assert(conv.history.size() == 2, "Conversation history contains 2 messages")
_assert(conv.history[0].sender == "Hero", "First message sent by Hero")
_assert(conv.history[1].sender == "Alice", "Second message sent by Alice")
_assert(conv.history[1].timestamp == 1010, "Timestamp recorded correctly")