Files
mtgodot-poc/project/pick_show_test.gd
T

70 lines
3.5 KiB
GDScript
Raw 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.
# pick_show_test —— §8.8 / §5.4 game.py OnRender「Picking」块分派 1:1
# IsPickedWindow 门、chr.Pick() 强显、targetBoard 强显、去重、__IsShowName() 分叉
# (非总显名字 -> item.Pick;总显名字 -> ShowAllTextTail + textTail.Pick)、
# SelectItemName 门。
# godot --headless --path project --script pick_show_test.gd
# 退出码 0 = 全过。
extends SceneTree
const PickShow = preload("res://pick_show.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: pick_show_test (§8.8/§5.4 OnRender Picking 分派 1:1)")
quit(0)
else:
printerr("%d check(s) failed" % _fail)
quit(1)
func _run() -> void:
var NP := PickShow.NO_PICK
_ck(NP == -1, "NO_PICK == -1")
# --- 0. char_pick_activegame.py:1533------------------------------------
_ck(PickShow.char_pick_active(true) == true, "鼠标在窗口 -> chr.Pick() 跑")
_ck(PickShow.char_pick_active(false) == false, "鼠标不在窗口 -> chr.Pick() 不跑")
# --- 1. forced_name_vids:1533..:1540 ShowCharacterTextTail 集合)--------
# 不在窗口 -> 空(连 target 强显也不做,参考里都在 :1533 门内)
_ck(PickShow.forced_name_vids(false, 2000, 1500) == [], "不在窗口 -> 无强显")
# 悬停命中 + 有目标框 -> 两个都强显,顺序 [hover, target]
_ck(PickShow.forced_name_vids(true, 2000, 1500) == [2000, 1500], "悬停+目标 -> [hover, target]")
# 只悬停命中
_ck(PickShow.forced_name_vids(true, 2000, 0) == [2000], "只悬停 -> [hover]")
# 只有目标框
_ck(PickShow.forced_name_vids(true, NP, 1500) == [1500], "只目标框 -> [target]")
_ck(PickShow.forced_name_vids(true, 0, 1500) == [1500], "hover=0 视为无 -> [target]")
# 悬停的正是目标 -> 去重
_ck(PickShow.forced_name_vids(true, 1500, 1500) == [1500], "悬停==目标 -> 去重成一个")
# 啥也没有
_ck(PickShow.forced_name_vids(true, NP, 0) == [], "在窗口但无命中无目标 -> 空")
# --- 2. should_pick_item:1543----------------------------------------
_ck(PickShow.should_pick_item(true, false) == true, "在窗口 且 非总显名字 -> item.Pick()")
_ck(PickShow.should_pick_item(true, true) == false, "总显名字 -> 不走 item.Pick()")
_ck(PickShow.should_pick_item(false, false) == false, "不在窗口 -> 不走 item.Pick()")
# --- 3. should_show_all_names / should_pick_text_tail:1552 / :1554--
_ck(PickShow.should_show_all_names(true) == true, "总显名字 -> ShowAllTextTail")
_ck(PickShow.should_show_all_names(false) == false, "非总显名字 -> 不 ShowAllTextTail")
_ck(PickShow.should_pick_text_tail(true) == true, "总显名字 -> textTail.Pick()")
_ck(PickShow.should_pick_text_tail(false) == false, "非总显名字 -> 不 textTail.Pick()")
# item 拾取的两条路互斥:非总显名字走 item.Pick,总显名字走 textTail.Pick
for isn in [true, false]:
var via_item := PickShow.should_pick_item(true, isn)
var via_tail := PickShow.should_pick_text_tail(isn)
_ck(via_item != via_tail, "在窗口时 item.Pick 与 textTail.Pick 恰好二选一(is_show_name=%s" % isn)
# --- 4. should_select_item_name:1560------------------------------
_ck(PickShow.should_select_item_name(7) == true, "PickingItemIndex=7 -> SelectItemName")
_ck(PickShow.should_select_item_name(0) == true, "PickingItemIndex=0(有效索引)-> SelectItemName")
_ck(PickShow.should_select_item_name(NP) == false, "PickingItemIndex=-1 -> 不 SelectItemName")