feat: add deepwolf replay command#23
Conversation
Load a saved transcript JSON and re-render the game to the terminal, using the same coloured event stream as `simulate`. - `transcript.py`: add `Transcript` class, `load()`, and `_event_from_json()` to reconstruct Event objects from a saved transcript - `cli.py`: add `replay PATH` subcommand with optional `--delay` between events - Tests: round-trip (simulate → save → load → verify), CLI end-to-end Closes JuneQQQ#16 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for picking this up @MichisGitIsKing — and great follow-through on #16. 🙏 The implementation is clean: reusing 1. The bilingual invariant is dropped on the result paneldeepwolf has a strict bilingual invariant (en/zh via
A Chinese-language transcript replayed today would render its event log in Chinese (event The cleanest fix is to store # transcript.py to_json — add one line:
"lang": ... # I can point you at where to pull this from GameResult
# Transcript / cmd_replay:
from deepwolf.i18n import Translator, pick
tr = Translator(self.lang)
title = pick(self.lang, f"{tr.faction_label(self.winner)} win",
f"{tr.faction_label(self.winner)}获胜")
# and use pick(..., "survived", "存活") / pick(..., f"died day {d}", f"第 {d} 天死亡")For the 2. The branch is
|
Hey @JuneQQQ!
Here's the replay command you asked for in #16.
What's new
deepwolf replay PATH— loads a saved transcript JSON and re-renders the game to the terminal, same coloured event stream assimulate.transcript.py: addedTranscriptclass,load(), and_event_from_json()to reconstruct Event objects from saved transcriptscli.py: newreplaysubcommand with optional--delayflag (seconds between events, default 0 = instant)All three CI checks pass (ruff, mypy, pytest — 63/63).
The replay just re-emits stored events through the existing renderer — no GameState rebuild needed, exactly as you suggested.
Closes #16