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

88 lines
3.4 KiB
GDScript

# test_intro_empire_parity.gd —— 40250 三国地貌 3D 运镜与阵营选择回归测试
extends SceneTree
const SystemClass = preload("res://intro_empire_phase.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_intro_empire_parity (Batch 29 Direction 2) ===")
_test_initial_empire_state()
_test_camera_target_positions_and_switching()
_test_camera_smooth_interpolation()
_test_empire_description_and_confirmation()
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_initial_empire_state() -> void:
print("\n--- Test 1: Initial Empire & Camera Initialization ---")
var emp = SystemClass.new(SystemClass.EMPIRE_SHINSOO)
_assert(emp.selected_empire == SystemClass.EMPIRE_SHINSOO, "Initial empire is Shinsoo")
var info = emp.get_selected_empire_info()
_assert(info["capital"] == "Yongan", "Shinsoo capital is Yongan")
_assert(emp.current_cam_pos == Vector3(100.0, 50.0, -200.0), "Initial camera pos matches preset")
func _test_camera_target_positions_and_switching() -> void:
print("\n--- Test 2: Switching Empires & Camera Target Updates ---")
var emp = SystemClass.new(SystemClass.EMPIRE_SHINSOO)
# Switch to Chunjo (Yellow)
var sw1 = emp.select_empire(SystemClass.EMPIRE_CHUNJO)
_assert(sw1 == true, "Switched to Chunjo")
_assert(emp.target_cam_pos == Vector3(-150.0, 60.0, -180.0), "Chunjo camera target pos set")
_assert(emp.is_transitioning == true, "Camera transition activated")
# Switch to Jinno (Blue)
var sw2 = emp.select_empire(SystemClass.EMPIRE_JINNO)
_assert(sw2 == true, "Switched to Jinno")
_assert(emp.target_cam_pos == Vector3(0.0, 80.0, -250.0), "Jinno camera target pos set")
# Reject invalid empire
var sw_inv = emp.select_empire(99)
_assert(sw_inv == false, "Reject invalid empire id 99")
func _test_camera_smooth_interpolation() -> void:
print("\n--- Test 3: Smooth Camera Interpolation Flow ---")
var emp = SystemClass.new(SystemClass.EMPIRE_SHINSOO)
emp.select_empire(SystemClass.EMPIRE_JINNO)
_assert(emp.is_transitioning == true, "Transitioning flag is true")
# Halfway step (0.5)
emp.update_camera_transition(0.5)
_assert(emp.is_transitioning == true, "Still transitioning at 50%")
_assert(emp.transition_t == 0.5, "transition_t is 0.5")
# Complete transition (another 0.5)
emp.update_camera_transition(0.5)
_assert(emp.is_transitioning == false, "Transition completed")
_assert(emp.current_cam_pos == Vector3(0.0, 80.0, -250.0), "Camera arrived exactly at Jinno preset")
func _test_empire_description_and_confirmation() -> void:
print("\n--- Test 4: Empire Metadata & Confirmation Phase Transition ---")
var emp = SystemClass.new(SystemClass.EMPIRE_JINNO)
var info = emp.get_selected_empire_info()
_assert(info["desc"].contains("崇尚武道强权"), "Contains Jinno lore description")
_assert(info["trait"].contains("物理基础攻击力 +5%"), "Contains Jinno trait bonus")
var conf = emp.confirm_empire_selection()
_assert(conf["success"] == true, "Confirmed empire selection")
_assert(conf["empire_id"] == SystemClass.EMPIRE_JINNO, "Confirmed Jinno (3)")
_assert(conf["next_phase"] == "CHARACTER_SELECT", "Routes to CHARACTER_SELECT phase")