You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A valuable whose name is only whitespace counts as having a name of its own #355
PlayerView.valuable_names treats a gem or piece of jewellery whose name is only whitespace as a piece with a name of its own. The check in _item_names (src/osrlib/crawl/views.py, the add_valuable helper) is if valuable.name and valuable.name != _ROLLED_VALUABLE_NAMES[valuable.kind], so a name of " " is truthy and becomes a key. PileView.items has the same gap, because _pile_view shows valuable.name or valuable.kind, so the pile's entry is the blank string and not the kind.
Elsewhere osrlib counts a whitespace-only label as empty: SpellMode.display_name falls back to its key when the label is only whitespace (_label_from_key in src/osrlib/core/spells.py).
Repro
On main at a0cfb10 (2.9.0), a member carrying ValuableInstance(instance_id="valuable-0101", kind="gem", name=" ", value_gp=10):
A piece whose name is empty after stripping whitespace has no name of its own: it isn't a key in valuable_names (or in valuable_phrases, once #354 lands), and a pile's items shows its kind. A ValuableSpec with such a name is an authoring slip, so the alternative is for validate_adventure to refuse it; either way the view shouldn't show a blank name.
Found while writing the contract for #354, whose decisions keep the keys of valuable_names as they are, so the fix is its own change.
Fixed in #356. A name of whitespace alone is no name of its own, and the view trims the whitespace around a name, in valuable_names, valuable_phrases, and a pile's items.
Activity
mmacy commentedon Nov 26, 2026
Fixed in #356. A name of whitespace alone is no name of its own, and the view trims the whitespace around a name, in
valuable_names,valuable_phrases, and a pile'sitems.