Scrypt / tests /test_replay.py
IMJONEZZ's picture
SCRYPT: initial commit — game, sandbox, Warden, Space web layer
9fca766
Raw
History Blame Contribute Delete
1.14 kB
"""End-to-end determinism: a full scripted match replays identically."""
from scrypt.data import load_content
from scrypt.engine.combat import CombatState, Phase, Result
def run_pacifist_match(seed: int) -> CombatState:
"""Player draws and rings the bell, never playing a card. The Warden's
encounter script should grind them down to a loss."""
content = load_content()
state = CombatState(
main_deck=content.starter_decks["vanilla"]["cards"],
side_deck=[content.card("bit")] * 10,
script=content.encounters["first_blood"]["script"],
seed=seed,
)
for _ in range(40):
if state.phase is Phase.OVER:
break
if state.phase is Phase.DRAW:
state.draw("side" if state.can_draw_side else "main")
state.ring_bell()
return state
def test_pacifist_player_loses():
state = run_pacifist_match(seed=123)
assert state.result is Result.PLAYER_LOSS
def test_same_seed_same_event_log():
a = run_pacifist_match(seed=123)
b = run_pacifist_match(seed=123)
assert [repr(e) for e in a.events] == [repr(e) for e in b.events]