DeckReveal holds an animated roll's draws until each result lights; the cards-left count waits too. Fast rolls and any newer roll drop the holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
3.2 KiB
GDScript
73 lines
3.2 KiB
GDScript
extends TestBase
|
|
## 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.)
|
|
|
|
|
|
func _init() -> void:
|
|
if not await start_main():
|
|
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 threads")
|
|
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 thread (%d threads, %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")
|
|
|
|
await _test_deck_waits()
|
|
finish()
|
|
|
|
|
|
## Deck mode: an animated roll fades the drawn result only once it lights;
|
|
## a fast roll fades it at once.
|
|
func _test_deck_waits() -> void:
|
|
var t := main.data.get_table("wilderness")
|
|
t.card_mode = true
|
|
main.reshuffle_table(t.id)
|
|
main.layout._board_changed()
|
|
await _frames()
|
|
var total := main.cards_left(t.id).y
|
|
main.start_roll(t.id)
|
|
var eid := ""
|
|
for st: Dictionary in main.current["all"]:
|
|
if st.get("table_id") == t.id and st.has("entry_id"):
|
|
eid = st["entry_id"]
|
|
var card := main.card_for(t.id)
|
|
_check(eid != "" and card.rows[eid].modulate.a == 1.0, "mid-animation the drawn result isn't faded yet")
|
|
_check(main.cards_left(t.id).x == total, "mid-animation the count hasn't dropped")
|
|
var until := Time.get_ticks_msec() + 15000
|
|
while not main.current.get("done", false) and Time.get_ticks_msec() < until:
|
|
await process_frame
|
|
card = main.card_for(t.id)
|
|
var gone := (main.decks[t.id] as DeckState).remaining(t, t.find_entry(eid)) <= 0
|
|
_check(main.current.get("done", false), "the animated roll finished")
|
|
_check(card.rows[eid].modulate.a < 1.0 if gone else true, "after the animation the result fades")
|
|
_check(main.cards_left(t.id).x == total - 1, "after the animation the count drops")
|
|
main.start_roll(t.id, true)
|
|
_check(main.cards_left(t.id).x == total - 2, "a fast roll drops the count at once")
|
|
t.card_mode = false
|