Repository navigation
Keep a door that starts open open when its state is written, and refuse end_encounter with nothing open - #206
Merged
Merged
Conversation
…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
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.doorstored a plainDoorState(), soopenwasFalseeven for a door whosestarts_openis set. Writing an unrelated field, likediscovered, 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_stateis now a property, and its setter links the state to the session's adventure. BothGameSession.newandload_gamego through it. The link lives in a slot that pydantic equality, copies, and saves all leave out, so the save format andschema_versionare unchanged. ADungeonStatethat no session holds still gives all-Falsestates.end_encounterwith nothing openend_encounterraisedAttributeErrorwhen no encounter was open. It now raisesValueErrorbefore it changes or draws anything, as the project's rule for argument checks asks.Changelog
end_encounter.What to check
tests/test_door_and_end_encounter.pycovers movement, the player view,SetDoorState, save and load, and a door that starts closed.https://claude.ai/code/session_01V7ErtnsmhaP7aLwcfmzohD