Skip to content

Discovering a secret door refunds both of its cells - #131

Merged
mmacy merged 3 commits into
mainfrom
chunk/refund-both-cells
Sep 15, 2026
Merged

mmacy merged 3 commits into
mainfrom
chunk/refund-both-cells

Conversation

@mmacy

@mmacy mmacy commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

A secret door is one edge shared by two cells, and a room_traps search from either cell covers that edge, so an undiscovered secret door hides the trap beyond it from both sides. Before this change, discovering the door refunded only the cell the discovery named: the searcher's cell in _reveal, or (x, y) in _handle_set_door_state. A member who searched the far cell while the door was still wall kept exploration.search.already_tried after walking round to it, even though the door now made the trap findable from that side too.

This fixes both discovery paths so they refund both cells of the edge:

  • _refund_trap_search in crawl/exploration.py now takes the discovered door's direction and clears room_traps attempts for the cell it was named from and the cell across the edge (step(position, direction)).
  • _reveal's secret_doors branch passes the direction of each door it discovers.
  • _handle_set_door_state in crawl/session.py passes command.direction.

Other search kinds and other cells keep their attempts, and both discovery paths use the same helper so they can't drift.

Docstrings updated to say so: Search in crawl/commands.py, _refund_trap_search, and the searching entry of docs/adaptations.md (with the new test class added to its "Locked by" list). SetDoorState's docstring doesn't describe the refund, so it needed no change.

Also, as asked outside this chunk: appended a sentence to the _migrate_3_to_4 docstring in persistence.py noting that the message code the dropped surrender flag's event once carried is gone too, so an event still naming it would no longer parse, though no log holds one because nothing ever set the flag that would have produced it. This is worded without the literal removed token, since test_unwired_surfaces.py::test_the_surrender_path_is_gone asserts that string appears nowhere under src/osrlib.

Fixes the first issue in #129 (the scroll re-validation issue described there is a separate chunk).

Test plan

  • uv run pytest --runxfail tests/test_exploration.py — 132 passed, including both previously xfail tests in TestDiscoveringASecretDoorRefundsBothCells now passing for real.
  • uv run ruff format --check
  • uv run ruff check
  • uv run pyright
  • uv run pytest — 2899 passed, 146 skipped, 2 xpassed (the two chunk tests, markers left for the lead to remove at merge), 0 failed.
  • uv run mkdocs build --strict

https://claude.ai/code/session_01NmCezTw8hKKujkaEZ3YGAs

…refund-both-cells)

Acceptance tests marked expected-to-fail: a discovery from the near side, by search or by referee command, refunds the far cell's room-trap attempts.

Claude-Session: https://claude.ai/code/session_01NmCezTw8hKKujkaEZ3YGAs
A secret door is one edge shared by two cells, and a room_traps search
from either cell covers that edge, so an undiscovered secret door hides
the trap beyond it from both sides. _refund_trap_search now takes the
discovered door's direction and clears the room_traps attempts of the
cell across the edge as well as the cell the discovery was named from,
on both discovery paths: a secret_doors search in _reveal and the
referee's SetDoorState in _handle_set_door_state. Other kinds and other
cells keep their attempts.

Also appends a sentence to the _migrate_3_to_4 docstring in
persistence.py noting that the message code the dropped surrender flag's
event once carried is gone too, so an event still naming it would no
longer parse, though no log holds one.

Claude-Session: https://claude.ai/code/session_01NmCezTw8hKKujkaEZ3YGAs
@mmacy
mmacy merged commit 47b87fe into main Sep 15, 2026
@mmacy
mmacy deleted the chunk/refund-both-cells branch September 15, 2026 02:01
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