This commit is contained in:
Forrest 2026-10-01 23:01:56 -04:00
parent 0cba7f5ee0
commit 32ed347b58
172 changed files with 5464 additions and 582 deletions

103
tests/attack_click.gd Normal file
View file

@ -0,0 +1,103 @@
extends SceneTree
## Plays games through the game scene, headless, with you driven by the greedy bot. Whenever it
## would attack, it does so by clicking instead: the attacker, then the middle of the target
## location, where the defenders' cards stand. Checks that the click attacks.
##
## godot --headless --script res://tests/attack_click.gd -- [--games N] [--seed N]
var _game: Node
var _games := 4
var _seed := 7
var _played := 0
var _hb := GreedyBot.new(GreedyBot.STYLES.greedy.params)
var _wait := -1
var _attacks := 0
var _on_defender := 0
var _missed := 0
var _began := false
func _init() -> void:
var args := OS.get_cmdline_user_args()
var i := 0
while i < args.size():
match args[i]:
"--games":
i += 1
_games = int(args[i])
"--seed":
i += 1
_seed = int(args[i])
i += 1
Card3D.instant = true
_game = load("res://scenes/game.tscn").instantiate()
root.add_child.call_deferred(_game)
func _process(_d: float) -> bool:
if _game == null or not _game.is_node_ready():
return false
if not _began:
_began = true
_new_game()
return false
if Engine.get_physics_frames() < _wait:
return false
var m: LocalMatch = _game.match_
for n in 400:
if not Util.errors.is_empty():
print("seed %d: engine error: %s" % [m.setup.seed, "; ".join(Util.errors)])
return _finish(true)
if m.is_over():
_played += 1
if _played >= _games:
return _finish(false)
_new_game()
return false
if m.bot_to_act():
m.bot_step()
continue
# Let physics catch up with the table before clicking it.
if _wait < 0:
_wait = Engine.get_physics_frames() + 2
return false
_wait = -1
var a: Dictionary = _hb.choose(RulesEngine.view_for(m.s, m.human), m.legal(), m.human)
if a.type == "attack":
_click_attack(m, a)
else:
m.act(a)
return false
return false
func _click_attack(m: LocalMatch, a: Dictionary) -> void:
var table: GameTable = _game.table
var mv: Dictionary = _game.moves.filter(func(x): return x.action == a)[0]
_attacks += 1
_game._select(mv.source)
var sp := table.camera.unproject_position(BoardLayout.at[a.to] + Vector3(0, 0.01, 0))
var key := table.key_at(sp)
if key.begins_with("anomaly:"):
_on_defender += 1
var before := m.actions.size()
_game._pick(key, sp)
if _game.hud.popover_open():
_game.hud.hide_popover()
if m.actions.size() == before:
_missed += 1
print("seed %d: clicking %s (at %s's middle) didn't attack" % [m.setup.seed, key, a.to])
m.act(a)
func _new_game() -> void:
_game._paused = true
_game.hud.close_modal()
_game.start_game({"seed": _seed + _played, "human": _played % 2, "style": "greedy"})
Util.errors.clear()
func _finish(failed: bool) -> bool:
print("attack click: %d game(s), %d attacks clicked (%d on a defender's card), %d missed" % [_played, _attacks, _on_defender, _missed])
quit(1 if failed or _missed > 0 else 0)
return false

View file

@ -149,7 +149,8 @@ func _check_game(t: Dictionary, index: Dictionary) -> Dictionary:
if dealt != decks:
return fail.call(0, "dealt different decks: %s vs TS %s" % [JSON.stringify(dealt), JSON.stringify(decks)])
var s = RulesEngine.create_game({"pool": _pool, "decks": decks, "seed": seed, "rules": rules, "log": true})
# With events on, so the run also shows that recording them leaves the rules alone.
var s = RulesEngine.create_game({"pool": _pool, "decks": decks, "seed": seed, "rules": rules, "log": true, "events": true})
if s == null or not Util.errors.is_empty():
return fail.call(0, "create_game failed: %s" % "; ".join(Util.errors))
var initial: Dictionary = t.initial
@ -226,11 +227,13 @@ func _compare(s: Dictionary, t: Dictionary, n: int, state_md5: String, log_md5:
return ""
## The state as fingerprinted: without its card defs (fixed for the game) and log (checked by line).
## The state as fingerprinted: without its card defs (fixed for the game), log (checked by line) and
## events (TS has none, see godot-plan.md §3).
func _body(s: Dictionary) -> Dictionary:
var b := s.duplicate()
b.erase("defs")
b.erase("log")
b.erase("events")
return b

342
tests/events.gd Normal file
View file

@ -0,0 +1,342 @@
extends SceneTree
## Plays random-vs-random games with events on (godot-plan.md §3) and checks after every action that
## the event stream, folded up from the start, gives the state: each player's Bandwidth, each
## gateway's Firewall, each location's owner, the zone of every card, where every Anomaly stands,
## which Anomalies are face up, and their counters. Every event's "from" must match the fold too, and
## the Bandwidth safety net (State.reconcile_bandwidth) must never be needed.
##
## godot --headless --script res://tests/events.gd -- [--games N] [--seed N]
var _fold: Dictionary
var _seen := 0
var _errors: Array[String] = []
func _init() -> void:
var games := 30
var first := 1
var args := OS.get_cmdline_user_args()
var i := 0
while i < args.size():
match args[i]:
"--games":
i += 1
games = int(args[i])
"--seed":
i += 1
first = int(args[i])
i += 1
var pool := Cards.load_cards()
var rules := Rules.defaults()
var started := Time.get_ticks_msec()
var failed := 0
var steps := 0
var events := 0
var kinds := {}
State.event_fixes = 0
for seed in range(first, first + games):
Util.errors.clear()
_errors = []
var err := _play(pool, rules, seed)
if err == "" and not Util.errors.is_empty():
err = "engine error: %s" % "; ".join(Util.errors)
if err == "" and State.event_fixes > 0:
err = "the Bandwidth safety net added %d event(s)" % State.event_fixes
if err != "":
failed += 1
print("seed %d: %s" % [seed, err])
State.event_fixes = 0
continue
steps += _fold.steps
events += _seen
for k in _fold.kinds:
kinds[k] = kinds.get(k, 0) + _fold.kinds[k]
var secs := (Time.get_ticks_msec() - started) / 1000.0
var counts := PackedStringArray()
var names := kinds.keys()
names.sort()
for k in names:
counts.append("%s %d" % [k, kinds[k]])
print("events: %s" % ", ".join(counts))
print("events: %d/%d games consistent (%d steps, %d events, %.1fs)" % [games - failed, games, steps, events, secs])
var match_err := _check_match(pool, first)
if match_err != "":
failed += 1
print("LocalMatch: %s" % match_err)
quit(0 if failed == 0 else 1)
## LocalMatch records events and hands out yours: the bot's draws hidden, yours shown.
func _check_match(pool: Dictionary, seed: int) -> String:
var rules := LocalMatch.rules_from([])
var setup := {"seed": seed, "human": 0, "decks": LocalMatch.random_decks(pool, seed, rules), "rules": []}
var m := LocalMatch.new(pool, setup, RandomBot.new(seed))
var you := RandomBot.new(seed + 1)
var from := m.event_count()
if from == 0:
return "no events after setup"
for n in 300:
if m.is_over():
break
if m.bot_to_act():
m.bot_step()
else:
m.act(you.choose(m.view(), m.legal(), m.human))
var mine := m.events_since(from)
if mine.size() != m.event_count() - from:
return "events_since(%d) has %d events, expected %d" % [from, mine.size(), m.event_count() - from]
var drew := [0, 0]
for ev in mine:
if ev.k == "drew":
drew[ev.p] += 1
if (ev.p == m.bot_side) != (ev.card == -1):
return "a draw shown to the wrong player: %s" % JSON.stringify(ev)
if drew[0] == 0 or drew[1] == 0:
return "no draws seen: %s" % str(drew)
return ""
## Plays one game, checking after every action. Returns "" or the first problem.
func _play(pool: Dictionary, rules: Dictionary, seed: int) -> String:
var decks := Play.deal(pool, seed, rules)
var s = RulesEngine.create_game({"pool": pool, "decks": decks, "seed": seed, "rules": rules, "log": true, "events": true})
if s == null:
return "create_game failed"
_start_fold(s)
var err := _check(s, "setup")
if err != "":
return err
var random: Callable = Play.bots().random
var players := [random.call(seed * 2 + 1), random.call(seed * 2 + 2)]
var n := 0
while not s.over:
n += 1
if n > Play.MAX_ACTIONS:
return "didn't finish"
var p: int = RulesEngine.decider(s)
var legal := RulesEngine.legal_actions(s)
var view := RulesEngine.view_for(s, p)
if view.events != null:
return "view_for keeps the events"
var a: Dictionary = players[p].choose(view, legal, p)
if not RulesEngine.apply_action(s, a, legal):
return "illegal action"
_fold.steps += 1
err = _check(s, "step %d (%s), turn %d" % [n, RulesEngine.action_key(a), s.turn])
if err != "":
return err
return _check_views(s)
# ---------------------------------------------------------------------------------------------
# The fold
func _start_fold(s: Dictionary) -> void:
_seen = 0
var zone := {}
for c in s.cards:
var kind: String = s.defs[c.name].kind
zone[c.id] = "slot" if kind == "anomaly" else ("serverPile" if kind == "server" else "deck")
var owner := {}
# No event captures the starts; folding from them, any capture event must agree.
for loc in GameMap.START_LOC:
owner[loc] = GameMap.START_LOC.find(loc)
for loc in GameMap.LOCATIONS:
if not owner.has(loc):
owner[loc] = null
var at := {}
var face := {}
var counters := {}
for p in 2:
for slot in range(1, 9):
var k := "%d:%d" % [p, slot]
at[k] = null
counters[k] = {"infection": 0, "bugs": 0, "damage": 0}
if slot <= 4:
face[k] = false
_fold = {"bandwidth": [0, 0], "firewalls": {}, "owner": owner, "zone": zone, "at": at, "face": face,
"counters": counters, "turn": 0, "active": -1, "combats": {}, "steps": 0, "kinds": {}}
## Folds the new events, then compares the fold with the state.
func _check(s: Dictionary, where: String) -> String:
var events: Array = s.events
for i in range(_seen, events.size()):
var err := _apply(s, events[i])
if err != "":
return "%s: event %d %s: %s" % [where, i, JSON.stringify(events[i]), err]
_seen = events.size()
var err := _compare(s)
return "" if err == "" else "%s: %s" % [where, err]
func _zone_matches(zone: String, from: String) -> bool:
return from != "" and (zone == from or zone.begins_with(from + ":"))
func _apply(s: Dictionary, ev: Dictionary) -> String:
var f := _fold
f.kinds[ev.k] = f.kinds.get(ev.k, 0) + 1
var rk := func(r) -> String: return "%d:%d" % [r.player, r.slot]
match ev.k:
"turn":
if ev.turn != f.turn + 1:
return "turn %d after %d" % [ev.turn, f.turn]
f.turn = ev.turn
f.active = ev.p
"bandwidth":
if ev.from != f.bandwidth[ev.p]:
return "from %d, but the fold has %d" % [ev.from, f.bandwidth[ev.p]]
if ev.from == ev.to:
return "no change"
f.bandwidth[ev.p] = ev.to
"firewall":
if ev.from != f.firewalls.get(ev.line, 0):
return "from Lv %d, but the fold has %d" % [ev.from, f.firewalls.get(ev.line, 0)]
f.firewalls[ev.line] = ev.to
"captured":
if ev.from != f.owner[ev.loc]:
return "from %s, but the fold has %s" % [ev.from, f.owner[ev.loc]]
f.owner[ev.loc] = ev.p
"drew":
if f.zone[ev.card] != "deck":
return "drawn from %s" % f.zone[ev.card]
if s.cards[ev.card].owner != ev.p:
return "not the drawer's card"
f.zone[ev.card] = "hand"
"hand", "discard":
if not _zone_matches(f.zone[ev.card], ev.from):
return "from %s, but the fold has %s" % [ev.from, f.zone[ev.card]]
if s.cards[ev.card].owner != ev.p:
return "p isn't the owner"
f.zone[ev.card] = ev.k
if ev.k == "discard" and ev.why == "":
return "no why"
"pile":
if not _zone_matches(f.zone[ev.card], ev.from):
return "from %s, but the fold has %s" % [ev.from, f.zone[ev.card]]
f.zone[ev.card] = ev.zone
"install":
var was: String = f.zone[ev.card]
if was != "hand" and was != "serverPile":
return "installed from %s" % was
f.zone[ev.card] = ("play:" + ev.at.substr(4)) if ev.at.begins_with("loc:") else "worn:" + ev.at.substr(8)
"stack":
if ev.kind == "execution":
if f.zone[ev.card] != "hand":
return "played from %s" % f.zone[ev.card]
f.zone[ev.card] = "stack"
"placed":
if f.at[rk.call(ev.ref)] != null:
return "placed, but it stands on %s" % f.at[rk.call(ev.ref)]
f.at[rk.call(ev.ref)] = ev.loc
"moved":
if f.at[rk.call(ev.ref)] != ev.from:
return "moved from %s, but it stands on %s" % [ev.from, f.at[rk.call(ev.ref)]]
f.at[rk.call(ev.ref)] = ev.to
"recalled", "destroyed":
var from = ev.get("from", ev.get("loc"))
if from == null or f.at[rk.call(ev.ref)] != from:
return "left %s, but it stands on %s" % [from, f.at[rk.call(ev.ref)]]
f.at[rk.call(ev.ref)] = null
"flipped":
if f.face[rk.call(ev.ref)]:
return "already face up"
f.face[rk.call(ev.ref)] = true
"damaged":
if ev.amount <= 0 or f.at[rk.call(ev.ref)] == null:
return "bad damage"
f.counters[rk.call(ev.ref)].damage += ev.amount
"counter":
var c: Dictionary = f.counters[rk.call(ev.ref)]
if c[ev.what] != ev.from:
return "%s from %d, but the fold has %d" % [ev.what, ev.from, c[ev.what]]
c[ev.what] = ev.to
"combat":
if f.combats.has(ev.id):
return "combat %d twice" % ev.id
f.combats[ev.id] = ev.loc
"rolled":
if not f.combats.values().has(ev.loc):
return "a roll with no combat there"
"rerolled":
if ev.dice.is_empty() and s.combat == null:
return "a reroll with no combat"
_:
return "unknown kind"
return ""
## The state's zone for every card, in the fold's terms.
func _zones(s: Dictionary) -> Dictionary:
var out := {}
for p in 2:
var pl: Dictionary = s.players[p]
for zone in ["hand", "deck", "serverPile", "discard"]:
for id in pl[zone]:
out[id] = zone
for i in pl.anomalies.size():
var av: Dictionary = pl.anomalies[i]
for hw in av.hardware:
out[hw] = "worn:%d:%d" % [p, i + 1]
if i < 4 and av.card >= 0:
out[av.card] = "slot"
for loc in s.locations:
var L: Dictionary = s.locations[loc]
if L.server != null:
out[L.server] = "play:" + loc
for id in L.programs:
out[id] = "play:" + loc
for item in s.stack:
if item.kind == "execution":
out[item.card] = "stack"
return out
func _compare(s: Dictionary) -> String:
var f := _fold
for p in 2:
if f.bandwidth[p] != s.players[p].bandwidth:
return "%s's Bandwidth folds to %d, is %d" % [State.player_name(p), f.bandwidth[p], s.players[p].bandwidth]
for line in GameMap.LINES:
if f.firewalls.get(line.id, 0) != s.firewalls.get(line.id, 0):
return "the Firewall on %s folds to %d, is %d" % [line.id, f.firewalls.get(line.id, 0), s.firewalls.get(line.id, 0)]
for loc in GameMap.LOCATIONS:
if f.owner[loc] != s.locations[loc].owner:
return "%s's owner folds to %s, is %s" % [loc, f.owner[loc], s.locations[loc].owner]
var zones := _zones(s)
for id in f.zone:
if f.zone[id] != zones.get(id, "?"):
return "%s (%d) folds to %s, is in %s" % [s.cards[id].name, id, f.zone[id], zones.get(id, "?")]
for p in 2:
for slot in range(1, 9):
var k := "%d:%d" % [p, slot]
var av: Dictionary = s.players[p].anomalies[slot - 1]
if f.at[k] != av.at:
return "Anomaly %s folds to %s, stands on %s" % [k, f.at[k], av.at]
if slot <= 4 and f.face[k] != av.faceUp:
return "Anomaly %s folds to face %s, is %s" % [k, "up" if f.face[k] else "down", "up" if av.faceUp else "down"]
var want := State.counters_of(av)
if f.counters[k] != want:
return "Anomaly %s's counters fold to %s, are %s" % [k, f.counters[k], want]
if f.turn != s.turn or (not s.over and f.active != s.active):
return "turn folds to %d (%d), is %d (%d)" % [f.turn, f.active, s.turn, s.active]
return ""
## Each player's events: the same stream, with the other player's draws hidden.
func _check_views(s: Dictionary) -> String:
for p in 2:
var mine := State.events_for(s, p)
if mine.size() != s.events.size():
return "events_for(%d) has %d events of %d" % [p, mine.size(), s.events.size()]
for i in mine.size():
var ev: Dictionary = mine[i]
var real: Dictionary = s.events[i]
if ev.k == "drew" and ev.p != p and ev.card != -1:
return "events_for(%d) shows the other player's draw" % p
if ev.k == "drew" and ev.p == p and ev.card != real.card:
return "events_for(%d) hides its own draw" % p
if not State.events_for(s, p, s.events.size()).is_empty():
return "events_for from the end isn't empty"
return ""

1
tests/events.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dlcfd2ok4i5qh

37
tests/menu_screenshot.gd Normal file
View file

@ -0,0 +1,37 @@
extends SceneTree
## Renders the title screen and saves a screenshot. Needs a display (not --headless).
##
## godot --script res://tests/menu_screenshot.gd -- [--setup] [--out PATH]
var _menu: Node
var _out := "/tmp/files-tcg-menu.png"
var _setup := false
var _frames := 0
func _init() -> void:
var args := OS.get_cmdline_user_args()
var i := 0
while i < args.size():
match args[i]:
"--out":
i += 1
_out = args[i]
"--setup":
_setup = true
i += 1
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_NO_FOCUS, true)
if _setup:
SceneRouter.args = {"screen": "setup"}
_menu = load("res://scenes/menu.tscn").instantiate()
_menu.set_process_unhandled_input(false)
root.add_child.call_deferred(_menu)
func _process(_delta: float) -> bool:
_frames += 1
if _frames == 90:
root.get_viewport().get_texture().get_image().save_png(_out)
print("saved %s" % _out)
return true
return false

View file

@ -0,0 +1 @@
uid://bjawqnk48u86v

109
tests/present_smoke.gd Normal file
View file

@ -0,0 +1,109 @@
extends SceneTree
## Plays whole games through the game scene with the animations on (sped up), so every engine
## event goes through the presenter and the table's motion paths in real frames. The bot runs on
## its thread as in play, and waits for each show to end; your moves are random picks made once
## the show is over. Fails on an engine error or a stuck game.
##
## godot --headless --script res://tests/present_smoke.gd -- [--games N] [--seed N] [--speed X]
var _game: Node
var _games := 2
var _seed := 1
var _speed := 0.08
var _played := 0
var _moves := 0
var _shows := 0
var _events := 0
var _rng := RandomNumberGenerator.new()
var _started := 0
var _idle_frames := 0
var _failed := false
var _frames := 0
func _init() -> void:
var args := OS.get_cmdline_user_args()
var i := 0
while i < args.size():
match args[i]:
"--games":
i += 1
_games = int(args[i])
"--seed":
i += 1
_seed = int(args[i])
"--speed":
i += 1
_speed = float(args[i])
i += 1
_rng.seed = _seed
_game = load("res://scenes/game.tscn").instantiate()
root.add_child.call_deferred(_game)
_started = Time.get_ticks_msec()
func _process(_delta: float) -> bool:
if _game == null or not _game.is_node_ready():
return false
_frames += 1
if _frames == 1:
Motion.speed_scale = _speed
_new_game()
return false
var m: LocalMatch = _game.match_
if not Util.errors.is_empty():
print("seed %d: engine error: %s" % [m.setup.seed, "; ".join(Util.errors)])
_failed = true
return _finish()
if m.is_over():
print("seed %d: %s after %d moves" % [m.setup.seed, Hud.status_line(m.view(), m), m.actions.size()])
_played += 1
if _played >= _games:
return _finish()
_new_game()
return false
var presenter: Presenter = _game.presenter
if presenter.busy():
_idle_frames = 0
return false
_idle_frames += 1
if m.human_to_act() and _idle_frames > 1:
_idle_frames = 0
var before := m.event_count()
_pick(m)
_events += m.event_count() - before
_shows += 1
elif _idle_frames > 3000:
print("stuck: no move for 3000 frames (bot to act: %s)" % m.bot_to_act())
_failed = true
return _finish()
return false
func _new_game() -> void:
_game.hud.close_modal()
_game.settings.botDelay = 0.0
_game.start_game({"seed": _seed + _played, "human": _played % 2, "style": "greedy"})
Util.errors.clear()
func _pick(_m: LocalMatch) -> void:
_moves += 1
var moves: Array = _game.moves
if moves.is_empty():
return
var others := moves.filter(func(mv): return mv.action.type not in ["end", "pass"])
var pick: Dictionary
if not others.is_empty() and _rng.randf() < 0.65:
pick = others[_rng.randi() % others.size()]
else:
var stop := moves.filter(func(mv): return mv.action.type in ["end", "pass"])
pick = stop[0] if not stop.is_empty() else moves[_rng.randi() % moves.size()]
_game._play(pick)
func _finish() -> bool:
var secs := (Time.get_ticks_msec() - _started) / 1000.0
print("present smoke: %d game(s), %d of your moves, %d events shown, %d frames, %.1fs" % [_played, _moves, _events, _frames, secs])
quit(1 if _failed else 0)
return false

View file

@ -0,0 +1 @@
uid://bgdqoa1quiiuo

View file

@ -3,6 +3,13 @@ extends SceneTree
## display (not --headless).
##
## godot --script res://tests/screenshot.gd -- [--seed N] [--moves N] [--out PATH] [--top] [--north] [--select KEY|auto]
## [--focus [N]] [--terminal] [--frames N] [--at SECONDS] [--zoom X] [--combat]
##
## --combat keeps playing past --moves until a combat is under way at one of your decisions.
## --at takes the shot that many seconds after the moves are made instead of at a frame, to catch
## an animation part way (use with --disable-vsync, as a hidden window's frames can be throttled).
##
## --focus opens the hand-focus row, with its Nth card under the mouse; --terminal opens the log.
var _game: Node
var _seed := 1
@ -12,6 +19,13 @@ var _top := false
var _select := ""
var _human := 0
var _frames := 0
var _shot_at := 70
var _focus := -2
var _terminal := false
var _zoom := 1.0
var _combat := false
var _at := -1.0
var _dealt_at := 0
var _rng := RandomNumberGenerator.new()
@ -36,6 +50,24 @@ func _init() -> void:
"--select":
i += 1
_select = args[i]
"--focus":
_focus = -1
if i + 1 < args.size() and args[i + 1].is_valid_int():
i += 1
_focus = int(args[i])
"--terminal":
_terminal = true
"--frames":
i += 1
_shot_at = int(args[i])
"--zoom":
i += 1
_zoom = float(args[i])
"--combat":
_combat = true
"--at":
i += 1
_at = float(args[i])
i += 1
_rng.seed = _seed
# Don't take keyboard focus or clicks from whatever you're doing while it renders.
@ -55,7 +87,10 @@ func _process(_delta: float) -> bool:
_game.start_game({"seed": _seed, "human": _human, "style": "greedy"})
var m: LocalMatch = _game.match_
var n := 0
while n < _moves and not m.is_over():
var in_combat := func() -> bool:
var c = m.combat()
return c != null and not c.done and m.human_to_act()
while (n < _moves or (_combat and not in_combat.call() and n < 4000)) and not m.is_over():
n += 1
if m.bot_to_act():
m.bot_step()
@ -68,8 +103,13 @@ func _process(_delta: float) -> bool:
var stop := moves.filter(func(mv): return mv.action.type in ["end", "pass"])
_game._play(stop[0] if not stop.is_empty() else moves[0])
m.run_bot()
_dealt_at = Time.get_ticks_msec()
if _combat:
print("combat under way: %s" % in_combat.call())
if _top:
_game.table.toggle_view()
if _zoom != 1.0:
_game.table.zoom(_zoom)
if _select == "auto":
# The first hand card with a targeted move.
for mv in _game.moves:
@ -80,7 +120,15 @@ func _process(_delta: float) -> bool:
_game._select(_select)
var card := _select.substr(5) if _select.begins_with("hand:") else ""
_game._inspect({"key": _select, "card": card})
if _frames == 70:
if _frames == 4:
if _terminal:
_game.hud.set_drawer(true)
if _focus >= -1:
_game.hud.set_hand_focus(true)
if _frames == 30 and _focus >= 0:
_game.hud._hover_focus(_focus)
var due := _frames == _shot_at if _at < 0 else _frames > 2 and Time.get_ticks_msec() - _dealt_at >= _at * 1000
if due:
var img := root.get_viewport().get_texture().get_image()
img.save_png(_out)
print("saved %s" % _out)

View file

@ -23,6 +23,7 @@ var _threaded := false
## The physics frame to wait for before the next check, so the bodies have moved with the cards.
var _wait := -1
var _checks := 0
var _began := false
func _init() -> void:
@ -52,7 +53,9 @@ func _init() -> void:
func _process(_delta: float) -> bool:
if _game == null or not _game.is_node_ready():
return false
if _steps == 0 and _played == 0:
# Once: with --threaded, bot moves don't count as steps, so a step count can't tell.
if not _began:
_began = true
_new_game()
if Engine.get_physics_frames() < _wait:
return false