- Tray chips name their card in bold, dark text; how it was rolled follows, muted. - The card inspector lists Threads in (from which card and result) and Threads out (from which result, to which card); click one to select it. - A range typed backwards (start above end) is no longer swapped: the card warns and its die is greyed out until it's fixed. - Save as template… can replace one of your templates; the template list's Rename became Edit… (name, description, fill-in labels). - Spread ▾ export: the Table Tarot file first, other formats in a submenu. - Test spread section hints in plain words. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
3.8 KiB
GDScript
100 lines
3.8 KiB
GDScript
extends SceneTree
|
|
## Small UI items: backwards ranges warn and block rolling (no auto-swap), the
|
|
## inspector's thread lists, replacing a template, the tray chip's bold source
|
|
## name, and the export menu's Other formats.
|
|
## Run: godot --headless --path . -s res://tests/test_small_ui.gd -- --sample
|
|
|
|
var _failures := 0
|
|
var main: Main
|
|
|
|
|
|
func _init() -> void:
|
|
if not OS.get_cmdline_user_args().has("--sample"):
|
|
print("Run with -- --sample so the test can't touch saved data.")
|
|
quit(2)
|
|
return
|
|
main = load("res://ui/main.tscn").instantiate()
|
|
root.add_child(main)
|
|
await _frames(5)
|
|
await _test_backwards_range()
|
|
await _test_thread_lists()
|
|
_test_template_replace()
|
|
await _test_chip_and_export()
|
|
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
|
|
quit(1 if _failures else 0)
|
|
|
|
|
|
func _test_backwards_range() -> void:
|
|
var t := main.data.get_table("wilderness")
|
|
var e := t.entries[0]
|
|
e.range_lo = 40
|
|
e.range_hi = 10
|
|
var card := main.card_for("wilderness")
|
|
card.update_warning()
|
|
_check(e.range_lo == 40 and e.range_hi == 10, "the ends aren't swapped")
|
|
_check(RollRange.backwards(t) != "" and t.range_problems().contains("runs backwards"), "a warning says the range runs backwards")
|
|
_check(card.header_ui.roll_button.disabled, "the die button is greyed out")
|
|
main.rolling.start_roll("wilderness")
|
|
await _frames()
|
|
_check(not str(main.current).contains("wilderness") or main.current.is_empty() or main.current.get("table_id", "") != "wilderness", "it can't be rolled")
|
|
e.range_lo = 1
|
|
e.range_hi = 30
|
|
card.update_warning()
|
|
_check(not card.header_ui.roll_button.disabled, "fixing it enables the die again")
|
|
|
|
|
|
func _test_thread_lists() -> void:
|
|
main.set_mode(Main.Mode.BUILD)
|
|
await _frames()
|
|
main.select_card("road")
|
|
await _frames(3)
|
|
var texts: Array[String] = []
|
|
for b in main.inspector.find_children("*", "Button", true, false):
|
|
texts.append((b as Button).text)
|
|
var heads: Array[String] = []
|
|
for l in main.inspector.find_children("*", "Label", true, false):
|
|
heads.append((l as Label).text)
|
|
_check(heads.any(func(s: String) -> bool: return s.begins_with("THREADS IN (")), "the card inspector lists threads in")
|
|
_check(texts.any(func(s: String) -> bool: return s.begins_with("Wilderness Travel · ")), "a thread in names its card and result: %s" % str(texts.slice(0, 6)))
|
|
_check(texts.any(func(s: String) -> bool: return s.contains(" → ")), "threads out name where they go")
|
|
|
|
|
|
func _test_template_replace() -> void:
|
|
var lib := main.templating.templates()
|
|
var tpl := TemplateKit.make(main.data, ["road"], "card", "Road")
|
|
var id := lib.add(tpl)
|
|
var changed := tpl.duplicate(true)
|
|
changed["name"] = "Road, revised"
|
|
changed["replace_id"] = id
|
|
main.templating.store_template(changed)
|
|
_check(lib.get_template(id).get("name") == "Road, revised", "Replace saves over the same template")
|
|
_check(not lib.get_template(id).has("replace_id"), "without the replace marker")
|
|
var count := lib.list().size()
|
|
main.templating.store_template(tpl.duplicate(true))
|
|
_check(lib.list().size() == count + 1, "a plain save still adds a new one")
|
|
|
|
|
|
func _test_chip_and_export() -> void:
|
|
main.set_mode(Main.Mode.PLAY)
|
|
main.rolling.start_roll("road", true)
|
|
await _frames(4)
|
|
var bold := false
|
|
for l in main.tray.find_children("*", "Label", true, false):
|
|
var lab := l as Label
|
|
if lab.text == "Road Encounter" and lab.get_theme_font("font") == Style.body_bold():
|
|
bold = true
|
|
_check(bold, "the chip names its card in bold")
|
|
var pm := main.top_bar._board_menu.get_popup()
|
|
var subs := pm.find_children("*", "PopupMenu", false, false)
|
|
_check(subs.size() == 1 and (subs[0] as PopupMenu).item_count == IoMenu.EXPORTS.size() - 1, "rare formats sit under Other formats")
|
|
|
|
|
|
func _frames(n: int = 2) -> void:
|
|
for i in n:
|
|
await process_frame
|
|
|
|
|
|
func _check(ok: bool, what: String) -> void:
|
|
if not ok:
|
|
_failures += 1
|
|
print("FAIL ", what)
|