Skip to content

Name the items in the player view - #332

Merged
mmacy merged 15 commits into
mainfrom
view-item-names
Nov 26, 2026
Merged

mmacy merged 15 commits into
mainfrom
view-item-names

Conversation

@mmacy

@mmacy mmacy commented Nov 26, 2026

Copy link
Copy Markdown
Owner

A client with only the player view and the player-visible events couldn't word "The party finds 2 vials of holy water". The item templates had one name, the price-list label, like "Holy water (vial)" and "Torches (6)", and PileView.items gave strings like holy_water×2 to parse. Planned for 2.8.0. This is part 3 of #316, and with #327 it closes #316.

What changed

  • Display names on the item templates. Every equipment and magic item template has display_name and display_name_plural, noun phrases with no article, like "vial of holy water" and "vials of holy water". The SRD compiler fills them for the built-in catalogs, by rule where a rule holds and by override elsewhere. A template an author writes without them gets its name and a plural with the ending on the head noun, so "Idol of the drowned saint" gives "Idols of the drowned saint". The rule has one implementation in osrlib.core.items, and the compiler imports it.
  • PlayerView.item_names and item_names_plural name every item id the view shows, and only those. The names come from the catalogs the session uses, so an item the adventure bundles is named.
  • PileView.contents gives each pile entry's id and count as fields, beside the items strings, which don't change.
  • ItemIdentifiedEvent carries the item's display names, because a potion identified by drinking it is named by no view.
  • The masks hold. An unidentified magic item is named by its category mask, like "potion" or "shield with a faint aura", never by its true name or template id, and a cursed item has the same names as its lookalike. A valuable is named by its kind.
  • Old saves. When a session starts from a party document, when a save loads, and when a member joins by AddMember, each embedded template of an item the catalog has takes the catalog's display names. A 2.7.0 save then gives the view a fresh session gives, and the next save writes the names.
  • The equipment and magic item id index pages in the reference list the display names.

Fixed

  • EquipmentDestroyedEvent, which the players see, named an unidentified magic item by its true name, like "Sword +1". It names it by its mask.
  • The masked display of an enchanted arm was built from the price-list label, which gave "a arrows (quiver of 20) with a faint aura" and "a chainmail with a faint aura". It's built from one unit of the base: "an arrow with a faint aura", "a suit of chainmail with a faint aura". The changelog lists all eight strings that change, and a test pins that list against 2.7.0's over every template and base.

format_message still names items by id. #325 covers names on the item events and in the default lines.

Generated data and goldens

equipment.json and magic_items.json are regenerated by the compiler, and phase1_party.json, phase5_npc_parties.json, and phase5_milestone.json by their generators. The differences are the display name values and the overrides_applied entries that record a name set by an override. No command log, stream state, or draw changes.

Testing

tests/test_item_display_names.py pins both names of all 51 equipment templates and a sample of magic items, a rule over all 164 magic items, the default plural for an author's names, and that every compiled plural is what the default rule gives. tests/test_view_item_names.py covers the view, the masks, and fixtures written by 2.7.0. tests/test_embedded_item_names.py covers the three moments an embedded template takes the catalog's names, that nothing else in it changes, and that a save written now loads to the same save.

An independent review granted every one of the 164 magic items unidentified, equipped it where a member could, and found no template id or true name in the player view, the player-visible events, or their default lines, in an inventory or in a pile. Over 2,844 commands of random play, the keys of item_names were exactly the ids the view showed after every command.

https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3

mmacy added 15 commits November 25, 2026 20:01
…layer view

The stubs are display_name and display_name_plural on the five item templates,
PlayerView.item_names and item_names_plural, PileItemView and PileView.contents,
and display_name and display_name_plural on ItemIdentifiedEvent. The docstrings
of EquipmentDestroyedEvent.item_names and MemberView.inventory state the masking
the chunk makes hold. The tests in tests/test_item_display_names.py and
tests/test_view_item_names.py are marked expected-to-fail for the
view-item-names chunk, which is part 3 of #316.

The compiled equipment and magic item data and three goldens were regenerated,
because every template dump now has the two new fields, still empty. The goldens
change by those keys alone, plus the engine stamp of the engine that wrote them.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
A client with only the player view and the player events couldn't word "The
party finds 2 vials of holy water": the item templates had one name, the
price-list label like "Torches (6)", and a pile listed strings like
"holy_water×2" (#316, part 3).

The SRD compiler now fills display_name and display_name_plural on every
equipment and magic item template. The display name is the printed name in
lowercase with a trailing parenthesis dropped. Body armour is a suit,
ammunition names one unit, boots and gauntlets are a pair, a spell scroll
keeps its spell count as a "with" phrase, a label after a colon moves to the
front except a treasure map's numeral, and a word printed in capitals keeps
them. The plural ending goes on the word that names the item, before any
"of", "with", "vs", comma, bonus, or numeral, and "staff" becomes "staves".
Gear sold as a lot or a substance, leather armour, and the two magic items
that are sets get their names from overrides with a reason each. A template
written without the fields gets its name and the regular plural.

PlayerView.item_names and item_names_plural name every id the inventories
and the known piles show, from the template a stack embeds or the session's
catalog, so a bundled item in a pile is named. An unidentified magic item is
named by its mask, a valuable by its kind. PileView.contents gives each pile
entry's id and count, and ItemIdentifiedEvent carries the identified item's
names, because a potion drunk unidentified is named by no view.

Two defects are fixed. EquipmentDestroyedEvent, which the players see, named
an unidentified magic item by its true name; it now names it by its mask.
The masked display of an enchanted arm was built from the price-list label,
giving "a arrows (quiver of 20) with a faint aura", "a chainmail with a faint
aura", and "a arm with a faint aura"; it is now built from one unit of the
base's display name, giving "an arrow with a faint aura", "a suit of
chainmail with a faint aura", and "a suit of armour with a faint aura". The
masking lives in osrlib.core.items so the combat kernel and the view share it.

The data and three goldens were regenerated. phase1_party.json,
phase5_npc_parties.json, and phase5_milestone.json embed equipment
templates, so they change by the filled display names and by the
overrides_applied entries the name overrides record on the gear and armour
they embed. No command log, stream state, or draw changes.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
The views guide names items from PlayerView.item_names beside the spell
names, states the new ammunition and armour masks, and reads a pile from
PileView.contents. The authoring guide sets the two fields on the bundled
idol and states their defaults, the FastAPI page and the spec list what the
view now shows, and the adaptations register states the naming rules and
the masking rule. The changelog has the Added and Fixed bullets for #316,
part 3, with the masked display strings that change quoted before and after.

The override reasons and one comment are reworded; the compiled data does
not change.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
A client reads item names from PlayerView.item_names, and the monster id
index already lists each template's display name, but the equipment and
magic item indexes listed only the printed name. Both pages now have a
display name column and a display name plural column beside the printed
name, so the reference shows the names a client receives. The equipment
page's introduction no longer uses em dashes.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
…rals, and the changed masks

A stack a member carries is now named from the session's catalog, never from the
template it embeds, because a save or a party document from osrlib 2.7.0 embeds
templates without display names. tests/saves/view_item_names_2.7.0.json and
view_item_names_party_2.7.0.json were written by the v2.7.0 tag's code and are
kept as it wrote them.

An identified magic item in a pile is keyed by its instance id alone, since a
pile shows no template id. The exact-keys test now holds an identified item in
a pile and one carried.

A template written without a plural gets the regular ending on the word that
names the item, as the compiler's plural does, with "staff" becoming "staves".
A guard checks that every compiled plural is the default plural of its display
name, and another pins every masked display that differs from 2.7.0's, with the
2.7.0 side recorded as data.

The new tests that fail against the current implementation are marked
expected-to-fail for the view-item-names chunk.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
A save or a party document from osrlib 2.7.0 embeds item templates without
display names, so a carried stack fell back to the price-list label, with
holy water reading "Holy water (vial)" and "Holy water (vial)s". The player
view now names every mundane stack whose id the session's catalog has from
that catalog, carried or in a pile, and names a carried stack from its
embedded template only when the catalog lacks the id.

A pile shows a magic item by its instance id alone, so an identified item's
template id is now a key in item_names only while a member carries it. An
identified wand in a pile no longer adds wand_of_cold.

The default plural of a template written without one puts the ending on the
word that names the item, before the first "of", "with", "vs", comma,
bonus, closing Roman numeral, or opening parenthesis, and "staff" becomes
"staves" with its capital kept. The rule is osrlib.core.items._item_plural,
which the SRD compiler now imports in place of its own plural and irregular
table. Every compiled plural already followed the rule, so the compiled
data and the goldens don't change.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
The views guide, the changelog, the authoring guide, and the adaptations
register say that a mundane stack is named from the session's catalog, with
the embedded template only for an id the catalog lacks, and state the
default plural rule with its examples. The changelog's Fixed bullet on
masks adds the silver tipped arrow and sling stone strings, which the guard
over every template and base pins.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
A name an author writes in title case, like "Staff Of Power", missed the head
noun, and a doubled space put a space before the ending. Both are marked
expected-to-fail for the chunk view-item-names.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
The default plural matched "of", "with", and "vs" in lowercase only, so a
name an author wrote in title case, like "Staff Of Power", took the ending on
its last word: "Staff Of Powers". The connectors now match in any case, giving
"Staves Of Power". The head was also split on single spaces, so "Box  of
rocks" gave "Box s of rocks"; the last word is now found by a pattern that
keeps any whitespace after it, giving "Boxes  of rocks".

The template docstrings, the authoring guide, the adaptations register, and
the changelog state the case rule. The compiled names are lowercase and use
single spaces, so the compiled data doesn't change.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
The implementation is in, so the tests run as ordinary tests.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
# Conflicts:
#	CHANGELOG.md
#	docs/front-ends/fastapi-pattern.md
#	docs/guides/views-and-visibility.md
#	docs/spec.md
A save or a party document from osrlib 2.7.0 embeds item templates without
display names, so the inventory dump, the referee view, and the next save showed
the defaults from the price-list name. The docstrings of ItemInstance.template,
PlayerView.item_names, AddMember.character, and load_game now state the rule: when
a session starts, when a save loads, and when AddMember adds a member, each
embedded template whose id the session's catalog has takes the catalog's two
names and the overrides_applied entries that name them, and nothing else.

tests/test_embedded_item_names.py pins it against the two 2.7.0 fixtures and a new
one, tests/saves/view_item_names_npcs_2.7.0.json, written by the v2.7.0 tag's code
with an NPC party that carries gear. The tests that fail now are marked
expected-to-fail for the view-item-names chunk. Two guards run unmarked: loading a
2.7.0 save draws nothing, and a save written now re-saves unchanged.

tests/test_view_features.py::test_a_save_written_by_2_7_0_loads_with_the_new_fields
stays failing and unmarked until the chunk's change lands.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
A save or a party document from osrlib 2.7.0 embeds item templates without
display names, so they validated with the defaults from the price-list name.
The inventory dump, the referee view, and the next save showed "Holy water
(vial)" where a new session shows "vial of holy water", and
test_view_features' 2.7.0 save test failed on the merged tree.

The private _take_catalog_item_names in osrlib.crawl.session gives each
template a character's stacks embed the display_name and display_name_plural
of the catalog's template with the same id, with the overrides_applied
entries that name those two fields. Nothing else in the template changes, a
template whose id the catalog lacks keeps its names, and a second call
changes nothing. GameSession.__init__ applies it to every party member once
the equipment catalog is set, which covers GameSession.new, load_game, and
replay_game; load_game applies it to the NPC adventurers it restores; and
AddMember applies it to the copy that joins, so the logged command keeps the
character as it arrived. The player view now names a carried stack from the
template it embeds, which already has the catalog's names. No draw, golden,
or compiled data changes.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
The changelog says that the gear in a 2.7.0 save or party document takes
the catalog's display names when a session starts, loads, or adds a member,
and that the next save writes them. The views guide and the spec say a
carried stack is named from its embedded template, which has those names.

Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
@mmacy
mmacy merged commit 79f655f into main Nov 26, 2026
5 checks passed
@mmacy
mmacy deleted the view-item-names branch November 26, 2026 05:13
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.

Player view lacks emptied caches, known room traps, and item names

1 participant