Repository navigation
Say in the player view when a caster picks a form, whether they can prepare now, and a valuable's own name - #349
Merged
Merged
Conversation
…, and a valuable's own name The new fields are stubs with defaults: `reverses_at`, `can_prepare_now`, and `needs_sleep_to_prepare` on `MemberView` (#338), and `valuable_names` on `PlayerView` (#339). The docstrings of `PlayerView.item_names` and `PileItemView` now point to `valuable_names`, and `item_names` itself doesn't change. The tests in tests/test_view_prepare_now.py and tests/test_view_valuable_names.py are marked xfail until the chunk lands, except the cases a stub already satisfies, which run as guards: the fighter's cases, a caster whom the moment refuses after a sleep, `item_names` naming every valuable by its kind, and a 2.8.0 player view parsing. tests/saves/view_prepare_now_2.8.0.json and tests/saves/view_valuable_names_2.8.0.json are saves of the two test states written by osrlib 2.8.0. `PrepareSpells` refuses a member whose class casts nothing with `magic.memorize.needs_sleep` in a new session and with `magic.memorize.not_a_caster` after a sleep. A test of this chunk pins `magic.memorize.not_a_caster` whether or not the party has slept. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
…layer view `MemberView.reverses_at`, `can_prepare_now`, and `needs_sleep_to_prepare` (#338) and `PlayerView.valuable_names` (#339) now come from the checks the commands make, so a front end that builds its prepare, cast, and town screens from the view alone no longer infers them. - `reverses_at` reads `_reverses_at` in osrlib.core.spells, which `_selection_rejection` now uses to refuse a divine caster's reversed selection and `_memorized_index` uses to match a cast to a copy. - `can_prepare_now` and `needs_sleep_to_prepare` come from `_prepare_now` in osrlib.crawl._spells, which checks the command's allowed modes, `_member_able`, and `_prepare_refusal`, the refusal that `_handle_prepare_spells` now returns. `_needs_sleep` is the sleep rule both read. - `valuable_names` is built in the walk `_item_names` already makes over the inventories and the known piles. A piece has its own name unless the name is empty or the one in `_ROLLED_VALUABLE_NAMES`, which `_generate_valuable` in osrlib.core.treasure now reads too. `PrepareSpells` checked the sleep rule before the class, so it refused a member whose class casts nothing with `magic.memorize.needs_sleep` until the party's first sleep. `_prepare_refusal` checks the class first, so the refusal is `magic.memorize.not_a_caster` whether or not the party has slept. No RNG draw changes and no golden file or generated page changes. The guide to views, the spec, the FastAPI page, and the changelog describe the new fields and the fix. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
The acceptance tests of the prepare fields and the valuable names now run as ordinary tests. The guide said can_prepare_now is false during an encounter or a battle, and the rule is that it's false unless the session is in town or exploring. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
…ables # Conflicts: # CHANGELOG.md
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.
Closes #338. Closes #339.
A client that builds its prepare dialog, cast dialog, town screen, and item sentences from the player view had to infer three facts from other fields. Each is now a field that comes from the check the command runs.
MemberView.reverses_atis"memorize","cast", orNonefor a member who casts nothing. It comes from the class's kind of caster, so a divine caster with a spell book reads"cast".MemberView.can_prepare_nowis true exactly when the session accepts aPrepareSpellsfrom the member whose selection fitspreparable_spellsandspell_slots.MemberView.needs_sleep_to_prepareis the sleep rule by itself, from the sleep counts, so it's right after a save is restored into a new session.PlayerView.valuable_namesgives the own name of each named gem and piece of jewellery whose id the view shows, in a member's inventory or a known pile.item_namesis unchanged, because 2.8.0 clients put an article in front of its values.One refusal changes. A member whose class casts nothing is refused a
PrepareSpellswithmagic.memorize.not_a_casterwhether or not the party has slept. Before, a session that hadn't slept yet saidmagic.memorize.needs_sleep.Every new field has a default, so a 2.8.0 player view still parses, a 2.8.0 save gives the view a fresh session gives, and
SCHEMA_VERSIONstays 4.How it was checked
The acceptance tests in
tests/test_view_prepare_now.pyandtests/test_view_valuable_names.pywere written before the implementation by a different agent. An independent review drove 80 sessions of 100 commands through this branch and osrlib 2.8.0: the only difference in 8,000 commands was thenot_a_casterrefusal above, 73 times. It made 65,280 checks that the three member fields agree with what the session accepts, and 2,400 steps of twin sessions that differ only in secrets gave identical player views. All ten mutations were caught.The review measured the player view at about 5.5% slower than 2.8.0 for a ten-member party (1.16 ms to 1.22 ms), which is recorded on #335.
https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3