Files
mtgodot-poc/project/test_emotion_action_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

76 lines
3.5 KiB
GDScript

# test_emotion_action_parity.gd —— 验证方向 3:角色情绪动作与表情快捷键 40250 1:1 对齐
extends SceneTree
const EmotionActionSystem = preload("res://emotion_action_system.gd")
var _passed := 0
var _failed := 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_emotion_action_parity (Direction 3: Emotions & Hotkeys 1:1) ===")
test_emotion_definitions()
test_command_resolution()
test_ctrl_hotkeys()
test_action_prerequisites()
print("\n=== SUMMARY: %d passed, %d failed ===" % [_passed, _failed])
if _failed > 0:
printerr("TEST FAILED!")
quit(1)
else:
print("ALL TESTS PASSED!")
quit(0)
func test_emotion_definitions() -> void:
print("\n--- Test 1: 18 Official Emotions Definitions (emotion.py) ---")
_assert(EmotionActionSystem.is_valid_emotion(EmotionActionSystem.EMOTION_CLAP), "Clap (1) is valid")
_assert(EmotionActionSystem.is_valid_emotion(EmotionActionSystem.EMOTION_ANGRY), "Angry (4) is valid")
_assert(EmotionActionSystem.is_valid_emotion(EmotionActionSystem.EMOTION_DANCE_1), "Dance 1 (13) is valid")
_assert(EmotionActionSystem.is_valid_emotion(EmotionActionSystem.EMOTION_DANCE_6), "Dance 6 (18) is valid")
_assert(not EmotionActionSystem.is_valid_emotion(999), "Invalid emotion 999 rejected")
func test_command_resolution() -> void:
print("\n--- Test 2: Chat Command Resolution (/clap, /dance1..) ---")
_assert(EmotionActionSystem.get_emotion_from_command("/clap") == EmotionActionSystem.EMOTION_CLAP,
"/clap resolves to EMOTION_CLAP (1)")
_assert(EmotionActionSystem.get_emotion_from_command("/dance1") == EmotionActionSystem.EMOTION_DANCE_1,
"/dance1 resolves to EMOTION_DANCE_1 (13)")
_assert(EmotionActionSystem.get_emotion_from_command("/angry") == EmotionActionSystem.EMOTION_ANGRY,
"/angry resolves to EMOTION_ANGRY (4)")
_assert(EmotionActionSystem.get_emotion_from_command("/unknown") == 0,
"/unknown resolves to 0")
func test_ctrl_hotkeys() -> void:
print("\n--- Test 3: Ctrl + 1..9 Hotkey Mapping ---")
# Ctrl+1 (idx 0) -> Clap
_assert(EmotionActionSystem.get_hotkey_emotion(0) == EmotionActionSystem.EMOTION_CLAP, "Ctrl+1 triggers Clap")
# Ctrl+2 (idx 1) -> Congratulation
_assert(EmotionActionSystem.get_hotkey_emotion(1) == EmotionActionSystem.EMOTION_CONGRATULATION, "Ctrl+2 triggers Congratulation")
# Ctrl+4 (idx 3) -> Angry
_assert(EmotionActionSystem.get_hotkey_emotion(3) == EmotionActionSystem.EMOTION_ANGRY, "Ctrl+4 triggers Angry")
# Ctrl+9 (idx 8) -> Banter
_assert(EmotionActionSystem.get_hotkey_emotion(8) == EmotionActionSystem.EMOTION_BANTER, "Ctrl+9 triggers Banter")
func test_action_prerequisites() -> void:
print("\n--- Test 4: Action Execution Prerequisites (Combat & Mounted Restrictions) ---")
# Successful execution
var res_ok := EmotionActionSystem.perform_emotion(EmotionActionSystem.EMOTION_CLAP, false, false)
_assert(res_ok.ok and res_ok.code == "SUCCESS", "Emotion performed successfully")
_assert(res_ok.motion == "clap", "Motion is clap")
# Rejected while in combat
var res_combat := EmotionActionSystem.perform_emotion(EmotionActionSystem.EMOTION_CLAP, true, false)
_assert(not res_combat.ok and res_combat.code == "CANNOT_IN_BATTLE", "Emotion rejected during combat")
# Rejected while mounted
var res_mount := EmotionActionSystem.perform_emotion(EmotionActionSystem.EMOTION_CLAP, false, true)
_assert(not res_mount.ok and res_mount.code == "CANNOT_ON_MOUNT", "Emotion rejected while mounted")