Files
mtgodot-poc/project/motion_registry_test.gd
T
shenandshen c93894313a fix: 装备属性面板避让逻辑 + 多项功能更新
- item_tooltip_view.gd: 新增 avoid_rect 属性,tooltip 与装备窗口重叠时自动推到左侧
- inventory_ui.gd: 悬停装备时传入窗口矩形作为避让区域
- 包含其他累积的功能开发和测试文件
2026-09-21 16:38:59 -07:00

70 lines
2.8 KiB
GDScript

# motion_registry_test —— 40250 RaceData 注册顺序/权重的资源回归。
# godot --headless --path project --script motion_registry_test.gd
extends SceneTree
const MotionRegistry = preload("res://ui/motion_registry.gd")
var _fail := 0
func _ck(ok: bool, msg: String) -> void:
if not ok:
_fail += 1
printerr("FAIL: " + msg)
func _find(entries: Array, name: String) -> Dictionary:
for entry in entries:
if String(entry.get("name", "")) == name:
return entry
return {}
func _init() -> void:
var assets := AssetRoot.path()
var registry: RefCounted = MotionRegistry.load_for(assets, 0)
_ck(bool(registry.get("source_loaded")), "warrior registry reads playersettingmodule.py")
for race in range(8):
var race_registry: RefCounted = MotionRegistry.load_for(assets, race)
var race_wait: Array = race_registry.variants(1, 1)
var expected_wait_count := 2 if (race & 3) in [0, 1] else 1
_ck(race_wait.size() == expected_wait_count,
"race %d keeps the source-defined GENERAL wait registration count" % race)
var race_attack: Array = race_registry.variants(1, 14)
_ck(race_attack.size() == 2 and int(race_attack[0].get("weight", -1)) == 50 and
int(race_attack[1].get("weight", -1)) == 50,
"race %d keeps the source-defined GENERAL attack weights" % race)
var general_wait: Array = registry.variants(1, 1)
_ck(general_wait.size() == 2, "GENERAL WAIT preserves two registered variants")
_ck(int(_find(general_wait, "wait.msa").get("weight", -1)) == 70,
"SetMotionRandomWeight changes GENERAL wait.msa to 70")
_ck(int(_find(general_wait, "wait_1.msa").get("weight", -1)) == 30,
"GENERAL wait_1.msa keeps registered weight 30")
var onehand_wait: Array = registry.variants(2, 1)
_ck(onehand_wait.size() == 2, "ONEHAND WAIT preserves registration order")
_ck(String(onehand_wait[0].get("name", "")) == "wait.msa" and
String(onehand_wait[1].get("name", "")) == "wait_1.msa",
"ONEHAND WAIT keeps wait then wait_1 order")
_ck(int(onehand_wait[0].get("weight", -1)) == 50 and
int(onehand_wait[1].get("weight", -1)) == 50,
"ONEHAND WAIT keeps 50/50 weights")
var horse_wait: Array = registry.variants(9, 1)
_ck(horse_wait.size() == 3, "HORSE WAIT preserves all three variants")
_ck(int(horse_wait[0].get("weight", -1)) == 90 and
int(horse_wait[1].get("weight", -1)) == 9 and
int(horse_wait[2].get("weight", -1)) == 1,
"HORSE WAIT keeps 90/9/1 weighted selection")
var general_attack: Array = registry.variants(1, 14)
_ck(general_attack.size() == 2, "GENERAL COMBO_ATTACK_1 has two attack resources")
_ck(int(_find(general_attack, "attack.msa").get("weight", -1)) == 50 and
int(_find(general_attack, "attack_1.msa").get("weight", -1)) == 50,
"GENERAL attack resources keep 50/50 weights")
if _fail == 0:
print("PASS: motion_registry_test")
quit(0)
else:
printerr("%d check(s) failed" % _fail)
quit(1)