Files
mtgodot-poc/project/part_hiding_test.gd

77 lines
3.4 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# part_hiding_test —— §4.1 修改 4:变身 / 时装部位遮挡(PartHiding1:1 自检。
# canonical #18。 godot --headless --path project --script part_hiding_test.gd
extends SceneTree
const PartHiding = preload("res://part_hiding.gd")
var failed := 0
func _ck(ok: bool, message: String) -> void:
if not ok:
failed += 1
printerr("FAIL: " + message)
func _init() -> void:
_test_animal_wear()
_test_dress_and_bouquet()
_test_changable_weapon()
_test_weapon_hidden()
_test_hair_hidden()
_test_body_shape()
_test_effective_weapon()
if failed == 0:
print("PASS: part_hiding_test (§4.1 修改 4 poly / animal-wear / dress 遮挡 1:1)")
quit(0)
else:
quit(1)
func _test_animal_wear() -> void:
for s in [100, 101, 102, 103]:
_ck(PartHiding.is_animal_wear(s), "shape %d is animal-wear" % s)
for s in [0, 5, 99, 104, 201]:
_ck(not PartHiding.is_animal_wear(s), "shape %d not animal-wear" % s)
func _test_dress_and_bouquet() -> void:
_ck(PartHiding.is_wearing_dress(201), "shape 201 is wedding dress")
for s in [0, 200, 202, 100]:
_ck(not PartHiding.is_wearing_dress(s), "shape %d not dress" % s)
for v in [50201, 50202, 50203, 50204]:
_ck(PartHiding.is_bouquet(v), "vnum %d is bouquet" % v)
for v in [0, 50200, 50205, 19]:
_ck(not PartHiding.is_bouquet(v), "vnum %d not bouquet" % v)
func _test_changable_weapon() -> void:
# 婚纱:只有捧花可换
_ck(PartHiding.is_changable_weapon(50201, 201), "dress + bouquet -> changable")
_ck(not PartHiding.is_changable_weapon(19, 201), "dress + sword -> not changable")
# 非婚纱 shape:任何武器可换(动物时装的隐藏走 weapon_hidden,不走这条)
_ck(PartHiding.is_changable_weapon(19, 5), "normal shape + sword -> changable")
_ck(PartHiding.is_changable_weapon(19, 100), "animal-wear shape not blocked by __IsChangableWeapon")
func _test_weapon_hidden() -> void:
_ck(not PartHiding.weapon_hidden(5, false, 19), "normal shape, not poly -> weapon shown")
_ck(PartHiding.weapon_hidden(5, true, 19), "poly -> weapon hidden (any shape)")
_ck(PartHiding.weapon_hidden(101, false, 19), "animal-wear shape -> weapon hidden")
_ck(PartHiding.weapon_hidden(201, false, 19), "dress + non-bouquet -> weapon hidden")
_ck(not PartHiding.weapon_hidden(201, false, 50203), "dress + bouquet -> weapon shown")
_ck(PartHiding.weapon_hidden(201, false), "dress + no weapon -> hidden")
func _test_hair_hidden() -> void:
_ck(not PartHiding.hair_hidden(5, false), "normal -> hair shown")
_ck(PartHiding.hair_hidden(5, true), "poly -> hair hidden")
_ck(PartHiding.hair_hidden(102, false), "animal-wear -> hair hidden")
_ck(not PartHiding.hair_hidden(201, false), "dress -> hair NOT hidden")
func _test_body_shape() -> void:
_ck(PartHiding.body_shape(3, false) == 3, "normal shape passthrough")
_ck(PartHiding.body_shape(100, false) == 100, "animal-wear shape kept (出时装体)")
_ck(PartHiding.body_shape(3, true) == 0, "poly -> body shape 0")
_ck(PartHiding.body_shape(201, true) == 0, "poly overrides dress shape")
func _test_effective_weapon() -> void:
_ck(PartHiding.effective_weapon(19, 5, false) == 19, "normal -> weapon passthrough")
_ck(PartHiding.effective_weapon(19, 100, false) == 0, "animal-wear -> weapon 0")
_ck(PartHiding.effective_weapon(50201, 201, false) == 50201, "dress + bouquet -> keep bouquet")
_ck(PartHiding.effective_weapon(19, 201, false) == 0, "dress + sword -> 0")
_ck(PartHiding.effective_weapon(19, 5, true) == 0, "poly -> weapon 0")