111 lines
6.4 KiB
GDScript
111 lines
6.4 KiB
GDScript
# text_tail_test —— §8.8 头顶「称号 / 等级 / 公会名」子标签 1:1:
|
||
# GetTitleColor(g_akD3DXClrTitle)、RefreshTextTail 的 TITLE_NONE / 越界分支、
|
||
# UpdateTextTailLevel 的 "Lv %d" + s_kLevelColor、RegisterCharacterTextTail 的
|
||
# dwGuildID!=0 / "Noname" 兜底、AttachTextTail 的 110/10 高度、EnablePKTitle 开关。
|
||
# godot --headless --path project --script text_tail_test.gd
|
||
# 退出码 0 = 全过。
|
||
extends SceneTree
|
||
|
||
const TextTail = preload("res://text_tail.gd")
|
||
const EntityRules = preload("res://entity_rules.gd")
|
||
|
||
var _fail := 0
|
||
func _ck(c: bool, m: String) -> void:
|
||
if not c:
|
||
_fail += 1
|
||
printerr("FAIL: " + m)
|
||
|
||
func _init() -> void:
|
||
_run()
|
||
if _fail == 0:
|
||
print("PASS: text_tail_test (§8.8 GetTitleColor / RefreshTextTail / UpdateTextTailLevel 1:1)")
|
||
quit(0)
|
||
else:
|
||
printerr("%d check(s) failed" % _fail)
|
||
quit(1)
|
||
|
||
func _run() -> void:
|
||
# --- 0. 常量(InstanceBase.h / PythonTextTail.cpp)------------------------
|
||
_ck(TextTail.TITLE_NUM == 9, "TITLE_NUM == 9")
|
||
_ck(TextTail.TITLE_NONE == 4, "TITLE_NONE == 4")
|
||
_ck(TextTail.GUILD_NAME_FALLBACK == "Noname", "guild fallback == \"Noname\"")
|
||
# s_kLevelColor = D3DXCOLOR(152/255, 255/255, 51/255, 1)
|
||
_ck(TextTail.LEVEL_COLOR.is_equal_approx(Color8(152, 255, 51)), "LEVEL_COLOR == (152,255,51)")
|
||
# c_TextTail_Guild_Name_Color = 0xFFEFD3FF -> RGB (239,211,255)
|
||
_ck(TextTail.GUILD_NAME_COLOR.is_equal_approx(Color8(239, 211, 255)), "GUILD_NAME_COLOR == 0xEFD3FF")
|
||
|
||
# --- 1. GetTitleColor:g_akD3DXClrTitle[grade](introloading TITLE_COLOR_DICT)
|
||
_ck(TextTail.title_color(0).is_equal_approx(Color8(0, 204, 255)), "title_color(0) == GOOD_4 (0,204,255)")
|
||
_ck(TextTail.title_color(1).is_equal_approx(Color8(0, 144, 255)), "title_color(1) == GOOD_3 (0,144,255)")
|
||
_ck(TextTail.title_color(2).is_equal_approx(Color8(92, 110, 255)), "title_color(2) == GOOD_2 (92,110,255)")
|
||
_ck(TextTail.title_color(3).is_equal_approx(Color8(155, 155, 255)), "title_color(3) == GOOD_1 (155,155,255)")
|
||
_ck(TextTail.title_color(4).is_equal_approx(Color8(255, 255, 255)), "title_color(4) == NORMAL (255,255,255)")
|
||
_ck(TextTail.title_color(5).is_equal_approx(Color8(207, 117, 0)), "title_color(5) == EVIL_1 (207,117,0)")
|
||
_ck(TextTail.title_color(6).is_equal_approx(Color8(235, 83, 0)), "title_color(6) == EVIL_2 (235,83,0)")
|
||
_ck(TextTail.title_color(7).is_equal_approx(Color8(227, 0, 0)), "title_color(7) == EVIL_3 (227,0,0)")
|
||
_ck(TextTail.title_color(8).is_equal_approx(Color8(255, 0, 0)), "title_color(8) == EVIL_4 (255,0,0)")
|
||
# uGrade >= TITLE_NUM -> 白(GetTitleColor 的 s_kD3DXClrTitleDefault)
|
||
_ck(TextTail.title_color(9).is_equal_approx(Color(1, 1, 1)), "title_color(9) -> white")
|
||
_ck(TextTail.title_color(-1).is_equal_approx(Color(1, 1, 1)), "title_color(-1) -> white")
|
||
|
||
# --- 2. title_name_key / level_text / text_tail_height 字面 ---------------
|
||
_ck(TextTail.title_name_key(0) == "PVP_LEVEL0", "title_name_key(0) == PVP_LEVEL0")
|
||
_ck(TextTail.title_name_key(8) == "PVP_LEVEL8", "title_name_key(8) == PVP_LEVEL8")
|
||
_ck(TextTail.level_text(1) == "Lv 1", "level_text(1) == \"Lv 1\"")
|
||
_ck(TextTail.level_text(99) == "Lv 99", "level_text(99) == \"Lv 99\"")
|
||
_ck(TextTail.text_tail_height(true) == 110.0, "text_tail_height(mounted) == 110")
|
||
_ck(TextTail.text_tail_height(false) == 10.0, "text_tail_height(on foot) == 10")
|
||
|
||
# --- 3. RefreshTextTail 称号分支(按 GetAlignmentGrade)------------------
|
||
TextTail.set_pk_title_enabled(true)
|
||
# alignment 0 -> grade 4 == TITLE_NONE -> 不显示(DetachTitle)
|
||
var t_none := TextTail.refresh_title(0)
|
||
_ck(int(t_none["grade"]) == 4, "align 0 -> grade 4")
|
||
_ck(not t_none["show_title"], "grade TITLE_NONE -> show_title false")
|
||
# alignment 12000 -> grade 0 -> 显示 GOOD_4
|
||
var t_good := TextTail.refresh_title(12000)
|
||
_ck(int(t_good["grade"]) == 0 and t_good["show_title"], "align 12000 -> grade 0, show_title true")
|
||
_ck(t_good["name_key"] == "PVP_LEVEL0", "grade 0 name_key == PVP_LEVEL0")
|
||
_ck(t_good["color"].is_equal_approx(Color8(0, 204, 255)), "grade 0 title colour GOOD_4")
|
||
# alignment -12001 -> grade 8 -> EVIL_4
|
||
var t_evil := TextTail.refresh_title(-12001)
|
||
_ck(int(t_evil["grade"]) == 8 and t_evil["show_title"], "align -12001 -> grade 8, show_title true")
|
||
_ck(t_evil["color"].is_equal_approx(Color8(255, 0, 0)), "grade 8 title colour EVIL_4")
|
||
# grade 3(align 1000)显示,grade 5(align -1)显示
|
||
_ck(TextTail.refresh_title(1000)["show_title"], "grade 3 shows title")
|
||
_ck(TextTail.refresh_title(-1)["show_title"], "grade 5 shows title")
|
||
|
||
# --- 4. UpdateTextTailLevel / AttachLevel ------------------------------
|
||
var lv := TextTail.refresh_level(42)
|
||
_ck(lv["show_level"] and lv["text"] == "Lv 42", "level 42 -> \"Lv 42\"")
|
||
_ck(lv["color"].is_equal_approx(Color8(152, 255, 51)), "level colour == s_kLevelColor")
|
||
# m_dwLevel 0 -> AttachTextTail 不调 UpdateTextTailLevel
|
||
_ck(not TextTail.refresh_level(0)["show_level"], "level 0 -> no level tag")
|
||
|
||
# --- 5. RegisterCharacterTextTail 公会名分支 --------------------------
|
||
# dwGuildID == 0 -> 不建标签
|
||
_ck(not TextTail.refresh_guild(0, "Whatever")["show_guild"], "guild id 0 -> no guild tag")
|
||
# guild != 0 且解出名字
|
||
var g_ok := TextTail.refresh_guild(7, "RedKnights")
|
||
_ck(g_ok["show_guild"] and g_ok["name"] == "RedKnights", "guild 7 -> resolved name")
|
||
_ck(g_ok["color"].is_equal_approx(Color8(239, 211, 255)), "guild name colour")
|
||
# guild != 0 但 GetGuildName 失败(空串)-> "Noname"
|
||
var g_no := TextTail.refresh_guild(7, "")
|
||
_ck(g_no["show_guild"] and g_no["name"] == "Noname", "guild name lookup fail -> \"Noname\"")
|
||
|
||
# --- 6. EnablePKTitle(FALSE):AttachTitle / AttachLevel 早退 ------------
|
||
TextTail.set_pk_title_enabled(false)
|
||
_ck(not TextTail.is_pk_title_enabled(), "pk title disabled")
|
||
_ck(not TextTail.refresh_title(12000)["show_title"], "pk-title off -> title suppressed")
|
||
_ck(not TextTail.refresh_level(42)["show_level"], "pk-title off -> level suppressed")
|
||
# 公会名不受 bPKTitleEnable 影响(RegisterCharacterTextTail 里没这判)
|
||
_ck(TextTail.refresh_guild(7, "RedKnights")["show_guild"], "pk-title off -> guild name still shown")
|
||
# 还原静态状态,避免污染同进程后续测试
|
||
TextTail.set_pk_title_enabled(true)
|
||
_ck(TextTail.refresh_title(12000)["show_title"], "restore: pk title on again")
|
||
|
||
# --- 7. grade 与 entity_rules.alignment_grade 一致 --------------------
|
||
for a in [15000, 9000, 5000, 2000, 500, -500, -5000, -9000, -15000]:
|
||
_ck(int(TextTail.refresh_title(a)["grade"]) == EntityRules.alignment_grade(a),
|
||
"grade matches alignment_grade(%d)" % a)
|