Skip to content

Keep a door that starts open open when its state is written, and refuse end_encounter with nothing open - #206

Merged
mmacy merged 3 commits into
mainfrom
chunk/door-and-end
Oct 31, 2026
Merged

mmacy merged 3 commits into
mainfrom
chunk/door-and-end

Conversation

@mmacy

@mmacy mmacy commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Two defects found while rewriting the API docstrings.

A door that starts open stayed open only until something wrote to it

The first write through DungeonState.door stored a plain DoorState(), so open was False even for a door whose starts_open is set. Writing an unrelated field, like discovered, closed the door and blocked movement. #159 fixed the same kind of bug for reads.

Now a new door state starts from the door's DoorSpec, through the seeding rule the session already uses for the door states its commands store. GameSession.dungeon_state is now a property, and its setter links the state to the session's adventure. Both GameSession.new and load_game go through it. The link lives in a slot that pydantic equality, copies, and saves all leave out, so the save format and schema_version are unchanged. A DungeonState that no session holds still gives all-False states.

end_encounter with nothing open

end_encounter raised AttributeError when no encounter was open. It now raises ValueError before it changes or draws anything, as the project's rule for argument checks asks.

Changelog

  • The door bullet now describes the fixed behavior.
  • A new bullet covers end_encounter.
  • The 2.0.1 replay bullet now lists, among logs that raise, a command after the whole party was turned to stone, because the session now ends the game there (End the game when the whole party is turned to stone #200).

What to check

  • No golden file changed.
  • tests/test_door_and_end_encounter.py covers movement, the player view, SetDoorState, save and load, and a door that starts closed.

https://claude.ai/code/session_01V7ErtnsmhaP7aLwcfmzohD

mmacy added 3 commits October 30, 2026 17:52
…er fixes

DungeonState.door now documents that a new state starts from the door's
DoorSpec in the session's adventure. A door that starts open reads open, and
writing one field, such as discovered, changes only that field. Today the
first write stores a closed door and blocks the party.

end_encounter now documents ValueError when no encounter is open, raised
before it changes anything or takes a draw. Today it raises AttributeError.

The new tests are marked xfail for chunk door-and-end. The unmarked tests
pass today and guard closing the door, a door that starts closed, and a
DungeonState with no session.

Claude-Session: https://claude.ai/code/session_01V7ErtnsmhaP7aLwcfmzohD
…th nothing open

DungeonState.door now starts a door with no entry from the door's DoorSpec,
through the same seeding rule that the session's door commands use. A door
that starts open reads open, and writing another field, such as discovered,
stores an entry that is still open. The party can walk through it.

GameSession.dungeon_state is now a property. Setting it links the state to
the session's adventure, so GameSession.new and load_game both get the
behavior. The link is a slot on DungeonState, outside its fields and private
attributes. Equality, copies, pickles, and saves leave it out, so the save
format and schema_version don't change.

end_encounter now raises ValueError when no encounter is open, before it
changes anything or takes a draw. Before, it raised AttributeError.

No golden file changed.

Claude-Session: https://claude.ai/code/session_01V7ErtnsmhaP7aLwcfmzohD
@mmacy
mmacy merged commit ca7311c into main Oct 31, 2026
5 checks passed
@mmacy
mmacy deleted the chunk/door-and-end branch October 31, 2026 00:54
@mmacy mmacy mentioned this pull request Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant