Repository navigation
Give each named valuable a phrase for a sentence - #356
Merged
Merged
Conversation
The stubs are `ValuableSpec.phrase` and `ValuableInstance.phrase`, both defaulting to the empty string, and `PlayerView.valuable_phrases`, defaulting to an empty map, each with its final docstring. The spec's player view paragraph names the new map. The tests in tests/test_view_valuable_phrases.py are marked xfail with the reason "chunk: valuable-phrases", except three guards that already pass: an adventure document keeps a phrase, a piece the party can't see has no phrase in the view, and a PlayerView that osrlib 2.9.0 built validates with no phrases. tests/goldens/phase5_hoards.json gains an empty `phrase` key on every generated valuable, because a hoard dumps its ValuableInstance models whole. Nothing else in it changes. The two fixtures under tests/saves/ were written by a scratch copy of v2.9.0 from the test module's own builder. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
A piece whose name is only whitespace is a key in valuable_names and shows a blank entry in a pile. The test pins that it has no name of its own, in both maps and in the pile's items. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
PlayerView.valuable_phrases has the same keys as valuable_names and gives each piece's phrase with its article and case, so a remote front end can word "Wren takes a silver altar candlestick." from the view alone. The phrase is the piece's own `phrase` when it isn't empty or only whitespace, and otherwise osrlib makes it from the name: a first word of "the", "a", or "an" is lowered, and any other name has its first letter lowered and "an" or "a" in front. Taking a placed cache copies ValuableSpec.phrase to the ValuableInstance as it copies `name`, so saves round-trip it and a 2.9.0 save, whose pieces have no phrase, gets made phrases. A piece whose name is only whitespace now has no name of its own (#355): it is a key in neither map, and a pile's `items` show its kind instead of the blank string. The docstrings of PileItemView, PlayerView.item_names, and PlayerView.valuable_names send a list to valuable_names and a sentence to valuable_phrases. The authoring guide gains a section on naming a valuable and when to set `phrase`, and the views and FastAPI guides name the new map. No golden file changes. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
PileView.items is a tuple, so the comparison with a list could never pass. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
The view trims a name and a phrase and judges a name of its own on the trimmed name, an accented vowel takes "an", and the docstrings say "first character" and name the kind each rolled name belongs to. The guide and the changelog say when to set a phrase without listing phrases that read wrong. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
…el "an" The amended contract has the view trim the whitespace around a valuable's name and phrase: the values of valuable_names and valuable_phrases and a pile's items show the trimmed text, and a piece has a name of its own when its trimmed name is neither empty nor its kind's rolled name, so " Gem " is a rolled gem's lookalike. The stored pieces keep what the author wrote. _with_article reads the first character's base letter after Unicode decomposition, so "Émeraude" and "Öl-lamp" take "an" and "Çintamani" takes "a". Its other callers pass built-in ASCII names, whose articles don't change, and no golden file changes. The authoring guide no longer says valuable_names gives the name as you wrote it. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
This was referenced Nov 26, 2026
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.
Fixes #354 and #355.
The problem
PlayerView.valuable_namesgives a named gem's or piece of jewellery's name as its author wrote it for a list, and the 2.9.0 docs told a client to use it as written in a sentence. That reads "Wren takes Silver altar candlestick." A client can't tell a common noun from a proper name, so it can't choose the article or the case.The change
ValuableSpec.phraseandValuableInstance.phraseare new optional fields: what to call the piece in the middle of a sentence, with its article and its case, such as"the abbot's seal ring". The session copies the phrase from the spec to the piece where it copies the name.PlayerView.valuable_phraseshas exactly the keys ofvaluable_names. Each value is the piece's phrase, or one made from its name when the phrase is empty or only whitespace. A name whose first word is "the", "a", or "an" keeps that word in lowercase. Any other name gets its first character in lowercase and "an" or "a" in front, by its first letter, and an accented vowel counts as a vowel.items. The stored pieces keep what the author wrote.valuable_namesand a sentence tovaluable_phrases. The authoring guide says when to setphrase.Everything is additive. A 2.9.0 save loads and gets a phrase for every named piece, and a
PlayerViewthat 2.9.0 built validates withvaluable_phrasesempty. No RNG stream draws differently, andSCHEMA_VERSIONdoesn't change.tests/goldens/phase5_hoards.jsongains"phrase": ""on each valuable, because a hoard dumps wholeValuableInstancemodels.How it was checked
tests/test_view_valuable_phrases.py, 43 tests, written before the implementation by a different agent, with two fixtures written by a scratch copy ofv2.9.0.phraseandvaluable_phrases. That replay ran before the trimming change, which changesvaluable_namesand a pile'sitemsonly for a name with whitespace around it.ruff format --check,ruff check,pyright,pytest(7,772 passed, 156 skipped),mkdocs build --strict, andtools.srd_compilewith no diff undersrc/osrlib/data.https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3