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

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)