extends SceneTree ## Fast roll (Shift-click): the whole result shows at once, with no animation. ## Run: godot --headless --path . -s res://tests/test_fast_roll.gd -- --sample ## (--sample keeps the app from reading or writing saved collections.) var _failures := 0 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 var main: Main = load("res://ui/main.tscn").instantiate() root.add_child(main) for i in 5: await process_frame if main._saving_enabled: print("Saving is enabled; refusing to roll.") quit(2) return main.rng.seed = 7 # A fast roll finishes in the same frame it starts. for i in 20: main.start_roll("wilderness", true) var all: Array = main.current["all"] _check(main.current.get("done", false), "fast roll is done immediately") _check(main.current["steps"].size() == all.size(), "fast roll shows every step at once") _check(main.board.pipes.pulse_key == "", "fast roll sends no bead down the pipes") var lit_steps := 0 for s: Dictionary in all: if s.has("entry_id") and not s.get("stop", false): lit_steps += 1 _check(main.is_entry_lit(str(s["table_id"]), str(s["entry_id"])), "every result on the path is lit") _check(main.lit_entries.size() == lit_steps, "only the path's results are lit") # Chains from Wilderness Travel are a single line, so n results have n - 1 pipes. _check(main.lit_pipes.size() == maxi(0, lit_steps - 1), "each link in the chain lights its pipe (%d pipes, %d results)" % [main.lit_pipes.size(), lit_steps]) for c in main.cards.values(): _check(not (c as TableCard)._rolling, "no card is left tumbling") # A normal roll still animates: it isn't finished in the same frame. main.start_roll("wilderness") _check(not main.current.get("done", false), "a normal roll still animates") # A fast roll started mid-animation takes over cleanly. main.start_roll("wilderness", true) _check(main.current.get("done", false), "a fast roll interrupts an animating one") for i in 90: await process_frame _check(main.current.get("done", false) and main.current.get("fast", false), "the interrupted roll doesn't overwrite the fast result") print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures]) quit(1 if _failures else 0) func _check(ok: bool, what: String) -> void: if not ok: _failures += 1 print(" ✗ ", what)