From 6e9df0c60b88f7543fa9d74bdf0ea2603784c0ce Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:01:51 -0800 Subject: [PATCH 01/14] Add the contract and acceptance tests for item display names in the player 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 --- src/osrlib/core/events.py | 6 +- src/osrlib/core/items.py | 98 +++++ src/osrlib/crawl/events.py | 14 + src/osrlib/crawl/views.py | 104 ++++- src/osrlib/data/equipment.json | 102 +++++ src/osrlib/data/magic_items.json | 328 ++++++++++++++++ tests/goldens/phase1_party.json | 50 ++- tests/goldens/phase5_milestone.json | 18 +- tests/goldens/phase5_npc_parties.json | 158 ++++++++ tests/test_item_display_names.py | 278 ++++++++++++++ tests/test_view_item_names.py | 533 ++++++++++++++++++++++++++ 11 files changed, 1675 insertions(+), 14 deletions(-) create mode 100644 tests/test_item_display_names.py create mode 100644 tests/test_view_item_names.py diff --git a/src/osrlib/core/events.py b/src/osrlib/core/events.py index 1ddf19ea..b63e6829 100644 --- a/src/osrlib/core/events.py +++ b/src/osrlib/core/events.py @@ -849,7 +849,11 @@ class EquipmentDestroyedEvent(Event): """The entity id of the victim.""" item_names: tuple[str, ...] - """The display names of the items that were destroyed.""" + """The names of the items that were destroyed, as the players know them: a mundane item's + `name`, like `"Torches (6)"`, an identified magic item's `name`, and an unidentified magic item's + masked name, like `"a sword with a faint aura"`, the `display` that + [`MemberView.inventory`][osrlib.crawl.views.MemberView.inventory] showed for it. The event has + player visibility, so it never names an unidentified item by its true name.""" saved_items: tuple[str, ...] = () """The instance ids of the magic items that passed their save and still exist. Empty when none survived, diff --git a/src/osrlib/core/items.py b/src/osrlib/core/items.py index 9e294e35..87bab239 100644 --- a/src/osrlib/core/items.py +++ b/src/osrlib/core/items.py @@ -383,6 +383,23 @@ class WeaponTemplate(_Model): """ name: str """The display name, for example `"Sword"`.""" + display_name: str = Field(default="", validate_default=True) + """What to call one of these weapons in a sentence, like `"sword"` or `"two-handed sword"`. + + It's lowercase unless a word is a proper noun or an abbreviation, and it has no article, so put a number or an + article in front of it: "a sword", "2 swords". + [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] gives it to the players' client. + + A template you write that leaves it out gets its `name`. + """ + display_name_plural: str = Field(default="", validate_default=True) + """What to call two or more of these weapons, like `"swords"` or `"staves"`. + + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' + client. A template you write that leaves it out gets `display_name` with the regular English ending: `s`, or + `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set it yourself + when the plural is irregular. + """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one weapon.""" weight_coins: int = Field(ge=0) @@ -445,6 +462,24 @@ class ArmourTemplate(_Model): index](https://mmacy.github.io/osrlib-python/reference/content-ids/equipment/).""" name: str """The display name.""" + display_name: str = Field(default="", validate_default=True) + """What to call one of these in a sentence, like `"shield"` or `"suit of chainmail"`. + + Body armour is named as a suit, so a count reads "2 suits of chainmail". It's lowercase unless a + word is a proper noun or an abbreviation, and it has no article, so put a number or an article in + front of it. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] gives it to the players' client. + + A template you write that leaves it out gets its `name`. + """ + display_name_plural: str = Field(default="", validate_default=True) + """What to call two or more of these, like `"shields"` or `"suits of chainmail"`. + + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' + client. A template you write that leaves it out gets `display_name` with the regular English ending on its last + word: `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set + it yourself when the plural is irregular, or when the word that takes the ending isn't the last, as in `"suits + of chainmail"`. + """ cost_gp: int = Field(ge=0) """The listed price in gold pieces.""" weight_coins: int = Field(ge=0) @@ -553,6 +588,27 @@ class GearTemplate(_Model): """The display name as the price list prints it, which includes the lot size for gear sold in lots: `"Torches (6)"`, `"Iron spikes (12)"`. """ + display_name: str = Field(default="", validate_default=True) + """What to call one unit of this gear in a sentence, like `"torch"` or `"vial of holy water"`. + + It names one of the units that [`ItemInstance.quantity`][osrlib.core.items.ItemInstance.quantity] + counts, not a lot from the price list, so `"Torches (6)"` is `"torch"`, and a stack of six reads + "6 torches". Where the price list names a substance, it names the container or the measure the + session counts: `"vial of holy water"`, `"flask of oil"`, `"pint of wine"`. It's lowercase unless a + word is a proper noun or an abbreviation, and it has no article, so put a number or an article in + front of it. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] gives it to the players' client. + + A template you write that leaves it out gets its `name`. + """ + display_name_plural: str = Field(default="", validate_default=True) + """What to call two or more units, like `"torches"` or `"vials of holy water"`. + + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' + client. A template you write that leaves it out gets `display_name` with the regular English ending on its last + word: `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set + it yourself when the plural is irregular, or when the word that takes the ending isn't the last, as in `"vials + of holy water"`. + """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one lot.""" lot_size: int = Field(default=1, ge=1) @@ -596,6 +652,24 @@ class AmmunitionTemplate(_Model): [the equipment id index](https://mmacy.github.io/osrlib-python/reference/content-ids/equipment/).""" name: str """The display name as the price list prints it, which includes the lot: `"Arrows (quiver of 20)"`.""" + display_name: str = Field(default="", validate_default=True) + """What to call one unit of this ammunition in a sentence, like `"arrow"` or `"crossbow bolt"`. + + It names one of the units that [`ItemInstance.quantity`][osrlib.core.items.ItemInstance.quantity] + counts, not the lot, so `"Arrows (quiver of 20)"` is `"arrow"`, and a full quiver reads "20 arrows". + It's lowercase unless a word is a proper noun or an abbreviation, and it has no article. + [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] gives it to the players' client. + + A template you write that leaves it out gets its `name`. + """ + display_name_plural: str = Field(default="", validate_default=True) + """What to call two or more units, like `"arrows"` or `"crossbow bolts"`. + + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' + client. A template you write that leaves it out gets `display_name` with the regular English ending on its last + word: `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set + it yourself when the plural is irregular. + """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one lot. 0 for sling stones.""" lot_size: int = Field(default=1, ge=1) @@ -957,6 +1031,30 @@ class MagicItemTemplate(_Model): index](https://mmacy.github.io/osrlib-python/reference/content-ids/magic-items/).""" name: str """The display name. Show this only once the instance is identified.""" + display_name: str = Field(default="", validate_default=True) + """What to call one of these items in a sentence once the party knows what it is, like + `"potion of healing"` or `"sword +1"`. + + It's lowercase unless a word is a proper noun or an abbreviation, like the `ESP` of + `"potion of ESP"`, and it has no article, so put a number or an article in front of it. For + enchanted ammunition it names one of the units that + [`MagicItemInstance.quantity`][osrlib.core.items.MagicItemInstance.quantity] counts, so + `"Arrows +1 (3d10 arrows)"` is `"arrow +1"`. Footwear and gloves are named as a pair, like + `"pair of boots of speed"`, so a count reads "2 pairs of boots of speed". + + Like `name`, show it only once the instance is identified. Until then, + [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] names the item by its masked name. + + A template you construct yourself that leaves it out gets its `name`. + """ + display_name_plural: str = Field(default="", validate_default=True) + """What to call two or more of these items, like `"potions of healing"` or `"swords +1"`. + + The ending goes on the word that names the item, which is often not the last word. A template you + construct yourself that leaves it out gets `display_name` with the regular English ending on its + last word: `s`, or `es` after `s`, `x`, + `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set it yourself when that isn't the plural. + """ category: MagicItemCategory """What kind of item it is. See [`MagicItemCategory`][osrlib.core.items.MagicItemCategory].""" base_item_id: str | None = None diff --git a/src/osrlib/crawl/events.py b/src/osrlib/crawl/events.py index c8d9ace3..e26448ad 100644 --- a/src/osrlib/crawl/events.py +++ b/src/osrlib/crawl/events.py @@ -1794,6 +1794,20 @@ class ItemIdentifiedEvent(Event): """The session-scoped id of the item, the same id the earlier events contained.""" template_id: str """What it turned out to be, as its magic item catalog id.""" + display_name: str = "" + """What to call the item now that the party knows it, the template's + [`display_name`][osrlib.core.items.MagicItemTemplate.display_name], like `"potion of healing"`. + + It's here because the command that identifies an item can also use it up, like a potion drunk + before the party knew what it was. Then no view names it by its true name, because the view built + after the command no longer shows the item and the view from before showed it masked. When the + item is still carried, the view's + [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] has the same name under + `instance_id` and `template_id`.""" + display_name_plural: str = "" + """What to call two or more of the item, the template's + [`display_name_plural`][osrlib.core.items.MagicItemTemplate.display_name_plural], like + `"potions of healing"`.""" class CurseRevealedEvent(Event): diff --git a/src/osrlib/crawl/views.py b/src/osrlib/crawl/views.py index 6ab80d7f..280e0abe 100644 --- a/src/osrlib/crawl/views.py +++ b/src/osrlib/crawl/views.py @@ -158,6 +158,7 @@ "MemberEffectView", "MemberView", "ObjectiveView", + "PileItemView", "PileView", "PlayerView", "QuestView", @@ -231,17 +232,23 @@ class too.""" `worn_armour`, `shield`, `wielded`, and `rings`. Mundane items appear as the inventory serializes them. - A magic item is masked until it's identified. An unidentified one has a `display` name in - place of its true name, like `"a potion"`, or `"a dagger with a faint aura"` for a magic - weapon. When the display name refers to a weapon, the entry also has the `qualities` of that - plain weapon, as an identified one does, so you can tell a melee attack from a missile - attack without revealing the weapon's bonus or curse. It has a `missile_ranges` key only - when the rules give the weapon ranges, so on a sword the key is absent rather than empty. - Every magic staff displays as `"a staff"` and has the staff's `qualities`. Any other item - whose display name comes from its category, like `"a wand"`, has neither key, because its - display name doesn't refer to a weapon. An identified item - shows its `name`, its `template_id`, and whether a curse has been revealed. Charges never - appear.""" + A magic item is masked until it's identified. An unidentified one has a `display` name in place of its true + name, like `"a potion"`, or `"a dagger with a faint aura"` for a magic weapon. An enchanted weapon, suit of + armour, or shield is named after one unit of the mundane item underneath it, its + [`display_name`][osrlib.core.items.WeaponTemplate.display_name] with an article, so enchanted arrows display as + `"an arrow with a faint aura"` and enchanted chainmail as `"a suit of chainmail with a faint aura"`. A suit of + enchanted armour with no mundane item recorded displays as `"a suit of armour with a faint aura"`. When the + display name refers to a weapon, the entry also has the `qualities` of that plain weapon, as an identified one + does, so you can tell a melee attack from a missile attack without revealing the weapon's bonus or curse. It has + a `missile_ranges` key only when the rules give the weapon ranges, so on a sword the key is absent rather than + empty. Every magic staff displays as `"a staff"` and has the staff's `qualities`. Any other item whose display + name comes from its category, like `"a wand"`, has neither key, because its display name doesn't refer to a + weapon. An identified item shows its `name`, its `template_id`, and whether a curse has been revealed. Charges + never appear. + + To name an item in a sentence, look up the id it has here in + [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names]: a mundane item's + `template.id`, and a magic item's or a valuable's `instance_id`.""" memorized_spells: tuple[dict, ...] """The prepared spells, one dumped [`MemorizedSpell`][osrlib.core.spells.MemorizedSpell] per copy, in memorization @@ -433,6 +440,27 @@ class EdgeView(_Model): a door.""" +class PileItemView(_Model): + """One thing in a dropped pile, by the id the events name it by, with its count. + + You get these from [`PileView.contents`][osrlib.crawl.views.PileView.contents]. Look `item_id` up + in [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] to name it. + """ + + model_config = ConfigDict(frozen=True) + + item_id: str + """The catalog id of a mundane stack, like `"holy_water"`, or the instance id of a magic item, + like `"magic-item-0003"`, or of a gem or piece of jewellery, like `"valuable-0007"`. It's the form + of id that [`ItemsDroppedEvent.item_ids`][osrlib.crawl.events.ItemsDroppedEvent.item_ids] and the + other item events use, and an unidentified magic item's template id never appears here.""" + quantity: int = 1 + """How many units: the size of a mundane stack, the + [`quantity`][osrlib.core.items.MagicItemInstance.quantity] of a magic item, which is more than 1 + only for enchanted ammunition, and always 1 for a gem or piece of jewellery.""" + + class PileView(_Model): """A known dropped pile in explored space. @@ -452,6 +480,14 @@ class PileView(_Model): """The pile's coins, as their value in whole gold pieces, rounded down.""" coins: Coins = Coins() """The pile's coins by denomination, so a pile of copper alone isn't mistaken for an empty one.""" + contents: tuple[PileItemView, ...] = () + """One entry per thing in the pile, in the order of `items`, each with the id the events name + it by and its count. + + A mundane stack has its catalog id, so a client reads `"holy_water"` and 2 here where `items` has + the string `"holy_water×2"`. A magic item and a valuable have their instance ids. Name each entry + from [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names], which has a key for + every id here.""" class DungeonNameView(_Model): @@ -1013,6 +1049,52 @@ class PlayerView(_Model): [`memorized_spells`][osrlib.crawl.views.MemberView.memorized_spells]. A divine caster prepares the normal form and chooses the form when casting, so every memorized copy of a reversible spell can be cast either way. To offer that choice, show both names.""" + item_names: dict[str, str] = {} + """What to call one of each item whose id the view shows, keyed by that id, like + `{"torch": "torch", "holy_water": "vial of holy water", "magic-item-0003": "potion"}`. Show these + names, not the ids, and put a number or an article in front of one: "a torch". To word a count, + like "6 torches", use `item_names_plural`. + + An item id appears in the view in four forms, and each is a key here: + + - The catalog id of a mundane stack, like `"holy_water"`, in a member's + [`inventory`][osrlib.crawl.views.MemberView.inventory] and in a pile's + [`contents`][osrlib.crawl.views.PileView.contents]. Its name is the template's + [`display_name`][osrlib.core.items.GearTemplate.display_name]. For a stack a member carries, + it's read from the template the stack embeds, and for a pile, from the session's catalog, + [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], so an + item the adventure bundles is named. A pile's catalog id that the session's catalog doesn't + have has no entry. + - The instance id of a magic item, like `"magic-item-0003"`, in an inventory and in a pile. + Until the party identifies the item, its name is the masked name the inventory shows, without + the article: `"potion"`, `"curious device"`, or `"shield with a faint aura"`. So a cursed item + and the item it passes for have the same name, and the name tells nothing the inventory + doesn't. Once the item is identified, its name is the template's + [`display_name`][osrlib.core.items.MagicItemTemplate.display_name], like `"potion of healing"`. + - The template id of an identified magic item, like `"potion_of_healing"`, which the inventory + shows once the item is identified, with the same name. An unidentified item's template id is + never a key. + - The instance id of a gem or a piece of jewellery, like `"valuable-0007"`. Its name is its kind, + `"gem"` or `"piece of jewellery"`. The players see everything else about it from the moment + they take it, its own name and its value in gold pieces included, in the inventory's + `valuables`. + + It names no item whose id the view doesn't show. The player-visible item events, like + [`ItemAcquiredEvent`][osrlib.crawl.events.ItemAcquiredEvent], name items by the same ids. An + item the command left in a member's pack or in a pile the view shows is a key in the view you + build after the command. An item the command used up, sold, or left behind on a trail is a key + in the view from before it. An item that is identified and used up in the same command, like a + potion drunk before the party knew it, has its true name on the + [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent].""" + item_names_plural: dict[str, str] = {} + """What to call two or more of each item in `item_names`, with the same keys, like + `{"torch": "torches", "holy_water": "vials of holy water", "magic-item-0003": "potions"}`. + + Each value is the plural of the name in `item_names`: the template's + [`display_name_plural`][osrlib.core.items.GearTemplate.display_name_plural], the plural of a + masked name, like `"shields with a faint aura"`, or `"gems"` or `"pieces of jewellery"`. Use it + with a count from a pile's [`contents`][osrlib.crawl.views.PileView.contents], an inventory + entry's `quantity`, or the ids an event repeats, one per unit: "2 vials of holy water".""" fatigued: bool """Whether any member is fatigued.""" exhausted: bool diff --git a/src/osrlib/data/equipment.json b/src/osrlib/data/equipment.json index f923fb27..17ae1c7e 100644 --- a/src/osrlib/data/equipment.json +++ b/src/osrlib/data/equipment.json @@ -11,6 +11,8 @@ "ammunition": [ { "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "arrows", "item_type": "ammunition", "lot_size": 20, @@ -21,6 +23,8 @@ }, { "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "crossbow_bolts", "item_type": "ammunition", "lot_size": 30, @@ -31,6 +35,8 @@ }, { "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "silver_tipped_arrow", "item_type": "ammunition", "lot_size": 1, @@ -41,6 +47,8 @@ }, { "cost_gp": 0, + "display_name": "", + "display_name_plural": "", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -57,6 +65,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, + "display_name": "", + "display_name_plural": "", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -69,6 +79,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -81,6 +93,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 60, + "display_name": "", + "display_name_plural": "", "id": "plate_mail", "item_type": "armour", "name": "Plate mail", @@ -93,6 +107,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -105,6 +121,8 @@ "capacity_coins": 400, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "backpack", "item_type": "gear", "lot_size": 1, @@ -116,6 +134,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "crowbar", "item_type": "gear", "lot_size": 1, @@ -127,6 +147,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "garlic", "item_type": "gear", "lot_size": 1, @@ -138,6 +160,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, + "display_name": "", + "display_name_plural": "", "id": "grappling_hook", "item_type": "gear", "lot_size": 1, @@ -149,6 +173,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 2, + "display_name": "", + "display_name_plural": "", "id": "hammer", "item_type": "gear", "lot_size": 1, @@ -160,6 +186,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, + "display_name": "", + "display_name_plural": "", "id": "holy_symbol", "item_type": "gear", "lot_size": 1, @@ -191,6 +219,8 @@ ] }, "cost_gp": 25, + "display_name": "", + "display_name_plural": "", "id": "holy_water", "item_type": "gear", "lot_size": 1, @@ -202,6 +232,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "iron_spikes", "item_type": "gear", "lot_size": 12, @@ -215,6 +247,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "lantern", "item_type": "gear", "lot_size": 1, @@ -230,6 +264,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "mirror", "item_type": "gear", "lot_size": 1, @@ -261,6 +297,8 @@ ] }, "cost_gp": 2, + "display_name": "", + "display_name_plural": "", "id": "oil_flask", "item_type": "gear", "lot_size": 1, @@ -274,6 +312,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "pole", "item_type": "gear", "lot_size": 1, @@ -285,6 +325,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 15, + "display_name": "", + "display_name_plural": "", "id": "rations_iron", "item_type": "gear", "lot_size": 7, @@ -298,6 +340,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -311,6 +355,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "rope", "item_type": "gear", "lot_size": 1, @@ -322,6 +368,8 @@ "capacity_coins": 600, "combat": null, "cost_gp": 2, + "display_name": "", + "display_name_plural": "", "id": "sack_large", "item_type": "gear", "lot_size": 1, @@ -333,6 +381,8 @@ "capacity_coins": 200, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "sack_small", "item_type": "gear", "lot_size": 1, @@ -344,6 +394,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 3, + "display_name": "", + "display_name_plural": "", "id": "stakes_and_mallet", "item_type": "gear", "lot_size": 1, @@ -355,6 +407,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, + "display_name": "", + "display_name_plural": "", "id": "thieves_tools", "item_type": "gear", "lot_size": 1, @@ -368,6 +422,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 3, + "display_name": "", + "display_name_plural": "", "id": "tinder_box", "item_type": "gear", "lot_size": 1, @@ -387,6 +443,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -402,6 +460,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -415,6 +475,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "wine", "item_type": "gear", "lot_size": 2, @@ -426,6 +488,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "wolfsbane", "item_type": "gear", "lot_size": 1, @@ -472,6 +536,8 @@ { "cost_gp": 7, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "battle_axe", "item_type": "weapon", "material": "standard", @@ -488,6 +554,8 @@ { "cost_gp": 3, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "club", "item_type": "weapon", "material": "standard", @@ -503,6 +571,8 @@ { "cost_gp": 30, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "crossbow", "item_type": "weapon", "material": "standard", @@ -533,6 +603,8 @@ { "cost_gp": 3, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "dagger", "item_type": "weapon", "material": "standard", @@ -561,6 +633,8 @@ { "cost_gp": 4, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "hand_axe", "item_type": "weapon", "material": "standard", @@ -589,6 +663,8 @@ { "cost_gp": 1, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "javelin", "item_type": "weapon", "material": "standard", @@ -616,6 +692,8 @@ { "cost_gp": 5, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "lance", "item_type": "weapon", "material": "standard", @@ -631,6 +709,8 @@ { "cost_gp": 40, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "long_bow", "item_type": "weapon", "material": "standard", @@ -659,6 +739,8 @@ { "cost_gp": 5, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "mace", "item_type": "weapon", "material": "standard", @@ -674,6 +756,8 @@ { "cost_gp": 7, "damage": "1d10", + "display_name": "", + "display_name_plural": "", "id": "pole_arm", "item_type": "weapon", "material": "standard", @@ -691,6 +775,8 @@ { "cost_gp": 25, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "short_bow", "item_type": "weapon", "material": "standard", @@ -719,6 +805,8 @@ { "cost_gp": 7, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "short_sword", "item_type": "weapon", "material": "standard", @@ -733,6 +821,8 @@ { "cost_gp": 30, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "silver_dagger", "item_type": "weapon", "material": "silver", @@ -761,6 +851,8 @@ { "cost_gp": 2, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "sling", "item_type": "weapon", "material": "standard", @@ -789,6 +881,8 @@ { "cost_gp": 3, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "spear", "item_type": "weapon", "material": "standard", @@ -818,6 +912,8 @@ { "cost_gp": 2, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "staff", "item_type": "weapon", "material": "standard", @@ -835,6 +931,8 @@ { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -849,6 +947,8 @@ { "cost_gp": 15, "damage": "1d10", + "display_name": "", + "display_name_plural": "", "id": "two_handed_sword", "item_type": "weapon", "material": "standard", @@ -865,6 +965,8 @@ { "cost_gp": 5, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "war_hammer", "item_type": "weapon", "material": "standard", diff --git a/src/osrlib/data/magic_items.json b/src/osrlib/data/magic_items.json index de66c7ee..1f7020e7 100644 --- a/src/osrlib/data/magic_items.json +++ b/src/osrlib/data/magic_items.json @@ -133,6 +133,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "amulet_of_protection_against_scrying", @@ -167,6 +169,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "armour_plus_1", @@ -198,6 +202,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "armour_plus_2", @@ -229,6 +235,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "armour_plus_3", @@ -260,6 +268,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "arrows_plus_1", @@ -291,6 +301,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "arrows_plus_2", @@ -322,6 +334,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "axe_plus_1", @@ -353,6 +367,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "axe_plus_2", @@ -384,6 +400,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "bag_of_devouring", @@ -418,6 +436,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "bag_of_holding", @@ -456,6 +476,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "boots_of_levitation", @@ -492,6 +514,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "boots_of_speed", @@ -526,6 +550,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "boots_of_travelling_and_leaping", @@ -560,6 +586,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "bow_plus_1", @@ -591,6 +619,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "broom_of_flying", @@ -625,6 +655,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "crossbow_bolts_plus_1", @@ -656,6 +688,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "crossbow_bolts_plus_2", @@ -687,6 +721,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "crystal_ball", @@ -728,6 +764,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "crystal_ball_with_clairaudience", @@ -760,6 +798,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "crystal_ball_with_esp", @@ -795,6 +835,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "cursed_armour_ac_9", @@ -828,6 +870,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "cursed_armour_minus_1", @@ -861,6 +905,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "cursed_armour_minus_2", @@ -931,6 +977,8 @@ } ], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "cursed_scroll", @@ -962,6 +1010,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "cursed_shield_ac_9", @@ -995,6 +1045,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "cursed_shield_minus_2", @@ -1028,6 +1080,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "dagger_plus_1", @@ -1059,6 +1113,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "dagger_plus_2_plus_3_vs_orcs_goblins_and_kobolds", @@ -1101,6 +1157,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -1176,6 +1234,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "drums_of_panic", @@ -1211,6 +1271,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "efreeti_bottle", @@ -1246,6 +1308,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "elemental_summoning_device_air", @@ -1288,6 +1352,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "elemental_summoning_device_earth", @@ -1330,6 +1396,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "elemental_summoning_device_fire", @@ -1372,6 +1440,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "elemental_summoning_device_water", @@ -1414,6 +1484,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "elven_cloak_and_boots", @@ -1449,6 +1521,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "flying_carpet", @@ -1484,6 +1558,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -1549,6 +1625,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -1602,6 +1680,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "helm_of_alignment_changing", @@ -1637,6 +1717,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "helm_of_reading_languages_and_magic", @@ -1672,6 +1754,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "helm_of_telepathy", @@ -1710,6 +1794,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "helm_of_teleportation", @@ -1747,6 +1833,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "horn_of_blasting", @@ -1783,6 +1871,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "mace_plus_1", @@ -1814,6 +1904,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "mace_plus_2", @@ -1845,6 +1937,8 @@ "cursed": false, "curses": [], "damage_bonus": 3, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "mace_plus_3", @@ -1876,6 +1970,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "medallion_of_esp_30", @@ -1912,6 +2008,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "medallion_of_esp_90", @@ -1944,6 +2042,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "mirror_of_life_trapping", @@ -1981,6 +2081,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_clairaudience", @@ -2017,6 +2119,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_clairvoyance", @@ -2053,6 +2157,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_control_animal", @@ -2090,6 +2196,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_control_dragon", @@ -2130,6 +2238,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_control_giant", @@ -2168,6 +2278,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_control_human", @@ -2209,6 +2321,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_control_plant", @@ -2248,6 +2362,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_control_undead", @@ -2287,6 +2403,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_delusion", @@ -2323,6 +2441,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_diminution", @@ -2360,6 +2480,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_esp", @@ -2394,6 +2516,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -2470,6 +2594,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_flying", @@ -2506,6 +2632,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_gaseous_form", @@ -2544,6 +2672,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -2610,6 +2740,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -2674,6 +2806,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -2729,6 +2863,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_heroism", @@ -2770,6 +2906,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": "invisible", "damage_dice": null, @@ -2823,6 +2961,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -2900,6 +3040,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_levitation", @@ -2937,6 +3079,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_longevity", @@ -2971,6 +3115,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -3025,6 +3171,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_polymorph_self", @@ -3059,6 +3207,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -3116,6 +3266,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "potion_of_treasure_finding", @@ -3155,6 +3307,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_controlling_animals", @@ -3195,6 +3349,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_controlling_humans", @@ -3234,6 +3390,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_controlling_plants", @@ -3272,6 +3430,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_delusion", @@ -3308,6 +3468,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_djinni_summoning", @@ -3345,6 +3507,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -3419,6 +3583,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_invisibility", @@ -3455,6 +3621,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -3518,6 +3686,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -3584,6 +3754,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -3645,6 +3817,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_spell_storing", @@ -3685,6 +3859,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_spell_turning", @@ -3720,6 +3896,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_telekinesis", @@ -3758,6 +3936,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_water_walking", @@ -3792,6 +3972,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -3848,6 +4030,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_wishes", @@ -3883,6 +4067,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "ring_of_x_ray_vision", @@ -3923,6 +4109,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "rod_of_cancellation", @@ -3959,6 +4147,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "rope_of_climbing", @@ -3994,6 +4184,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "scarab_of_protection", @@ -4029,6 +4221,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -4101,6 +4295,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -4171,6 +4367,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "scroll_of_protection_from_magic", @@ -4209,6 +4407,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -4274,6 +4474,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "shield_plus_1", @@ -4305,6 +4507,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "shield_plus_2", @@ -4336,6 +4540,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "shield_plus_3", @@ -4367,6 +4573,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sling_plus_1", @@ -4398,6 +4606,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "spear_plus_1", @@ -4429,6 +4639,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "spear_plus_2", @@ -4460,6 +4672,8 @@ "cursed": false, "curses": [], "damage_bonus": 3, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "spear_plus_3", @@ -4491,6 +4705,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "spell_scroll_1", @@ -4530,6 +4746,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "spell_scroll_2", @@ -4569,6 +4787,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "spell_scroll_3", @@ -4608,6 +4828,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "spell_scroll_5", @@ -4647,6 +4869,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "spell_scroll_7", @@ -4686,6 +4910,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "staff_of_commanding", @@ -4735,6 +4961,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -4791,6 +5019,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": "2d6", @@ -4850,6 +5080,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "staff_of_snakes", @@ -4892,6 +5124,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": "2d6", @@ -4948,6 +5182,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "staff_of_withering", @@ -4986,6 +5222,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": "2d6", @@ -5049,6 +5287,8 @@ "cursed": true, "curses": [], "damage_bonus": -1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_minus_1_cursed", @@ -5077,6 +5317,8 @@ "cursed": true, "curses": [], "damage_bonus": -2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_minus_2_cursed", @@ -5105,6 +5347,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1", @@ -5137,6 +5381,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -5193,6 +5439,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_flaming", @@ -5235,6 +5483,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": null, @@ -5286,6 +5536,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_locate_objects", @@ -5321,6 +5573,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_2_vs_lycanthropes", @@ -5367,6 +5621,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_2_vs_spell_users", @@ -5416,6 +5672,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_3_vs_dragons", @@ -5464,6 +5722,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_3_vs_enchanted_creatures", @@ -5505,6 +5765,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_3_vs_regenerating_creatures", @@ -5550,6 +5812,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_3_vs_undead", @@ -5591,6 +5855,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_wishes", @@ -5628,6 +5894,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_2", @@ -5660,6 +5928,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_2_charm_person", @@ -5695,6 +5965,8 @@ "cursed": false, "curses": [], "damage_bonus": 3, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "sword_plus_3", @@ -5727,6 +5999,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -5778,6 +6052,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -5828,6 +6104,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -5879,6 +6157,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -5932,6 +6212,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -5978,6 +6260,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -6046,6 +6330,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -6131,6 +6417,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -6189,6 +6477,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -6235,6 +6525,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -6296,6 +6588,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -6349,6 +6643,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [ { @@ -6395,6 +6691,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": "6d6", @@ -6449,6 +6747,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "wand_of_enemy_detection", @@ -6484,6 +6784,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": "afraid", "damage_dice": null, @@ -6540,6 +6842,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": "6d6", @@ -6594,6 +6898,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "wand_of_illusion", @@ -6628,6 +6934,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": null, "damage_dice": "6d6", @@ -6684,6 +6992,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "wand_of_magic_detection", @@ -6719,6 +7029,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "wand_of_metal_detection", @@ -6755,6 +7067,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "wand_of_negation", @@ -6791,6 +7105,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": { "condition": "paralysed", "damage_dice": null, @@ -6847,6 +7163,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "wand_of_polymorph", @@ -6881,6 +7199,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "wand_of_secret_door_detection", @@ -6914,6 +7234,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "wand_of_trap_detection", @@ -6947,6 +7269,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "war_hammer_plus_1", @@ -6978,6 +7302,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "war_hammer_plus_2", @@ -7009,6 +7335,8 @@ "cursed": false, "curses": [], "damage_bonus": 3, + "display_name": "", + "display_name_plural": "", "effect": null, "hoard_recipe": [], "id": "war_hammer_plus_3_dwarven_thrower", diff --git a/tests/goldens/phase1_party.json b/tests/goldens/phase1_party.json index e13ac790..c2edd0c7 100644 --- a/tests/goldens/phase1_party.json +++ b/tests/goldens/phase1_party.json @@ -1,5 +1,5 @@ { - "engine_version": "2.0.1", + "engine_version": "2.7.0", "kind": "party", "payload": { "characters": [ @@ -27,6 +27,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -57,6 +59,8 @@ "template": { "cost_gp": 5, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "mace", "item_type": "weapon", "material": "standard", @@ -80,6 +84,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -124,6 +130,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "iron_spikes", "item_type": "gear", "lot_size": 12, @@ -147,6 +155,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -177,6 +187,8 @@ "template": { "cost_gp": 5, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "war_hammer", "item_type": "weapon", "material": "standard", @@ -200,6 +212,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -254,6 +268,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -276,6 +292,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -332,6 +350,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -354,6 +374,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -399,6 +421,8 @@ "quantity": 1, "template": { "cost_gp": 0, + "display_name": "", + "display_name_plural": "", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -415,6 +439,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -443,6 +469,8 @@ "template": { "cost_gp": 2, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "sling", "item_type": "weapon", "material": "standard", @@ -479,6 +507,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -543,6 +573,8 @@ ] }, "cost_gp": 2, + "display_name": "", + "display_name_plural": "", "id": "oil_flask", "item_type": "gear", "lot_size": 1, @@ -566,6 +598,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -585,6 +619,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -602,6 +638,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -630,6 +668,8 @@ "template": { "cost_gp": 3, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "dagger", "item_type": "weapon", "material": "standard", @@ -699,6 +739,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "rope", "item_type": "gear", "lot_size": 1, @@ -720,6 +762,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -750,6 +794,8 @@ "template": { "cost_gp": 3, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "dagger", "item_type": "weapon", "material": "standard", @@ -786,6 +832,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", diff --git a/tests/goldens/phase5_milestone.json b/tests/goldens/phase5_milestone.json index 9a4b2996..93144dc2 100644 --- a/tests/goldens/phase5_milestone.json +++ b/tests/goldens/phase5_milestone.json @@ -3778,7 +3778,7 @@ "master_seed": 39, "mode": "victory", "party_document": { - "engine_version": "2.6.0", + "engine_version": "2.7.0", "kind": "party", "payload": { "characters": [ @@ -3810,6 +3810,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -3825,6 +3827,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -3847,6 +3851,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, + "display_name": "", + "display_name_plural": "", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -3901,6 +3907,8 @@ "template": { "cost_gp": 5, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "mace", "item_type": "weapon", "material": "standard", @@ -3924,6 +3932,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, + "display_name": "", + "display_name_plural": "", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -3978,6 +3988,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -4000,6 +4012,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -4054,6 +4068,8 @@ "template": { "cost_gp": 3, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "dagger", "item_type": "weapon", "material": "standard", diff --git a/tests/goldens/phase5_npc_parties.json b/tests/goldens/phase5_npc_parties.json index b3199426..c15f9d3c 100644 --- a/tests/goldens/phase5_npc_parties.json +++ b/tests/goldens/phase5_npc_parties.json @@ -19,6 +19,8 @@ "quantity": 1, "template": { "cost_gp": 0, + "display_name": "", + "display_name_plural": "", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -35,6 +37,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -52,6 +56,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -75,6 +81,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -105,6 +113,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -120,6 +130,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -138,6 +150,8 @@ "template": { "cost_gp": 2, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "sling", "item_type": "weapon", "material": "standard", @@ -174,6 +188,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -220,6 +236,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -234,6 +252,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -251,6 +271,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -274,6 +296,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -304,6 +328,8 @@ "template": { "cost_gp": 7, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "battle_axe", "item_type": "weapon", "material": "standard", @@ -328,6 +354,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, + "display_name": "", + "display_name_plural": "", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -372,6 +400,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, + "display_name": "", + "display_name_plural": "", "id": "thieves_tools", "item_type": "gear", "lot_size": 1, @@ -389,6 +419,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -406,6 +438,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -429,6 +463,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -459,6 +495,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -481,6 +519,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -527,6 +567,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -541,6 +583,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -558,6 +602,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -581,6 +627,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -611,6 +659,8 @@ "template": { "cost_gp": 7, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "battle_axe", "item_type": "weapon", "material": "standard", @@ -635,6 +685,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, + "display_name": "", + "display_name_plural": "", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -677,6 +729,8 @@ "quantity": 20, "template": { "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "arrows", "item_type": "ammunition", "lot_size": 20, @@ -693,6 +747,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -710,6 +766,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -733,6 +791,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -763,6 +823,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -781,6 +843,8 @@ "template": { "cost_gp": 40, "damage": "1d6", + "display_name": "", + "display_name_plural": "", "id": "long_bow", "item_type": "weapon", "material": "standard", @@ -817,6 +881,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, + "display_name": "", + "display_name_plural": "", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -907,6 +973,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -924,6 +992,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -947,6 +1017,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -980,6 +1052,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -1040,6 +1114,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1062,6 +1138,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 60, + "display_name": "", + "display_name_plural": "", "id": "plate_mail", "item_type": "armour", "name": "Plate mail", @@ -1104,6 +1182,8 @@ "quantity": 1, "template": { "cost_gp": 0, + "display_name": "", + "display_name_plural": "", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -1120,6 +1200,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -1137,6 +1219,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1160,6 +1244,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -1181,6 +1267,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -1229,6 +1317,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1247,6 +1337,8 @@ "template": { "cost_gp": 2, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "sling", "item_type": "weapon", "material": "standard", @@ -1283,6 +1375,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -1325,6 +1419,8 @@ "quantity": 1, "template": { "cost_gp": 0, + "display_name": "", + "display_name_plural": "", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -1341,6 +1437,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -1358,6 +1456,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1381,6 +1481,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -1423,6 +1525,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -1438,6 +1542,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1456,6 +1562,8 @@ "template": { "cost_gp": 2, "damage": "1d4", + "display_name": "", + "display_name_plural": "", "id": "sling", "item_type": "weapon", "material": "standard", @@ -1520,6 +1628,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -1564,6 +1674,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, + "display_name": "", + "display_name_plural": "", "id": "thieves_tools", "item_type": "gear", "lot_size": 1, @@ -1581,6 +1693,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -1598,6 +1712,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1621,6 +1737,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -1651,6 +1769,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1673,6 +1793,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -1717,6 +1839,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -1734,6 +1858,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1757,6 +1883,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -1811,6 +1939,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -1826,6 +1956,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1860,6 +1992,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 60, + "display_name": "", + "display_name_plural": "", "id": "plate_mail", "item_type": "armour", "name": "Plate mail", @@ -1904,6 +2038,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, + "display_name": "", + "display_name_plural": "", "id": "thieves_tools", "item_type": "gear", "lot_size": 1, @@ -1921,6 +2057,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -1938,6 +2076,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1961,6 +2101,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -1991,6 +2133,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -2025,6 +2169,8 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, + "display_name": "", + "display_name_plural": "", "id": "leather", "item_type": "armour", "name": "Leather", @@ -2069,6 +2215,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, + "display_name": "", + "display_name_plural": "", "id": "rations_standard", "item_type": "gear", "lot_size": 7, @@ -2086,6 +2234,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -2109,6 +2259,8 @@ ] }, "cost_gp": 1, + "display_name": "", + "display_name_plural": "", "id": "torch", "item_type": "gear", "lot_size": 6, @@ -2139,6 +2291,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, + "display_name": "", + "display_name_plural": "", "id": "shield", "item_type": "armour", "name": "Shield", @@ -2154,6 +2308,8 @@ "template": { "cost_gp": 10, "damage": "1d8", + "display_name": "", + "display_name_plural": "", "id": "sword", "item_type": "weapon", "material": "standard", @@ -2176,6 +2332,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 60, + "display_name": "", + "display_name_plural": "", "id": "plate_mail", "item_type": "armour", "name": "Plate mail", diff --git a/tests/test_item_display_names.py b/tests/test_item_display_names.py new file mode 100644 index 00000000..3c133a53 --- /dev/null +++ b/tests/test_item_display_names.py @@ -0,0 +1,278 @@ +"""Every item template has a name for one unit in a sentence and a name for two or more (issue #316, part 3). + +A remote front end words a count, like "The party finds 2 vials of holy water", from the player view and the events +alone. The templates' `name` is the price list's label, like `"Holy water (vial)"` or `"Torches (6)"`, which names a +lot and has no plural, so a client can't build that sentence from it. `display_name` and `display_name_plural` are +the words a sentence needs, as `MonsterTemplate.display_name` and `display_name_plural` are for monsters, and +`PlayerView.item_names` carries them to the client. + +The unit is the one the session counts. `ItemInstance.quantity` counts individual items, not lots, so the OSE SRD's +"Torches (6)" is six units of `"torch"`, "Iron spikes (12)" twelve of `"iron spike"`, "Wine (2 pints)" two of +`"pint of wine"`, and "Rations (iron, 7 days)" seven of `"iron ration"`. The SRD's gear descriptions name the +containers: "Holy water: Water blessed by a holy person, stored in a special vial" and "Oil flask: A flask of oil +fuels a lantern", so a unit of holy water is a vial and a unit of oil a flask. +""" + +import pytest + +from osrlib.core.items import AmmunitionTemplate, ArmourTemplate, GearTemplate, MagicItemTemplate, WeaponTemplate +from osrlib.crawl.adventure import Adventure, TownSpec +from osrlib.crawl.dungeon import DungeonSpec, LevelSpec +from osrlib.data import load_equipment, load_magic_items + +XFAIL = pytest.mark.xfail(reason="chunk: view-item-names") + +MUNDANE = { + # Gear. A lot from the price list becomes one unit, and a substance becomes its container or measure. + "backpack": ("backpack", "backpacks"), + "crowbar": ("crowbar", "crowbars"), + "garlic": ("bulb of garlic", "bulbs of garlic"), + "grappling_hook": ("grappling hook", "grappling hooks"), + "hammer": ("small hammer", "small hammers"), + "holy_symbol": ("holy symbol", "holy symbols"), + "holy_water": ("vial of holy water", "vials of holy water"), + "iron_spikes": ("iron spike", "iron spikes"), + "lantern": ("lantern", "lanterns"), + "mirror": ("hand mirror", "hand mirrors"), + "oil_flask": ("flask of oil", "flasks of oil"), + "pole": ("10’ pole", "10’ poles"), + "rations_iron": ("iron ration", "iron rations"), + "rations_standard": ("standard ration", "standard rations"), + "rope": ("50’ coil of rope", "50’ coils of rope"), + "sack_large": ("large sack", "large sacks"), + "sack_small": ("small sack", "small sacks"), + "stakes_and_mallet": ("set of stakes and mallet", "sets of stakes and mallet"), + "thieves_tools": ("set of thieves’ tools", "sets of thieves’ tools"), + "tinder_box": ("tinder box", "tinder boxes"), + "torch": ("torch", "torches"), + "waterskin": ("waterskin", "waterskins"), + "wine": ("pint of wine", "pints of wine"), + "wolfsbane": ("bunch of wolfsbane", "bunches of wolfsbane"), + # Ammunition: one arrow, not the quiver of 20. + "arrows": ("arrow", "arrows"), + "crossbow_bolts": ("crossbow bolt", "crossbow bolts"), + "silver_tipped_arrow": ("silver tipped arrow", "silver tipped arrows"), + "sling_stones": ("sling stone", "sling stones"), + # Weapons: the printed name in lowercase, with the regular plural except for the staff. + "battle_axe": ("battle axe", "battle axes"), + "club": ("club", "clubs"), + "crossbow": ("crossbow", "crossbows"), + "dagger": ("dagger", "daggers"), + "hand_axe": ("hand axe", "hand axes"), + "javelin": ("javelin", "javelins"), + "lance": ("lance", "lances"), + "long_bow": ("long bow", "long bows"), + "mace": ("mace", "maces"), + "pole_arm": ("pole arm", "pole arms"), + "short_bow": ("short bow", "short bows"), + "short_sword": ("short sword", "short swords"), + "silver_dagger": ("silver dagger", "silver daggers"), + "sling": ("sling", "slings"), + "spear": ("spear", "spears"), + "staff": ("staff", "staves"), + "sword": ("sword", "swords"), + "two_handed_sword": ("two-handed sword", "two-handed swords"), + "war_hammer": ("war hammer", "war hammers"), + # Armour: body armour is a suit, and the SRD's "Leather" is leather armour. + "chainmail": ("suit of chainmail", "suits of chainmail"), + "leather": ("suit of leather armour", "suits of leather armour"), + "plate_mail": ("suit of plate mail", "suits of plate mail"), + "shield": ("shield", "shields"), +} +"""The display names of every compiled equipment template, keyed by catalog id.""" + +MAGIC = { + "potion_of_healing": ("potion of healing", "potions of healing"), + # An abbreviation keeps its capitals. + "potion_of_esp": ("potion of ESP", "potions of ESP"), + "ring_of_protection": ("ring of protection", "rings of protection"), + "wand_of_cold": ("wand of cold", "wands of cold"), + # The ending goes on the word that names the item, and "staff" has the plural the mundane staff has. + "staff_of_healing": ("staff of healing", "staves of healing"), + "bag_of_holding": ("bag of holding", "bags of holding"), + "boots_of_speed": ("pair of boots of speed", "pairs of boots of speed"), + "gauntlets_of_ogre_power": ("pair of gauntlets of ogre power", "pairs of gauntlets of ogre power"), + "sword_plus_1": ("sword +1", "swords +1"), + "sword_plus_1_plus_3_vs_undead": ("sword +1, +3 vs undead", "swords +1, +3 vs undead"), + "sword_minus_1_cursed": ("sword -1, cursed", "swords -1, cursed"), + "shield_plus_1": ("shield +1", "shields +1"), + "armour_plus_1": ("suit of armour +1", "suits of armour +1"), + "cursed_armour_ac_9": ("suit of cursed armour, AC 9 [10]", "suits of cursed armour, AC 9 [10]"), + # Enchanted ammunition names one unit, which MagicItemInstance.quantity counts, not the generated count. + "arrows_plus_1": ("arrow +1", "arrows +1"), + "crossbow_bolts_plus_2": ("crossbow bolt +2", "crossbow bolts +2"), + # A spell scroll keeps how many spells it holds, which its printed name gives in a parenthesis. + "spell_scroll_1": ("spell scroll with 1 spell", "spell scrolls with 1 spell"), + "spell_scroll_3": ("spell scroll with 3 spells", "spell scrolls with 3 spells"), + # A treasure map's Roman numeral keeps its capitals. + "treasure_map_ii": ("treasure map II", "treasure maps II"), +} +"""The display names of a sample of compiled magic item templates, keyed by catalog id.""" + + +def _equipment() -> dict: + catalog = load_equipment() + return { + template.id: template for template in (*catalog.weapons, *catalog.armour, *catalog.gear, *catalog.ammunition) + } + + +def test_the_table_covers_every_compiled_equipment_template(): + """A template the compiler adds needs its names in `MUNDANE`, so this table stays the whole catalog.""" + assert set(_equipment()) == set(MUNDANE) + + +@XFAIL +@pytest.mark.parametrize(("item_id", "names"), sorted(MUNDANE.items())) +def test_each_compiled_equipment_template_has_its_display_names(item_id: str, names: tuple[str, str]): + template = _equipment()[item_id] + + assert (template.display_name, template.display_name_plural) == names + + +@XFAIL +@pytest.mark.parametrize(("item_id", "names"), sorted(MAGIC.items())) +def test_a_compiled_magic_item_template_has_its_display_names(item_id: str, names: tuple[str, str]): + template = load_magic_items().get(item_id) + + assert (template.display_name, template.display_name_plural) == names + + +@XFAIL +def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): + """Each one is filled, starts in lowercase, drops the printed parenthesis, and has a distinct plural.""" + for template in load_magic_items().items: + singular, plural = template.display_name, template.display_name_plural + assert singular and plural, template.id + assert not singular[0].isupper(), (template.id, singular) + assert "(" not in singular and "(" not in plural, (template.id, singular) + assert singular != plural, (template.id, singular) + + +@pytest.mark.parametrize( + ("template", "names"), + [ + # A template written without the fields gets its name, and the regular ending on the last word. + pytest.param( + GearTemplate.model_validate({"id": "crypt_key", "name": "Crypt key", "cost_gp": 0}), + ("Crypt key", "Crypt keys"), + id="gear", + marks=XFAIL, + ), + pytest.param( + GearTemplate.model_validate({"id": "compass", "name": "Brass compass", "cost_gp": 0}), + ("Brass compass", "Brass compasses"), + id="gear_es", + marks=XFAIL, + ), + pytest.param( + AmmunitionTemplate.model_validate({"id": "dart", "name": "Barbed dart", "cost_gp": 0}), + ("Barbed dart", "Barbed darts"), + id="ammunition", + marks=XFAIL, + ), + pytest.param( + WeaponTemplate.model_validate( + { + "id": "blade", + "name": "Drowned blade", + "cost_gp": 0, + "weight_coins": 60, + "damage": "1d8", + "qualities": ("melee",), + } + ), + ("Drowned blade", "Drowned blades"), + id="weapon", + marks=XFAIL, + ), + pytest.param( + ArmourTemplate.model_validate( + { + "id": "scale", + "name": "Saint's scale", + "cost_gp": 0, + "weight_coins": 300, + "ac": 6, + "ac_ascending": 13, + "category": "light", + } + ), + ("Saint's scale", "Saint's scales"), + id="armour", + marks=XFAIL, + ), + pytest.param( + MagicItemTemplate.model_validate({"id": "orb", "name": "Gleaming orb", "category": "misc"}), + ("Gleaming orb", "Gleaming orbs"), + id="magic_item", + marks=XFAIL, + ), + # A consonant before the y: "ies". + pytest.param( + GearTemplate.model_validate({"id": "reliquary", "name": "Reliquary", "cost_gp": 0}), + ("Reliquary", "Reliquaries"), + id="gear_ies", + marks=XFAIL, + ), + # A name written for one keeps a plural written for two or more. This holds before the chunk too. + pytest.param( + GearTemplate.model_validate( + { + "id": "lamp_oil", + "name": "Lamp oil", + "cost_gp": 0, + "display_name": "jar of lamp oil", + "display_name_plural": "jars of lamp oil", + } + ), + ("jar of lamp oil", "jars of lamp oil"), + id="written", + ), + # A plural left out of a written name follows the written name. + pytest.param( + GearTemplate.model_validate( + {"id": "idol", "name": "Idol of the drowned saint", "cost_gp": 0, "display_name": "jade idol"} + ), + ("jade idol", "jade idols"), + id="written_singular", + marks=XFAIL, + ), + ], +) +def test_a_template_you_write_without_the_fields_gets_them(template, names: tuple[str, str]): + assert (template.display_name, template.display_name_plural) == names + + +@XFAIL +def test_a_bundled_items_display_names_survive_the_adventure_document(): + """An adventure document round-trips the names its author wrote, and one written without them still loads.""" + idol = GearTemplate.model_validate( + { + "id": "temple_idol", + "name": "Idol of the drowned saint", + "cost_gp": 0, + "display_name": "idol of the drowned saint", + "display_name_plural": "idols of the drowned saint", + } + ) + key = GearTemplate.model_validate({"id": "crypt_key", "name": "Crypt key", "cost_gp": 0}) + level = LevelSpec(number=1, width=1, height=1, entrance=(0, 0)) + adventure = Adventure( + name="A", + town=TownSpec(name="Threshold"), + dungeons=(DungeonSpec(id="crypt", name="Crypt", levels=(level,)),), + items=(idol, key), + ) + + document = adventure.model_dump(mode="json") + for item in document["items"]: + if item["id"] == "crypt_key": + del item["display_name"], item["display_name_plural"] + loaded = Adventure.model_validate(document) + + names = {item.id: (item.display_name, item.display_name_plural) for item in loaded.items} + assert names == { + "temple_idol": ("idol of the drowned saint", "idols of the drowned saint"), + "crypt_key": ("Crypt key", "Crypt keys"), + } diff --git a/tests/test_view_item_names.py b/tests/test_view_item_names.py new file mode 100644 index 00000000..d237c80f --- /dev/null +++ b/tests/test_view_item_names.py @@ -0,0 +1,533 @@ +"""The player view names every item whose id it shows (issue #316, part 3). + +A remote front end builds its screens from `PlayerView` and the player-visible events alone. The view shows items by +id: a catalog id like `"holy_water"` for a mundane stack, an instance id like `"magic-item-0003"` for a magic item, +and an instance id like `"valuable-0007"` for a gem or piece of jewellery. A pile shows strings like +`"holy_water×2"`. `PlayerView.item_names` and `item_names_plural` carry a singular and a plural for every one of +those ids, read from the template a stack embeds or the session's catalog, so an item the adventure bundles is named. +`PileView.contents` gives each pile entry's id and count beside the strings. + +A masked item keeps its mask. Until the party identifies a magic item, its name is the masked name the inventory +shows, without the article, so a cursed item and the item it passes for read the same. The OSE SRD's Armour and +Shields page says "All types of tests indicate that a cursed shield or suit of armour is enchanted with a +1 bonus", +which is why `tests/test_unrevealed_curse_view.py` pins a cursed shield to the view of a shield +1. +""" + +import pytest + +from crawl_fixtures import build_party +from osrlib.core.events import Visibility +from osrlib.core.items import GearTemplate, MagicItemInstance, ValuableInstance +from osrlib.crawl.adventure import Adventure, TownSpec +from osrlib.crawl.commands import DropItems, EnterDungeon, GrantItem, IdentifyItem, TakeTreasure, UseItem +from osrlib.crawl.dungeon import AreaSpec, DungeonSpec, FeatureSpec, LevelSpec, ValuableSpec +from osrlib.crawl.events import ItemAcquiredEvent, ItemIdentifiedEvent, ItemsDroppedEvent +from osrlib.crawl.session import GameSession +from osrlib.crawl.views import PileItemView, PlayerView +from test_loot_and_traps import breath_kill + +XFAIL = pytest.mark.xfail(reason="chunk: view-item-names") + +FIGHTER = "character-0001" + +TEMPLE_IDOL = GearTemplate.model_validate( + { + "id": "temple_idol", + "name": "Idol of the drowned saint", + "cost_gp": 0, + "display_name": "idol of the drowned saint", + "display_name_plural": "idols of the drowned saint", + } +) +"""A bundled item with names its author wrote. `load_equipment()` has no `temple_idol`.""" + +SEAL_RING = ValuableSpec(kind="jewellery", name="The abbot's seal ring", value_gp=900) +PLAIN_GEM = ValuableSpec(kind="gem", value_gp=50) + + +def _adventure() -> Adventure: + """One cell, the entrance, in an area whose cache holds gear, a bundled item, a potion, and two valuables.""" + vault = FeatureSpec( + id="reliquary", + kind="treasure_cache", + description="A lead-lined reliquary.", + cell=(0, 0), + item_ids=("holy_water", "holy_water", "temple_idol"), + magic_item_ids=("potion_of_healing",), + valuables=(SEAL_RING, PLAIN_GEM), + ) + level = LevelSpec( + number=1, + width=1, + height=1, + entrance=(0, 0), + areas=(AreaSpec(id="vault", name="Vault", cells=((0, 0),), features=(vault,)),), + ) + return Adventure( + name="The Drowned Saint", + town=TownSpec(name="Threshold", travel_turns={"shrine": 1}), + dungeons=(DungeonSpec(id="shrine", name="The Shrine", levels=(level,)),), + items=(TEMPLE_IDOL,), + ) + + +def _player_view(game: GameSession) -> PlayerView: + view = game.view(Visibility.PLAYER) + assert isinstance(view, PlayerView) + return view + + +def _looted() -> tuple[GameSession, list[ItemAcquiredEvent]]: + """The stock party enters the shrine and empties the reliquary. Returns the session and the acquisitions.""" + game = GameSession.new(build_party(), _adventure(), seed=5) + assert game.execute(EnterDungeon(dungeon_id="shrine")).accepted + (feature,) = _player_view(game).explored[0].features + taken = game.execute(TakeTreasure(feature_id=feature.id)) + assert taken.accepted, [rejection.code for rejection in taken.rejections] + acquired = [event for event in taken.events if isinstance(event, ItemAcquiredEvent)] + assert acquired, "precondition: the party took the reliquary's contents" + return game, acquired + + +def _ids_of(acquired: list[ItemAcquiredEvent]) -> tuple[str, str, str]: + """The potion's and the two valuables' instance ids, in the order potion, seal ring, gem.""" + ids = [item_id for event in acquired for item_id in event.item_ids] + potion = next(item_id for item_id in ids if item_id.startswith("magic-item-")) + valuables = [item_id for item_id in ids if item_id.startswith("valuable-")] + assert len(valuables) == 2 + seal_ring, gem = sorted(valuables) + return potion, seal_ring, gem + + +def _holders(game: GameSession, item_id: str) -> list[str]: + """Every member who carries `item_id`, once per unit, as a catalog id or an instance id.""" + held = [] + for member in game.party.members: + for instance in member.inventory.all_instances(): + if isinstance(instance, MagicItemInstance): + if instance.instance_id == item_id: + held.append(member.id) + elif instance.template.id == item_id: + held.extend([member.id] * instance.quantity) + held.extend(member.id for valuable in member.inventory.valuables if valuable.instance_id == item_id) + return held + + +def _drop_everything(game: GameSession, order: list[str]) -> list[ItemsDroppedEvent]: + """Each holder drops each unit of the ids in `order`, in that order, onto the party's cell.""" + dropped = [] + for item_id in order: + for member_id in _holders(game, item_id): + result = game.execute(DropItems(character_id=member_id, item_ids=(item_id,))) + assert result.accepted, [rejection.code for rejection in result.rejections] + dropped += [event for event in result.events if isinstance(event, ItemsDroppedEvent)] + return dropped + + +def _shown_ids(view: PlayerView) -> set[str]: + """Every item id the view shows, read from the inventories and from the piles' contents.""" + shown: set[str] = set() + for member in view.party: + inventory = member.inventory + entries = [*inventory["items"], *inventory["wielded"], *inventory["rings"]] + entries += [entry for entry in (inventory["worn_armour"], inventory["shield"]) if entry is not None] + for entry in entries: + if entry["instance_type"] == "magic_item": + shown.add(entry["instance_id"]) + if entry["identified"]: + shown.add(entry["template_id"]) + else: + shown.add(entry["template"]["id"]) + shown.update(valuable["instance_id"] for valuable in inventory["valuables"]) + for pile in view.piles.values(): + shown.update(entry.item_id for entry in pile.contents) + return shown + + +# ---------------------------------------------------------------------- what the party carries + + +@XFAIL +def test_every_item_a_member_carries_is_named_singular_and_plural(): + """The reliquary's contents, spread across the party's packs. + + Holy water is named from the template the stack embeds, the bundled idol with the names its author wrote, the + unidentified potion by its masked name, and each valuable by its kind. The seal ring's own name stays in the + inventory's `valuables`. + """ + game, acquired = _looted() + potion, seal_ring, gem = _ids_of(acquired) + view = _player_view(game) + + assert view.item_names == { + "holy_water": "vial of holy water", + "temple_idol": "idol of the drowned saint", + potion: "potion", + seal_ring: "piece of jewellery", + gem: "gem", + } + assert view.item_names_plural == { + "holy_water": "vials of holy water", + "temple_idol": "idols of the drowned saint", + potion: "potions", + seal_ring: "pieces of jewellery", + gem: "gems", + } + + +@XFAIL +def test_every_id_an_acquisition_names_is_a_key_in_the_view_after_it(): + """`ItemAcquiredEvent.item_ids` repeats a catalog id once per unit, and each id is named after the command.""" + game, acquired = _looted() + view = _player_view(game) + + for event in acquired: + for item_id in event.item_ids: + assert item_id in view.item_names and item_id in view.item_names_plural, item_id + assert sum(event.item_ids.count("holy_water") for event in acquired) == 2 + + +@XFAIL +def test_the_view_names_exactly_the_ids_it_shows(): + """Every key is an id the inventories or the piles' contents show, and every such id is a key.""" + game, acquired = _looted() + potion, _, _ = _ids_of(acquired) + _drop_everything(game, ["holy_water", potion]) + view = _player_view(game) + + assert set(view.item_names) == _shown_ids(view) + assert set(view.item_names_plural) == set(view.item_names) + + +def test_a_party_that_carries_nothing_has_no_item_names(): + """The stock party starts with empty packs. This holds before the chunk too.""" + game = GameSession.new(build_party(), _adventure(), seed=5) + + view = _player_view(game) + + assert view.item_names == {} + assert view.item_names_plural == {} + + +# ---------------------------------------------------------------------- what lies in a pile + + +@XFAIL +def test_a_piles_contents_give_each_entrys_id_and_count_beside_the_strings(): + """The whole haul dropped on the party's cell. The strings stay as they were, and `contents` follows their order. + + The pile lists mundane stacks, then magic items, then valuables. The two vials merge into one stack of 2 whoever + dropped them, and the valuables keep the order they were dropped in. + """ + game, acquired = _looted() + potion, seal_ring, gem = _ids_of(acquired) + dropped = _drop_everything(game, ["holy_water", "temple_idol", potion, seal_ring, gem]) + view = _player_view(game) + + (pile,) = view.piles.values() + assert pile.items == ("holy_water×2", "temple_idol×1", "a potion", "The abbot's seal ring", "gem") + assert pile.contents == ( + PileItemView(item_id="holy_water", quantity=2), + PileItemView(item_id="temple_idol", quantity=1), + PileItemView(item_id=potion, quantity=1), + PileItemView(item_id=seal_ring, quantity=1), + PileItemView(item_id=gem, quantity=1), + ) + for event in dropped: + for item_id in event.item_ids: + assert item_id in view.item_names, item_id + + +@XFAIL +def test_a_bundled_item_in_a_pile_is_named_from_the_sessions_catalog(): + """Nobody carries the idol once it's dropped, so its name comes from `effective_equipment`, not a pack.""" + game, acquired = _looted() + potion, seal_ring, gem = _ids_of(acquired) + _drop_everything(game, ["holy_water", "temple_idol", potion, seal_ring, gem]) + + view = _player_view(game) + + assert all(member.inventory["items"] == [] for member in view.party) + assert view.item_names == { + "holy_water": "vial of holy water", + "temple_idol": "idol of the drowned saint", + potion: "potion", + seal_ring: "piece of jewellery", + gem: "gem", + } + assert view.item_names_plural["temple_idol"] == "idols of the drowned saint" + + +# ---------------------------------------------------------------------- masked and identified magic items + + +def _granted(game: GameSession, item_id: str, member_id: str = FIGHTER) -> str: + result = game.execute(GrantItem(character_id=member_id, item_id=item_id)) + assert result.accepted, [rejection.code for rejection in result.rejections] + (instance_id,) = next(event.item_ids for event in result.events if isinstance(event, ItemAcquiredEvent)) + return instance_id + + +def _town() -> GameSession: + return GameSession.new(build_party(), _adventure(), seed=5) + + +def _entry(view: PlayerView, instance_id: str, member_id: str = FIGHTER) -> dict: + (member,) = (member for member in view.party if member.id == member_id) + return next(entry for entry in member.inventory["items"] if entry.get("instance_id") == instance_id) + + +@XFAIL +@pytest.mark.parametrize( + ("template_id", "names"), + [ + pytest.param("potion_of_healing", ("potion", "potions"), id="potion"), + pytest.param("spell_scroll_1", ("scroll", "scrolls"), id="scroll"), + pytest.param("ring_of_protection", ("ring", "rings"), id="ring"), + pytest.param("wand_of_cold", ("wand", "wands"), id="wand"), + pytest.param("staff_of_healing", ("staff", "staves"), id="staff"), + pytest.param("rod_of_cancellation", ("rod", "rods"), id="rod"), + pytest.param("bag_of_holding", ("curious device", "curious devices"), id="misc"), + ], +) +def test_an_unidentified_item_is_named_by_its_category_mask(template_id: str, names: tuple[str, str]): + """The mask is the inventory's `display` without its article, and the template id stays out of the view.""" + game = _town() + instance_id = _granted(game, template_id) + + view = _player_view(game) + + assert (view.item_names[instance_id], view.item_names_plural[instance_id]) == names + assert _entry(view, instance_id)["display"] == f"a {names[0]}" + assert template_id not in view.model_dump_json() + + +@XFAIL +def test_an_unidentified_items_true_name_never_reaches_the_view(): + """Neither the potion's catalog id nor its true name, in either case, appears anywhere in the view.""" + game = _town() + _granted(game, "potion_of_healing") + + blob = _player_view(game).model_dump_json() + + for hidden in ("potion_of_healing", "Potion of Healing", "potion of healing", "potions of healing"): + assert hidden not in blob + assert '"potion"' in blob + + +@XFAIL +@pytest.mark.parametrize( + ("cursed", "lookalike", "base", "names"), + [ + pytest.param( + "cursed_shield_minus_2", + "shield_plus_1", + None, + ("shield with a faint aura", "shields with a faint aura"), + id="shield_minus_2", + ), + pytest.param( + "cursed_shield_ac_9", + "shield_plus_1", + None, + ("shield with a faint aura", "shields with a faint aura"), + id="shield_ac_9", + ), + pytest.param( + "cursed_armour_minus_1", + "armour_plus_1", + "chainmail", + ("suit of chainmail with a faint aura", "suits of chainmail with a faint aura"), + id="armour_minus_1", + ), + pytest.param( + "cursed_armour_ac_9", + "armour_plus_1", + "plate_mail", + ("suit of plate mail with a faint aura", "suits of plate mail with a faint aura"), + id="armour_ac_9", + ), + ], +) +def test_a_cursed_item_and_its_lookalike_have_the_same_names(cursed, lookalike, base, names): + """Two sessions that differ only in which of the pair the fighter got show the same names for it.""" + views = [] + for template_id in (cursed, lookalike): + game = _town() + instance_id = _granted(game, template_id) + if base is not None: + instance = game.member(FIGHTER).inventory.magic_item(instance_id) + assert instance is not None + instance.base_item_id = base + views.append((instance_id, _player_view(game))) + + (cursed_id, cursed_view), (lookalike_id, lookalike_view) = views + assert cursed_id == lookalike_id + assert cursed_view.item_names == lookalike_view.item_names == {cursed_id: names[0]} + assert cursed_view.item_names_plural == lookalike_view.item_names_plural == {cursed_id: names[1]} + assert cursed not in cursed_view.model_dump_json() + + +@pytest.mark.parametrize( + ("template_id", "base", "display", "names"), + [ + # The base's display_name with an article: "an" before a vowel. Today it reads "a arrows (quiver of 20) ...". + pytest.param( + "arrows_plus_1", + "arrows", + "an arrow with a faint aura", + ("arrow with a faint aura", "arrows with a faint aura"), + id="arrows", + marks=XFAIL, + ), + pytest.param( + "crossbow_bolts_plus_2", + "crossbow_bolts", + "a crossbow bolt with a faint aura", + ("crossbow bolt with a faint aura", "crossbow bolts with a faint aura"), + id="crossbow_bolts", + marks=XFAIL, + ), + # Body armour is a suit. Today it reads "a chainmail with a faint aura". + pytest.param( + "armour_plus_1", + "chainmail", + "a suit of chainmail with a faint aura", + ("suit of chainmail with a faint aura", "suits of chainmail with a faint aura"), + id="chainmail", + marks=XFAIL, + ), + # A suit with no mundane item recorded. Today it reads "a arm with a faint aura". + pytest.param( + "armour_plus_1", + None, + "a suit of armour with a faint aura", + ("suit of armour with a faint aura", "suits of armour with a faint aura"), + id="no_base", + marks=XFAIL, + ), + # The names a single word gives are unchanged in `display`, and these two already hold. + pytest.param("shield_plus_1", "shield", "a shield with a faint aura", None, id="shield"), + pytest.param("dagger_plus_1", "dagger", "a dagger with a faint aura", None, id="dagger"), + ], +) +def test_an_enchanted_arm_is_named_after_one_unit_of_its_base(template_id, base, display, names): + """The mask names the mundane item underneath by its display_name, so a stack of arrows reads in units.""" + game = _town() + quantity = 13 if base in ("arrows", "crossbow_bolts") else 1 + instance = MagicItemInstance( + instance_id="magic-item-9001", template_id=template_id, base_item_id=base, quantity=quantity + ) + game.member(FIGHTER).inventory.items.append(instance) + + view = _player_view(game) + + assert _entry(view, "magic-item-9001")["display"] == display + if names is not None: + assert (view.item_names["magic-item-9001"], view.item_names_plural["magic-item-9001"]) == names + + +@XFAIL +def test_an_identified_item_is_named_by_its_template_under_both_ids(): + """Once identified, the inventory shows the template id, and it and the instance id have the true names.""" + game = _town() + instance_id = _granted(game, "potion_of_healing") + identified = game.execute(IdentifyItem(character_id=FIGHTER, item_id=instance_id)) + assert identified.accepted, [rejection.code for rejection in identified.rejections] + + view = _player_view(game) + + assert _entry(view, instance_id)["template_id"] == "potion_of_healing" + assert view.item_names == {instance_id: "potion of healing", "potion_of_healing": "potion of healing"} + assert view.item_names_plural == {instance_id: "potions of healing", "potion_of_healing": "potions of healing"} + + +@XFAIL +def test_the_identification_event_names_the_item(): + """`IdentifyItem` leaves the potion in the pack, and the event and the view give the same names.""" + game = _town() + instance_id = _granted(game, "potion_of_healing") + + result = game.execute(IdentifyItem(character_id=FIGHTER, item_id=instance_id)) + + (event,) = (event for event in result.events if isinstance(event, ItemIdentifiedEvent)) + assert (event.display_name, event.display_name_plural) == ("potion of healing", "potions of healing") + assert _player_view(game).item_names[instance_id] == event.display_name + + +@XFAIL +def test_a_potion_identified_by_drinking_it_is_named_only_by_its_event(): + """Drinking an unidentified potion identifies it and uses it up in one command. + + The view before showed it masked, and the view after doesn't show it, so neither names `potion_of_healing`. The + identification event does. + """ + game = _town() + instance_id = _granted(game, "potion_of_healing") + assert game.execute(EnterDungeon(dungeon_id="shrine")).accepted + before = _player_view(game) + + result = game.execute(UseItem(character_id=FIGHTER, item_id=instance_id)) + assert result.accepted, [rejection.code for rejection in result.rejections] + + after = _player_view(game) + (event,) = (event for event in result.events if isinstance(event, ItemIdentifiedEvent)) + assert event.template_id == "potion_of_healing" + assert (event.display_name, event.display_name_plural) == ("potion of healing", "potions of healing") + assert before.item_names == {instance_id: "potion"} + assert "potion_of_healing" not in before.item_names and "potion_of_healing" not in after.item_names + assert instance_id not in after.item_names + + +# ---------------------------------------------------------------------- valuables + + +@XFAIL +def test_a_valuable_is_named_by_its_kind_whatever_its_own_name(): + """A gem the treasure tables roll is named `"Gem"`, and a piece of jewellery can have any name an author gives it. + + Both are named by their kind, and the inventory keeps each one's own name and value, which the players see from + the moment they take it. + """ + game = _town() + valuables = game.member(FIGHTER).inventory.valuables + valuables.append(ValuableInstance(instance_id="valuable-9001", kind="gem", name="Gem", value_gp=50)) + valuables.append(ValuableInstance(instance_id="valuable-9002", kind="jewellery", name="Jewellery", value_gp=600)) + valuables.append( + ValuableInstance(instance_id="valuable-9003", kind="jewellery", name="The abbot's seal ring", value_gp=900) + ) + + view = _player_view(game) + + assert view.item_names == { + "valuable-9001": "gem", + "valuable-9002": "piece of jewellery", + "valuable-9003": "piece of jewellery", + } + assert view.item_names_plural == { + "valuable-9001": "gems", + "valuable-9002": "pieces of jewellery", + "valuable-9003": "pieces of jewellery", + } + (member,) = (member for member in view.party if member.id == FIGHTER) + assert [(entry["name"], entry["value_gp"]) for entry in member.inventory["valuables"]] == [ + ("Gem", 50), + ("Jewellery", 600), + ("The abbot's seal ring", 900), + ] + + +# ---------------------------------------------------------------------- destroyed equipment + + +@XFAIL +def test_a_destroyed_unidentified_item_is_named_by_its_mask(): + """A hellhound's breath kills a member whose pack holds one unidentified Sword +1, which fails its save. + + `EquipmentDestroyedEvent` has player visibility, so it names the sword as the inventory showed it, "a sword with a + faint aura", not as "Sword +1". The sword's base is the mundane sword, so the mask is the sword's display name. + """ + _, _, event = breath_kill(need_saved=False) + + assert event.visibility is Visibility.PLAYER + assert event.item_names == ("a sword with a faint aura",) From ea29b9239672bf4874fa484fb02f4a178083e67c Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:14:55 -0800 Subject: [PATCH 02/14] Name every item the player view shows, for one and for two or more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/osrlib/core/combat.py | 8 +- src/osrlib/core/items.py | 99 ++- src/osrlib/crawl/_magic_items.py | 9 +- src/osrlib/crawl/views.py | 156 +++-- src/osrlib/data/equipment.json | 294 ++++---- src/osrlib/data/magic_items.json | 666 ++++++++++--------- tests/goldens/phase1_party.json | 171 +++-- tests/goldens/phase5_milestone.json | 37 +- tests/goldens/phase5_npc_parties.json | 481 ++++++++------ tools/srd_compile/equipment.py | 48 ++ tools/srd_compile/magic_items.py | 53 ++ tools/srd_compile/overrides/equipment.json | 146 ++++ tools/srd_compile/overrides/magic_items.json | 16 + 13 files changed, 1412 insertions(+), 772 deletions(-) create mode 100644 tools/srd_compile/overrides/equipment.json diff --git a/src/osrlib/core/combat.py b/src/osrlib/core/combat.py index 9d984435..94f3403a 100644 --- a/src/osrlib/core/combat.py +++ b/src/osrlib/core/combat.py @@ -173,7 +173,9 @@ MissileRanges, WeaponQuality, WeaponTemplate, + _masked_names, _shield_ac_parts, + _with_article, equipped_item_modifiers, magic_item_template, ) @@ -2099,7 +2101,8 @@ def destroy_equipment( items that save stay in the inventory's `items` list, no longer equipped. The saving throws report no events of their own. The function returns one [`EquipmentDestroyedEvent`][osrlib.core.events.EquipmentDestroyedEvent], which lists - the items destroyed and the items saved. In a + the items destroyed and the items saved. It names an unidentified magic item by its masked + name, like `"a sword with a faint aura"`, because the players see the event. In a [`GameSession`][osrlib.crawl.session.GameSession], that event's page says where a dead party member's saved items go. @@ -2176,7 +2179,8 @@ def destroy_equipment( if save_stream.randbelow(20) + 1 + best_bonus >= required: saved.append(instance) continue - destroyed.append(template.name) + # The event has player visibility, so an unidentified item is named as the inventory shows it. + destroyed.append(template.name if instance.identified else _with_article(_masked_names(instance)[0])) else: destroyed.append(instance.template.name) inventory.items = list(saved) diff --git a/src/osrlib/core/items.py b/src/osrlib/core/items.py index 87bab239..a7d7cb82 100644 --- a/src/osrlib/core/items.py +++ b/src/osrlib/core/items.py @@ -91,7 +91,7 @@ from collections.abc import Mapping from typing import TYPE_CHECKING, Annotated, Any, Literal -from pydantic import ConfigDict, Field, field_validator, model_validator +from pydantic import ConfigDict, Field, ValidationInfo, field_validator, model_validator import osrlib.core from osrlib.core._descriptions import _StrEnum @@ -99,6 +99,7 @@ from osrlib.core.dice import parse from osrlib.core.effects import ModifierSpec from osrlib.core.frozen import FrozenMap, _Model +from osrlib.core.monsters import _regular_plural from osrlib.core.rng import RngStream from osrlib.core.ruleset import EncumbranceMode, Ruleset from osrlib.core.treasure import MagicItemType, TreasureEntry @@ -421,6 +422,16 @@ class WeaponTemplate(_Model): osrlib doesn't read it during play. """ + @field_validator("display_name") + @classmethod + def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str: + return value or info.data.get("name", "") + + @field_validator("display_name_plural") + @classmethod + def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: + return value or _regular_plural(info.data.get("display_name", "")) + @field_validator("damage") @classmethod def _damage_must_parse(cls, value: str) -> str: @@ -501,6 +512,16 @@ class ArmourTemplate(_Model): osrlib doesn't read it during play. """ + @field_validator("display_name") + @classmethod + def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str: + return value or info.data.get("name", "") + + @field_validator("display_name_plural") + @classmethod + def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: + return value or _regular_plural(info.data.get("display_name", "")) + @model_validator(mode="after") def _body_armour_or_shield(self) -> ArmourTemplate: body_fields = (self.ac is not None, self.ac_ascending is not None, self.category is not None) @@ -632,6 +653,16 @@ class GearTemplate(_Model): osrlib doesn't read it during play. """ + @field_validator("display_name") + @classmethod + def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str: + return value or info.data.get("name", "") + + @field_validator("display_name_plural") + @classmethod + def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: + return value or _regular_plural(info.data.get("display_name", "")) + class AmmunitionTemplate(_Model): """Ammunition for a missile weapon: arrows, quarrels, sling stones. @@ -687,6 +718,16 @@ class AmmunitionTemplate(_Model): osrlib doesn't read it during play. """ + @field_validator("display_name") + @classmethod + def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str: + return value or info.data.get("name", "") + + @field_validator("display_name_plural") + @classmethod + def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: + return value or _regular_plural(info.data.get("display_name", "")) + ItemTemplate = Annotated[ WeaponTemplate | ArmourTemplate | GearTemplate | AmmunitionTemplate, @@ -1125,6 +1166,16 @@ class MagicItemTemplate(_Model): osrlib doesn't read it during play. """ + @field_validator("display_name") + @classmethod + def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str: + return value or info.data.get("name", "") + + @field_validator("display_name_plural") + @classmethod + def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: + return value or _regular_plural(info.data.get("display_name", "")) + @field_validator("charges_dice", "quantity_dice") @classmethod def _dice_must_parse(cls, value: str | None) -> str | None: @@ -2373,6 +2424,52 @@ def magic_item_template(instance: MagicItemInstance) -> MagicItemTemplate: return load_magic_items().get(instance.template_id) +_MASKED_CATEGORY_NAMES = { + MagicItemCategory.POTION: ("potion", "potions"), + MagicItemCategory.SCROLL: ("scroll", "scrolls"), + MagicItemCategory.RING: ("ring", "rings"), + MagicItemCategory.WAND: ("wand", "wands"), + MagicItemCategory.STAFF: ("staff", "staves"), + MagicItemCategory.ROD: ("rod", "rods"), + MagicItemCategory.MISC: ("curious device", "curious devices"), +} +"""What the players call an unidentified item of each category that isn't an enchanted arm.""" + + +def _masked_names(instance: MagicItemInstance) -> tuple[str, str]: + """Return what the players call an unidentified magic item, for one and for two or more, with no article. + + An item whose category has a name in `_MASKED_CATEGORY_NAMES` gets that name, like `"potion"`. An enchanted + weapon, piece of ammunition, suit of armour, or shield is named after one unit of the mundane item underneath it, + its `display_name` followed by "with a faint aura", the concession made because *detect magic* exists: `"arrow + with a faint aura"`, `"suit of chainmail with a faint aura"`. A suit of enchanted armour with no mundane item + recorded is `"suit of armour with a faint aura"`. + + The name depends on the category and the base alone, so a cursed item has the names of the item it passes for, + and neither the bonus nor the curse shows. + """ + from osrlib.data import load_equipment + + template = magic_item_template(instance) + category_names = _MASKED_CATEGORY_NAMES.get(template.category) + if category_names is not None: + return category_names + base_id = instance.base_item_id or template.base_item_id + if base_id is not None: + base = load_equipment().get(base_id) + singular, plural = base.display_name, base.display_name_plural + elif template.category is MagicItemCategory.ARMOUR: + singular, plural = "suit of armour", "suits of armour" + else: + singular, plural = "weapon", "weapons" + return f"{singular} with a faint aura", f"{plural} with a faint aura" + + +def _with_article(name: str) -> str: + """Return `name` after the indefinite article, `"an"` before a vowel and `"a"` otherwise.""" + return f"{'an' if name[:1].lower() in ('a', 'e', 'i', 'o', 'u') else 'a'} {name}" + + def _shield_ac_parts(shield: AnyInstance | None, *, ascending: bool) -> tuple[int | None, int]: """Return the armour class a shield sets, or None, and the bonus the shield adds to armour class. diff --git a/src/osrlib/crawl/_magic_items.py b/src/osrlib/crawl/_magic_items.py index 6420587f..c525d700 100644 --- a/src/osrlib/crawl/_magic_items.py +++ b/src/osrlib/crawl/_magic_items.py @@ -42,7 +42,14 @@ def _identify_item_events(session, member, instance: MagicItemInstance) -> list: events: list[Event] = [] if not instance.identified: instance.identified = True - events.append(ItemIdentifiedEvent(instance_id=instance.instance_id, template_id=instance.template_id)) + events.append( + ItemIdentifiedEvent( + instance_id=instance.instance_id, + template_id=instance.template_id, + display_name=template.display_name, + display_name_plural=template.display_name_plural, + ) + ) if template.cursed and not instance.cursed_revealed: instance.cursed_revealed = True events.append( diff --git a/src/osrlib/crawl/views.py b/src/osrlib/crawl/views.py index 280e0abe..65671be6 100644 --- a/src/osrlib/crawl/views.py +++ b/src/osrlib/crawl/views.py @@ -108,6 +108,7 @@ ``` """ +from collections.abc import Iterable from copy import deepcopy from typing import Literal @@ -119,7 +120,15 @@ from osrlib.core.effects import Condition, EffectsLedger, has_condition from osrlib.core.events import Event from osrlib.core.frozen import _Model -from osrlib.core.items import Coins, MagicItemCategory, MagicItemInstance, magic_item_template +from osrlib.core.items import ( + _MASKED_CATEGORY_NAMES, + Coins, + MagicItemCategory, + MagicItemInstance, + _masked_names, + _with_article, + magic_item_template, +) from osrlib.core.monsters import IdAllocator, MonsterInstance, _regular_plural from osrlib.core.ruleset import Ruleset from osrlib.crawl._feature_handles import ( @@ -133,7 +142,16 @@ from osrlib.crawl.adventure import Adventure from osrlib.crawl.battle import BattleState from osrlib.crawl.commands import Command, SessionMode -from osrlib.crawl.dungeon import Direction, DungeonState, EdgeKind, PartyLocation, Position, cell_ref, edge_ref +from osrlib.crawl.dungeon import ( + Direction, + DropPile, + DungeonState, + EdgeKind, + PartyLocation, + Position, + cell_ref, + edge_ref, +) from osrlib.crawl.encounter import EncounterState, _member_kind from osrlib.crawl.exploration import EXHAUSTED_KIND, FATIGUE_KIND, HEALING_SERVICES from osrlib.crawl.party import Party @@ -1292,29 +1310,18 @@ class RefereeView(_Model): arrived as, so check for a `dict` before reading an entry's attributes.""" -_MASKED_CATEGORY_NAMES = { - MagicItemCategory.POTION: "a potion", - MagicItemCategory.SCROLL: "a scroll", - MagicItemCategory.RING: "a ring", - MagicItemCategory.WAND: "a wand", - MagicItemCategory.STAFF: "a staff", - MagicItemCategory.ROD: "a rod", - MagicItemCategory.MISC: "a curious device", -} - - def _masked_magic_item(instance: MagicItemInstance) -> dict: """One magic item as the player sees it, masked until identified. - An unidentified item shows its category display name, and an enchanted arm shows its - base instead, as in "a sword with a faint aura", the concession made because *detect - magic* exists. A display string built from that base weapon already includes the weapon's name, - so the unidentified item also shows the `qualities` of the mundane weapon underneath - it, exactly as an identified one does, and its `missile_ranges` when the rules give that - weapon ranges. A weapon with no printed ranges, a sword among them, gets the `qualities` key - and no `missile_ranges` key at all. Every magic staff reads "a staff", and every one is a - mundane staff underneath, so the display is the name of the weapon and every staff shows the - staff's `qualities`. A wand or other item whose display comes from its category shows + An unidentified item shows its category display name, and an enchanted arm shows one unit of + its base instead, as in "a sword with a faint aura" or "an arrow with a faint aura", the + concession made because *detect magic* exists. A display string built from that base weapon + already includes the weapon's name, so the unidentified item also shows the `qualities` of + the mundane weapon underneath it, exactly as an identified one does, and its `missile_ranges` + when the rules give that weapon ranges. A weapon with no printed ranges, a sword among them, + gets the `qualities` key and no `missile_ranges` key at all. Every magic staff reads "a + staff", and every one is a mundane staff underneath, so the display is the name of the weapon + and every staff shows the staff's `qualities`. A wand or other item whose display comes from its category shows neither field, because the display isn't the name of a weapon and the fields would single the item out among the items that show the same string. @@ -1328,7 +1335,6 @@ def _masked_magic_item(instance: MagicItemInstance) -> dict: level, because by the rules as written charges are undiscoverable. """ from osrlib.core.combat import attack_facet - from osrlib.data import load_equipment template = magic_item_template(instance) facet = attack_facet(instance) @@ -1343,12 +1349,8 @@ def _masked_magic_item(instance: MagicItemInstance) -> dict: "cursed": instance.cursed_revealed, } else: - display = _MASKED_CATEGORY_NAMES.get(template.category) - if display is None: - base_id = instance.base_item_id or template.base_item_id - base_name = load_equipment().get(base_id).name.lower() if base_id is not None else "arm" - display = f"a {base_name} with a faint aura" - elif template.category is not MagicItemCategory.STAFF: + display = _with_article(_masked_names(instance)[0]) + if template.category in _MASKED_CATEGORY_NAMES and template.category is not MagicItemCategory.STAFF: # The display came from the category table, not the base weapon, so # attaching weapon facts here would single this one item out among the items in its # category that show the same string. "A staff" is the name of the weapon under every staff. @@ -1466,24 +1468,8 @@ def build_player_view(session) -> PlayerView: ) explored = tuple(_explored_levels(session)) visible_refs = _visible_cell_refs(session) - piles = { - ref: PileView( - items=tuple( - ( - *(f"{entry.item_id}×{entry.quantity}" for entry in pile.items), - *( - str(_masked_magic_item(item).get("name", _masked_magic_item(item).get("display"))) - for item in pile.magic_items - ), - *(valuable.name or valuable.kind for valuable in pile.valuables), - ) - ), - coins_gp_value=pile.coins.value_gp, - coins=pile.coins, - ) - for ref, pile in session.dungeon_state.piles.items() - if ref in visible_refs - } + known_piles = {ref: pile for ref, pile in session.dungeon_state.piles.items() if ref in visible_refs} + piles = {ref: _pile_view(pile) for ref, pile in known_piles.items()} fatigued = any(session.ledger.active_on(member.id, FATIGUE_KIND) for member in session.party.members) exhausted = any(session.ledger.active_on(member.id, EXHAUSTED_KIND) for member in session.party.members) deprivation = { @@ -1492,6 +1478,7 @@ def build_player_view(session) -> PlayerView: if state.worst > 0 } spell_names, reversed_spell_names = _spell_names(session, members, effects) + item_names, item_names_plural = _item_names(session, known_piles.values()) return PlayerView( adventure_name=session.adventure.name, adventure_description=session.adventure.description, @@ -1514,6 +1501,8 @@ def build_player_view(session) -> PlayerView: effects=effects, spell_names=spell_names, reversed_spell_names=reversed_spell_names, + item_names=item_names, + item_names_plural=item_names_plural, fatigued=fatigued, exhausted=exhausted, deprivation=deprivation, @@ -1544,6 +1533,79 @@ def _spell_names(session, members, effects) -> tuple[dict[str, str], dict[str, s return names, reversed_names +def _pile_view(pile: DropPile) -> PileView: + """One known pile as the players see it, with each entry's display string and its id and count.""" + magic_items = [_masked_magic_item(item) for item in pile.magic_items] + return PileView( + items=( + *(f"{entry.item_id}×{entry.quantity}" for entry in pile.items), + *(str(item.get("name", item.get("display"))) for item in magic_items), + *(valuable.name or valuable.kind for valuable in pile.valuables), + ), + coins_gp_value=pile.coins.value_gp, + coins=pile.coins, + contents=( + *(PileItemView(item_id=entry.item_id, quantity=entry.quantity) for entry in pile.items), + *(PileItemView(item_id=item.instance_id, quantity=item.quantity) for item in pile.magic_items), + *(PileItemView(item_id=valuable.instance_id) for valuable in pile.valuables), + ), + ) + + +_VALUABLE_NAMES = {"gem": ("gem", "gems"), "jewellery": ("piece of jewellery", "pieces of jewellery")} +"""What the players call a valuable of each kind, whatever name the piece has.""" + + +def _item_names(session, piles: Iterable[DropPile]) -> tuple[dict[str, str], dict[str, str]]: + # Each id the inventories and the known piles show gets one entry, from the first place it appears. A + # stack a member carries is named from the template it embeds, and a pile's stack from the session's + # catalog, which has the items the adventure bundles. An unidentified magic item keeps its mask, and + # its template id stays out. + names: dict[str, str] = {} + plurals: dict[str, str] = {} + + def add(item_id: str, singular: str, plural: str) -> None: + if item_id not in names: + names[item_id] = singular + plurals[item_id] = plural + + def add_magic_item(instance: MagicItemInstance) -> None: + if instance.identified: + template = magic_item_template(instance) + add(instance.instance_id, template.display_name, template.display_name_plural) + add(instance.template_id, template.display_name, template.display_name_plural) + else: + add(instance.instance_id, *_masked_names(instance)) + + for member in session.party.members: + for instance in member.inventory.all_instances(): + if isinstance(instance, MagicItemInstance): + add_magic_item(instance) + else: + add(instance.template.id, instance.template.display_name, instance.template.display_name_plural) + for valuable in member.inventory.valuables: + add(valuable.instance_id, *_VALUABLE_NAMES[valuable.kind]) + catalog = { + template.id: template + for template in ( + *session.effective_equipment.weapons, + *session.effective_equipment.armour, + *session.effective_equipment.gear, + *session.effective_equipment.ammunition, + ) + } + for pile in piles: + for entry in pile.items: + template = catalog.get(entry.item_id) + if template is not None: + add(entry.item_id, template.display_name, template.display_name_plural) + for instance in pile.magic_items: + add_magic_item(instance) + for valuable in pile.valuables: + add(valuable.instance_id, *_VALUABLE_NAMES[valuable.kind]) + return names, plurals + + def _quest_views(session): """The active quests, in document order, each with its revealed objectives. diff --git a/src/osrlib/data/equipment.json b/src/osrlib/data/equipment.json index 17ae1c7e..20faade9 100644 --- a/src/osrlib/data/equipment.json +++ b/src/osrlib/data/equipment.json @@ -11,8 +11,8 @@ "ammunition": [ { "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "arrow", + "display_name_plural": "arrows", "id": "arrows", "item_type": "ammunition", "lot_size": 20, @@ -23,8 +23,8 @@ }, { "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "crossbow bolt", + "display_name_plural": "crossbow bolts", "id": "crossbow_bolts", "item_type": "ammunition", "lot_size": 30, @@ -35,8 +35,8 @@ }, { "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "silver tipped arrow", + "display_name_plural": "silver tipped arrows", "id": "silver_tipped_arrow", "item_type": "ammunition", "lot_size": 1, @@ -47,8 +47,8 @@ }, { "cost_gp": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "sling stone", + "display_name_plural": "sling stones", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -65,8 +65,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of chainmail", + "display_name_plural": "suits of chainmail", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -79,12 +79,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 }, { @@ -93,8 +96,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 60, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of plate mail", + "display_name_plural": "suits of plate mail", "id": "plate_mail", "item_type": "armour", "name": "Plate mail", @@ -107,8 +110,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -121,8 +124,8 @@ "capacity_coins": 400, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "backpack", + "display_name_plural": "backpacks", "id": "backpack", "item_type": "gear", "lot_size": 1, @@ -134,8 +137,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "crowbar", + "display_name_plural": "crowbars", "id": "crowbar", "item_type": "gear", "lot_size": 1, @@ -147,21 +150,24 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "bulb of garlic", + "display_name_plural": "bulbs of garlic", "id": "garlic", "item_type": "gear", "lot_size": 1, "name": "Garlic", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": null, "combat": null, "cost_gp": 25, - "display_name": "", - "display_name_plural": "", + "display_name": "grappling hook", + "display_name_plural": "grappling hooks", "id": "grappling_hook", "item_type": "gear", "lot_size": 1, @@ -173,21 +179,24 @@ "capacity_coins": null, "combat": null, "cost_gp": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "small hammer", + "display_name_plural": "small hammers", "id": "hammer", "item_type": "gear", "lot_size": 1, "name": "Hammer (small)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": null, "combat": null, "cost_gp": 25, - "display_name": "", - "display_name_plural": "", + "display_name": "holy symbol", + "display_name_plural": "holy symbols", "id": "holy_symbol", "item_type": "gear", "lot_size": 1, @@ -219,26 +228,32 @@ ] }, "cost_gp": 25, - "display_name": "", - "display_name_plural": "", + "display_name": "vial of holy water", + "display_name_plural": "vials of holy water", "id": "holy_water", "item_type": "gear", "lot_size": 1, "name": "Holy water (vial)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "iron spike", + "display_name_plural": "iron spikes", "id": "iron_spikes", "item_type": "gear", "lot_size": 12, "name": "Iron spikes (12)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "wedges_doors": true } @@ -247,8 +262,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "lantern", + "display_name_plural": "lanterns", "id": "lantern", "item_type": "gear", "lot_size": 1, @@ -264,13 +279,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "hand mirror", + "display_name_plural": "hand mirrors", "id": "mirror", "item_type": "gear", "lot_size": 1, "name": "Mirror (hand-sized, steel)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { @@ -297,13 +315,16 @@ ] }, "cost_gp": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "flask of oil", + "display_name_plural": "flasks of oil", "id": "oil_flask", "item_type": "gear", "lot_size": 1, "name": "Oil (1 flask)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "fuels_lantern": true } @@ -312,26 +333,32 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "10’ pole", + "display_name_plural": "10’ poles", "id": "pole", "item_type": "gear", "lot_size": 1, "name": "Pole (10’ long, wooden)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": null, "combat": null, "cost_gp": 15, - "display_name": "", - "display_name_plural": "", + "display_name": "iron ration", + "display_name_plural": "iron rations", "id": "rations_iron", "item_type": "gear", "lot_size": 7, "name": "Rations (iron, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -340,13 +367,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -355,65 +385,80 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "50’ coil of rope", + "display_name_plural": "50’ coils of rope", "id": "rope", "item_type": "gear", "lot_size": 1, "name": "Rope (50’)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": 600, "combat": null, "cost_gp": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "large sack", + "display_name_plural": "large sacks", "id": "sack_large", "item_type": "gear", "lot_size": 1, "name": "Sack (large)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": 200, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "small sack", + "display_name_plural": "small sacks", "id": "sack_small", "item_type": "gear", "lot_size": 1, "name": "Sack (small)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": null, "combat": null, "cost_gp": 3, - "display_name": "", - "display_name_plural": "", + "display_name": "set of stakes and mallet", + "display_name_plural": "sets of stakes and mallet", "id": "stakes_and_mallet", "item_type": "gear", "lot_size": 1, "name": "Stakes (3) and mallet", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": null, "combat": null, "cost_gp": 25, - "display_name": "", - "display_name_plural": "", + "display_name": "set of thieves’ tools", + "display_name_plural": "sets of thieves’ tools", "id": "thieves_tools", "item_type": "gear", "lot_size": 1, "name": "Thieves’ tools", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "required_for": "open_locks" } @@ -422,8 +467,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 3, - "display_name": "", - "display_name_plural": "", + "display_name": "tinder box", + "display_name_plural": "tinder boxes", "id": "tinder_box", "item_type": "gear", "lot_size": 1, @@ -443,13 +488,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -460,8 +508,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -475,26 +523,32 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "pint of wine", + "display_name_plural": "pints of wine", "id": "wine", "item_type": "gear", "lot_size": 2, "name": "Wine (2 pints)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} }, { "capacity_coins": null, "combat": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "bunch of wolfsbane", + "display_name_plural": "bunches of wolfsbane", "id": "wolfsbane", "item_type": "gear", "lot_size": 1, "name": "Wolfsbane (1 bunch)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} } ], @@ -536,8 +590,8 @@ { "cost_gp": 7, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "battle axe", + "display_name_plural": "battle axes", "id": "battle_axe", "item_type": "weapon", "material": "standard", @@ -554,8 +608,8 @@ { "cost_gp": 3, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "club", + "display_name_plural": "clubs", "id": "club", "item_type": "weapon", "material": "standard", @@ -571,8 +625,8 @@ { "cost_gp": 30, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "crossbow", + "display_name_plural": "crossbows", "id": "crossbow", "item_type": "weapon", "material": "standard", @@ -603,8 +657,8 @@ { "cost_gp": 3, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "dagger", + "display_name_plural": "daggers", "id": "dagger", "item_type": "weapon", "material": "standard", @@ -633,8 +687,8 @@ { "cost_gp": 4, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "hand axe", + "display_name_plural": "hand axes", "id": "hand_axe", "item_type": "weapon", "material": "standard", @@ -663,8 +717,8 @@ { "cost_gp": 1, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "javelin", + "display_name_plural": "javelins", "id": "javelin", "item_type": "weapon", "material": "standard", @@ -692,8 +746,8 @@ { "cost_gp": 5, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "lance", + "display_name_plural": "lances", "id": "lance", "item_type": "weapon", "material": "standard", @@ -709,8 +763,8 @@ { "cost_gp": 40, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "long bow", + "display_name_plural": "long bows", "id": "long_bow", "item_type": "weapon", "material": "standard", @@ -739,8 +793,8 @@ { "cost_gp": 5, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "mace", + "display_name_plural": "maces", "id": "mace", "item_type": "weapon", "material": "standard", @@ -756,8 +810,8 @@ { "cost_gp": 7, "damage": "1d10", - "display_name": "", - "display_name_plural": "", + "display_name": "pole arm", + "display_name_plural": "pole arms", "id": "pole_arm", "item_type": "weapon", "material": "standard", @@ -775,8 +829,8 @@ { "cost_gp": 25, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "short bow", + "display_name_plural": "short bows", "id": "short_bow", "item_type": "weapon", "material": "standard", @@ -805,8 +859,8 @@ { "cost_gp": 7, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "short sword", + "display_name_plural": "short swords", "id": "short_sword", "item_type": "weapon", "material": "standard", @@ -821,8 +875,8 @@ { "cost_gp": 30, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "silver dagger", + "display_name_plural": "silver daggers", "id": "silver_dagger", "item_type": "weapon", "material": "silver", @@ -851,8 +905,8 @@ { "cost_gp": 2, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "sling", + "display_name_plural": "slings", "id": "sling", "item_type": "weapon", "material": "standard", @@ -881,8 +935,8 @@ { "cost_gp": 3, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "spear", + "display_name_plural": "spears", "id": "spear", "item_type": "weapon", "material": "standard", @@ -912,8 +966,8 @@ { "cost_gp": 2, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "staff", + "display_name_plural": "staves", "id": "staff", "item_type": "weapon", "material": "standard", @@ -931,8 +985,8 @@ { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -947,8 +1001,8 @@ { "cost_gp": 15, "damage": "1d10", - "display_name": "", - "display_name_plural": "", + "display_name": "two-handed sword", + "display_name_plural": "two-handed swords", "id": "two_handed_sword", "item_type": "weapon", "material": "standard", @@ -965,8 +1019,8 @@ { "cost_gp": 5, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "war hammer", + "display_name_plural": "war hammers", "id": "war_hammer", "item_type": "weapon", "material": "standard", diff --git a/src/osrlib/data/magic_items.json b/src/osrlib/data/magic_items.json index 1f7020e7..e0947673 100644 --- a/src/osrlib/data/magic_items.json +++ b/src/osrlib/data/magic_items.json @@ -133,8 +133,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "amulet of protection against scrying", + "display_name_plural": "amulets of protection against scrying", "effect": null, "hoard_recipe": [], "id": "amulet_of_protection_against_scrying", @@ -169,8 +169,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of armour +1", + "display_name_plural": "suits of armour +1", "effect": null, "hoard_recipe": [], "id": "armour_plus_1", @@ -202,8 +202,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of armour +2", + "display_name_plural": "suits of armour +2", "effect": null, "hoard_recipe": [], "id": "armour_plus_2", @@ -235,8 +235,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of armour +3", + "display_name_plural": "suits of armour +3", "effect": null, "hoard_recipe": [], "id": "armour_plus_3", @@ -268,8 +268,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "arrow +1", + "display_name_plural": "arrows +1", "effect": null, "hoard_recipe": [], "id": "arrows_plus_1", @@ -301,8 +301,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "arrow +2", + "display_name_plural": "arrows +2", "effect": null, "hoard_recipe": [], "id": "arrows_plus_2", @@ -334,8 +334,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "axe +1", + "display_name_plural": "axes +1", "effect": null, "hoard_recipe": [], "id": "axe_plus_1", @@ -367,8 +367,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "axe +2", + "display_name_plural": "axes +2", "effect": null, "hoard_recipe": [], "id": "axe_plus_2", @@ -400,8 +400,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "bag of devouring", + "display_name_plural": "bags of devouring", "effect": null, "hoard_recipe": [], "id": "bag_of_devouring", @@ -436,8 +436,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "bag of holding", + "display_name_plural": "bags of holding", "effect": null, "hoard_recipe": [], "id": "bag_of_holding", @@ -476,8 +476,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "pair of boots of levitation", + "display_name_plural": "pairs of boots of levitation", "effect": null, "hoard_recipe": [], "id": "boots_of_levitation", @@ -514,8 +514,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "pair of boots of speed", + "display_name_plural": "pairs of boots of speed", "effect": null, "hoard_recipe": [], "id": "boots_of_speed", @@ -550,8 +550,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "pair of boots of travelling and leaping", + "display_name_plural": "pairs of boots of travelling and leaping", "effect": null, "hoard_recipe": [], "id": "boots_of_travelling_and_leaping", @@ -586,8 +586,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "bow +1", + "display_name_plural": "bows +1", "effect": null, "hoard_recipe": [], "id": "bow_plus_1", @@ -619,8 +619,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "broom of flying", + "display_name_plural": "brooms of flying", "effect": null, "hoard_recipe": [], "id": "broom_of_flying", @@ -655,8 +655,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "crossbow bolt +1", + "display_name_plural": "crossbow bolts +1", "effect": null, "hoard_recipe": [], "id": "crossbow_bolts_plus_1", @@ -688,8 +688,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "crossbow bolt +2", + "display_name_plural": "crossbow bolts +2", "effect": null, "hoard_recipe": [], "id": "crossbow_bolts_plus_2", @@ -721,8 +721,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "crystal ball", + "display_name_plural": "crystal balls", "effect": null, "hoard_recipe": [], "id": "crystal_ball", @@ -764,8 +764,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "crystal ball with clairaudience", + "display_name_plural": "crystal balls with clairaudience", "effect": null, "hoard_recipe": [], "id": "crystal_ball_with_clairaudience", @@ -798,8 +798,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "crystal ball with ESP", + "display_name_plural": "crystal balls with ESP", "effect": null, "hoard_recipe": [], "id": "crystal_ball_with_esp", @@ -835,8 +835,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of cursed armour, AC 9 [10]", + "display_name_plural": "suits of cursed armour, AC 9 [10]", "effect": null, "hoard_recipe": [], "id": "cursed_armour_ac_9", @@ -870,8 +870,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of cursed armour -1", + "display_name_plural": "suits of cursed armour -1", "effect": null, "hoard_recipe": [], "id": "cursed_armour_minus_1", @@ -905,8 +905,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of cursed armour -2", + "display_name_plural": "suits of cursed armour -2", "effect": null, "hoard_recipe": [], "id": "cursed_armour_minus_2", @@ -977,8 +977,8 @@ } ], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "cursed scroll", + "display_name_plural": "cursed scrolls", "effect": null, "hoard_recipe": [], "id": "cursed_scroll", @@ -1010,8 +1010,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "cursed shield, AC 9 [10]", + "display_name_plural": "cursed shields, AC 9 [10]", "effect": null, "hoard_recipe": [], "id": "cursed_shield_ac_9", @@ -1045,8 +1045,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "cursed shield -2", + "display_name_plural": "cursed shields -2", "effect": null, "hoard_recipe": [], "id": "cursed_shield_minus_2", @@ -1080,8 +1080,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "dagger +1", + "display_name_plural": "daggers +1", "effect": null, "hoard_recipe": [], "id": "dagger_plus_1", @@ -1113,8 +1113,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "dagger +2, +3 vs orcs, goblins, and kobolds", + "display_name_plural": "daggers +2, +3 vs orcs, goblins, and kobolds", "effect": null, "hoard_recipe": [], "id": "dagger_plus_2_plus_3_vs_orcs_goblins_and_kobolds", @@ -1157,8 +1157,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "displacer cloak", + "display_name_plural": "displacer cloaks", "effect": { "condition": null, "damage_dice": null, @@ -1234,8 +1234,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "set of drums of panic", + "display_name_plural": "sets of drums of panic", "effect": null, "hoard_recipe": [], "id": "drums_of_panic", @@ -1248,7 +1248,10 @@ "Activating: Unless an item’s description states otherwise, it may be used any number of times per day and is activated by concentration." ], "name": "Drums of Panic", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {}, "quantity_dice": null, "usable_by": { @@ -1271,8 +1274,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "efreeti bottle", + "display_name_plural": "efreeti bottles", "effect": null, "hoard_recipe": [], "id": "efreeti_bottle", @@ -1308,8 +1311,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "air elemental summoning device", + "display_name_plural": "air elemental summoning devices", "effect": null, "hoard_recipe": [], "id": "elemental_summoning_device_air", @@ -1352,8 +1355,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "earth elemental summoning device", + "display_name_plural": "earth elemental summoning devices", "effect": null, "hoard_recipe": [], "id": "elemental_summoning_device_earth", @@ -1396,8 +1399,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "fire elemental summoning device", + "display_name_plural": "fire elemental summoning devices", "effect": null, "hoard_recipe": [], "id": "elemental_summoning_device_fire", @@ -1440,8 +1443,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "water elemental summoning device", + "display_name_plural": "water elemental summoning devices", "effect": null, "hoard_recipe": [], "id": "elemental_summoning_device_water", @@ -1484,8 +1487,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "set of elven cloak and boots", + "display_name_plural": "sets of elven cloak and boots", "effect": null, "hoard_recipe": [], "id": "elven_cloak_and_boots", @@ -1498,7 +1501,10 @@ "Activating: Unless an item’s description states otherwise, it may be used any number of times per day and is activated by concentration." ], "name": "Elven Cloak and Boots", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {}, "quantity_dice": null, "usable_by": { @@ -1521,8 +1527,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "flying carpet", + "display_name_plural": "flying carpets", "effect": null, "hoard_recipe": [], "id": "flying_carpet", @@ -1558,8 +1564,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "pair of gauntlets of ogre power", + "display_name_plural": "pairs of gauntlets of ogre power", "effect": { "condition": null, "damage_dice": null, @@ -1625,8 +1631,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "girdle of giant strength", + "display_name_plural": "girdles of giant strength", "effect": { "condition": null, "damage_dice": null, @@ -1680,8 +1686,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "helm of alignment changing", + "display_name_plural": "helms of alignment changing", "effect": null, "hoard_recipe": [], "id": "helm_of_alignment_changing", @@ -1717,8 +1723,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "helm of reading languages and magic", + "display_name_plural": "helms of reading languages and magic", "effect": null, "hoard_recipe": [], "id": "helm_of_reading_languages_and_magic", @@ -1754,8 +1760,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "helm of telepathy", + "display_name_plural": "helms of telepathy", "effect": null, "hoard_recipe": [], "id": "helm_of_telepathy", @@ -1794,8 +1800,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "helm of teleportation", + "display_name_plural": "helms of teleportation", "effect": null, "hoard_recipe": [], "id": "helm_of_teleportation", @@ -1833,8 +1839,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "horn of blasting", + "display_name_plural": "horns of blasting", "effect": null, "hoard_recipe": [], "id": "horn_of_blasting", @@ -1871,8 +1877,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "mace +1", + "display_name_plural": "maces +1", "effect": null, "hoard_recipe": [], "id": "mace_plus_1", @@ -1904,8 +1910,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "mace +2", + "display_name_plural": "maces +2", "effect": null, "hoard_recipe": [], "id": "mace_plus_2", @@ -1937,8 +1943,8 @@ "cursed": false, "curses": [], "damage_bonus": 3, - "display_name": "", - "display_name_plural": "", + "display_name": "mace +3", + "display_name_plural": "maces +3", "effect": null, "hoard_recipe": [], "id": "mace_plus_3", @@ -1970,8 +1976,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "medallion of ESP 30’", + "display_name_plural": "medallions of ESP 30’", "effect": null, "hoard_recipe": [], "id": "medallion_of_esp_30", @@ -2008,8 +2014,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "medallion of ESP 90’", + "display_name_plural": "medallions of ESP 90’", "effect": null, "hoard_recipe": [], "id": "medallion_of_esp_90", @@ -2042,8 +2048,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "mirror of life trapping", + "display_name_plural": "mirrors of life trapping", "effect": null, "hoard_recipe": [], "id": "mirror_of_life_trapping", @@ -2081,8 +2087,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of clairaudience", + "display_name_plural": "potions of clairaudience", "effect": null, "hoard_recipe": [], "id": "potion_of_clairaudience", @@ -2119,8 +2125,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of clairvoyance", + "display_name_plural": "potions of clairvoyance", "effect": null, "hoard_recipe": [], "id": "potion_of_clairvoyance", @@ -2157,8 +2163,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of control animal", + "display_name_plural": "potions of control animal", "effect": null, "hoard_recipe": [], "id": "potion_of_control_animal", @@ -2196,8 +2202,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of control dragon", + "display_name_plural": "potions of control dragon", "effect": null, "hoard_recipe": [], "id": "potion_of_control_dragon", @@ -2238,8 +2244,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of control giant", + "display_name_plural": "potions of control giant", "effect": null, "hoard_recipe": [], "id": "potion_of_control_giant", @@ -2278,8 +2284,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of control human", + "display_name_plural": "potions of control human", "effect": null, "hoard_recipe": [], "id": "potion_of_control_human", @@ -2321,8 +2327,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of control plant", + "display_name_plural": "potions of control plant", "effect": null, "hoard_recipe": [], "id": "potion_of_control_plant", @@ -2362,8 +2368,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of control undead", + "display_name_plural": "potions of control undead", "effect": null, "hoard_recipe": [], "id": "potion_of_control_undead", @@ -2403,8 +2409,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of delusion", + "display_name_plural": "potions of delusion", "effect": null, "hoard_recipe": [], "id": "potion_of_delusion", @@ -2441,8 +2447,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of diminution", + "display_name_plural": "potions of diminution", "effect": null, "hoard_recipe": [], "id": "potion_of_diminution", @@ -2480,8 +2486,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of ESP", + "display_name_plural": "potions of ESP", "effect": null, "hoard_recipe": [], "id": "potion_of_esp", @@ -2516,8 +2522,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of fire resistance", + "display_name_plural": "potions of fire resistance", "effect": { "condition": null, "damage_dice": null, @@ -2594,8 +2600,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of flying", + "display_name_plural": "potions of flying", "effect": null, "hoard_recipe": [], "id": "potion_of_flying", @@ -2632,8 +2638,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of gaseous form", + "display_name_plural": "potions of gaseous form", "effect": null, "hoard_recipe": [], "id": "potion_of_gaseous_form", @@ -2672,8 +2678,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of giant strength", + "display_name_plural": "potions of giant strength", "effect": { "condition": null, "damage_dice": null, @@ -2740,8 +2746,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of growth", + "display_name_plural": "potions of growth", "effect": { "condition": null, "damage_dice": null, @@ -2806,8 +2812,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of healing", + "display_name_plural": "potions of healing", "effect": { "condition": null, "damage_dice": null, @@ -2863,8 +2869,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of heroism", + "display_name_plural": "potions of heroism", "effect": null, "hoard_recipe": [], "id": "potion_of_heroism", @@ -2906,8 +2912,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of invisibility", + "display_name_plural": "potions of invisibility", "effect": { "condition": "invisible", "damage_dice": null, @@ -2961,8 +2967,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of invulnerability", + "display_name_plural": "potions of invulnerability", "effect": { "condition": null, "damage_dice": null, @@ -3040,8 +3046,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of levitation", + "display_name_plural": "potions of levitation", "effect": null, "hoard_recipe": [], "id": "potion_of_levitation", @@ -3079,8 +3085,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of longevity", + "display_name_plural": "potions of longevity", "effect": null, "hoard_recipe": [], "id": "potion_of_longevity", @@ -3115,8 +3121,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of poison", + "display_name_plural": "potions of poison", "effect": { "condition": null, "damage_dice": null, @@ -3171,8 +3177,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of polymorph self", + "display_name_plural": "potions of polymorph self", "effect": null, "hoard_recipe": [], "id": "potion_of_polymorph_self", @@ -3207,8 +3213,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of speed", + "display_name_plural": "potions of speed", "effect": { "condition": null, "damage_dice": null, @@ -3266,8 +3272,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "potion of treasure finding", + "display_name_plural": "potions of treasure finding", "effect": null, "hoard_recipe": [], "id": "potion_of_treasure_finding", @@ -3307,8 +3313,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of controlling animals", + "display_name_plural": "rings of controlling animals", "effect": null, "hoard_recipe": [], "id": "ring_of_controlling_animals", @@ -3349,8 +3355,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of controlling humans", + "display_name_plural": "rings of controlling humans", "effect": null, "hoard_recipe": [], "id": "ring_of_controlling_humans", @@ -3390,8 +3396,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of controlling plants", + "display_name_plural": "rings of controlling plants", "effect": null, "hoard_recipe": [], "id": "ring_of_controlling_plants", @@ -3430,8 +3436,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of delusion", + "display_name_plural": "rings of delusion", "effect": null, "hoard_recipe": [], "id": "ring_of_delusion", @@ -3468,8 +3474,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of djinni summoning", + "display_name_plural": "rings of djinni summoning", "effect": null, "hoard_recipe": [], "id": "ring_of_djinni_summoning", @@ -3507,8 +3513,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of fire resistance", + "display_name_plural": "rings of fire resistance", "effect": { "condition": null, "damage_dice": null, @@ -3583,8 +3589,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of invisibility", + "display_name_plural": "rings of invisibility", "effect": null, "hoard_recipe": [], "id": "ring_of_invisibility", @@ -3621,8 +3627,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of protection", + "display_name_plural": "rings of protection", "effect": { "condition": null, "damage_dice": null, @@ -3686,8 +3692,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of protection, 5’ radius", + "display_name_plural": "rings of protection, 5’ radius", "effect": { "condition": null, "damage_dice": null, @@ -3754,8 +3760,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of regeneration", + "display_name_plural": "rings of regeneration", "effect": { "condition": null, "damage_dice": null, @@ -3817,8 +3823,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of spell storing", + "display_name_plural": "rings of spell storing", "effect": null, "hoard_recipe": [], "id": "ring_of_spell_storing", @@ -3859,8 +3865,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of spell turning", + "display_name_plural": "rings of spell turning", "effect": null, "hoard_recipe": [], "id": "ring_of_spell_turning", @@ -3896,8 +3902,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of telekinesis", + "display_name_plural": "rings of telekinesis", "effect": null, "hoard_recipe": [], "id": "ring_of_telekinesis", @@ -3936,8 +3942,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of water walking", + "display_name_plural": "rings of water walking", "effect": null, "hoard_recipe": [], "id": "ring_of_water_walking", @@ -3972,8 +3978,8 @@ "cursed": true, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of weakness", + "display_name_plural": "rings of weakness", "effect": { "condition": null, "damage_dice": null, @@ -4030,8 +4036,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of wishes", + "display_name_plural": "rings of wishes", "effect": null, "hoard_recipe": [], "id": "ring_of_wishes", @@ -4067,8 +4073,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "ring of x-ray vision", + "display_name_plural": "rings of x-ray vision", "effect": null, "hoard_recipe": [], "id": "ring_of_x_ray_vision", @@ -4109,8 +4115,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "rod of cancellation", + "display_name_plural": "rods of cancellation", "effect": null, "hoard_recipe": [], "id": "rod_of_cancellation", @@ -4147,8 +4153,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "rope of climbing", + "display_name_plural": "ropes of climbing", "effect": null, "hoard_recipe": [], "id": "rope_of_climbing", @@ -4184,8 +4190,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "scarab of protection", + "display_name_plural": "scarabs of protection", "effect": null, "hoard_recipe": [], "id": "scarab_of_protection", @@ -4221,8 +4227,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "scroll of protection from elementals", + "display_name_plural": "scrolls of protection from elementals", "effect": { "condition": null, "damage_dice": null, @@ -4295,8 +4301,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "scroll of protection from lycanthropes", + "display_name_plural": "scrolls of protection from lycanthropes", "effect": { "condition": null, "damage_dice": null, @@ -4367,8 +4373,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "scroll of protection from magic", + "display_name_plural": "scrolls of protection from magic", "effect": null, "hoard_recipe": [], "id": "scroll_of_protection_from_magic", @@ -4407,8 +4413,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "scroll of protection from undead", + "display_name_plural": "scrolls of protection from undead", "effect": { "condition": null, "damage_dice": null, @@ -4474,8 +4480,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "shield +1", + "display_name_plural": "shields +1", "effect": null, "hoard_recipe": [], "id": "shield_plus_1", @@ -4507,8 +4513,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "shield +2", + "display_name_plural": "shields +2", "effect": null, "hoard_recipe": [], "id": "shield_plus_2", @@ -4540,8 +4546,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "shield +3", + "display_name_plural": "shields +3", "effect": null, "hoard_recipe": [], "id": "shield_plus_3", @@ -4573,8 +4579,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sling +1", + "display_name_plural": "slings +1", "effect": null, "hoard_recipe": [], "id": "sling_plus_1", @@ -4606,8 +4612,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "spear +1", + "display_name_plural": "spears +1", "effect": null, "hoard_recipe": [], "id": "spear_plus_1", @@ -4639,8 +4645,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "spear +2", + "display_name_plural": "spears +2", "effect": null, "hoard_recipe": [], "id": "spear_plus_2", @@ -4672,8 +4678,8 @@ "cursed": false, "curses": [], "damage_bonus": 3, - "display_name": "", - "display_name_plural": "", + "display_name": "spear +3", + "display_name_plural": "spears +3", "effect": null, "hoard_recipe": [], "id": "spear_plus_3", @@ -4705,8 +4711,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "spell scroll with 1 spell", + "display_name_plural": "spell scrolls with 1 spell", "effect": null, "hoard_recipe": [], "id": "spell_scroll_1", @@ -4746,8 +4752,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "spell scroll with 2 spells", + "display_name_plural": "spell scrolls with 2 spells", "effect": null, "hoard_recipe": [], "id": "spell_scroll_2", @@ -4787,8 +4793,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "spell scroll with 3 spells", + "display_name_plural": "spell scrolls with 3 spells", "effect": null, "hoard_recipe": [], "id": "spell_scroll_3", @@ -4828,8 +4834,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "spell scroll with 5 spells", + "display_name_plural": "spell scrolls with 5 spells", "effect": null, "hoard_recipe": [], "id": "spell_scroll_5", @@ -4869,8 +4875,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "spell scroll with 7 spells", + "display_name_plural": "spell scrolls with 7 spells", "effect": null, "hoard_recipe": [], "id": "spell_scroll_7", @@ -4910,8 +4916,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "staff of commanding", + "display_name_plural": "staves of commanding", "effect": null, "hoard_recipe": [], "id": "staff_of_commanding", @@ -4961,8 +4967,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "staff of healing", + "display_name_plural": "staves of healing", "effect": { "condition": null, "damage_dice": null, @@ -5019,8 +5025,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "staff of power", + "display_name_plural": "staves of power", "effect": { "condition": null, "damage_dice": "2d6", @@ -5080,8 +5086,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "staff of snakes", + "display_name_plural": "staves of snakes", "effect": null, "hoard_recipe": [], "id": "staff_of_snakes", @@ -5124,8 +5130,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "staff of striking", + "display_name_plural": "staves of striking", "effect": { "condition": null, "damage_dice": "2d6", @@ -5182,8 +5188,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "staff of withering", + "display_name_plural": "staves of withering", "effect": null, "hoard_recipe": [], "id": "staff_of_withering", @@ -5222,8 +5228,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "staff of wizardry", + "display_name_plural": "staves of wizardry", "effect": { "condition": null, "damage_dice": "2d6", @@ -5287,8 +5293,8 @@ "cursed": true, "curses": [], "damage_bonus": -1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword -1, cursed", + "display_name_plural": "swords -1, cursed", "effect": null, "hoard_recipe": [], "id": "sword_minus_1_cursed", @@ -5317,8 +5323,8 @@ "cursed": true, "curses": [], "damage_bonus": -2, - "display_name": "", - "display_name_plural": "", + "display_name": "sword -2, cursed", + "display_name_plural": "swords -2, cursed", "effect": null, "hoard_recipe": [], "id": "sword_minus_2_cursed", @@ -5347,8 +5353,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1", + "display_name_plural": "swords +1", "effect": null, "hoard_recipe": [], "id": "sword_plus_1", @@ -5381,8 +5387,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, energy drain", + "display_name_plural": "swords +1, energy drain", "effect": { "condition": null, "damage_dice": null, @@ -5439,8 +5445,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, flaming", + "display_name_plural": "swords +1, flaming", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_flaming", @@ -5483,8 +5489,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, light", + "display_name_plural": "swords +1, light", "effect": { "condition": null, "damage_dice": null, @@ -5536,8 +5542,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, locate objects", + "display_name_plural": "swords +1, locate objects", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_locate_objects", @@ -5573,8 +5579,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, +2 vs lycanthropes", + "display_name_plural": "swords +1, +2 vs lycanthropes", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_2_vs_lycanthropes", @@ -5621,8 +5627,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, +2 vs spell users", + "display_name_plural": "swords +1, +2 vs spell users", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_2_vs_spell_users", @@ -5672,8 +5678,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, +3 vs dragons", + "display_name_plural": "swords +1, +3 vs dragons", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_3_vs_dragons", @@ -5722,8 +5728,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, +3 vs enchanted creatures", + "display_name_plural": "swords +1, +3 vs enchanted creatures", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_3_vs_enchanted_creatures", @@ -5765,8 +5771,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, +3 vs regenerating creatures", + "display_name_plural": "swords +1, +3 vs regenerating creatures", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_3_vs_regenerating_creatures", @@ -5812,8 +5818,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, +3 vs undead", + "display_name_plural": "swords +1, +3 vs undead", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_plus_3_vs_undead", @@ -5855,8 +5861,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +1, wishes", + "display_name_plural": "swords +1, wishes", "effect": null, "hoard_recipe": [], "id": "sword_plus_1_wishes", @@ -5894,8 +5900,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +2", + "display_name_plural": "swords +2", "effect": null, "hoard_recipe": [], "id": "sword_plus_2", @@ -5928,8 +5934,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +2, charm person", + "display_name_plural": "swords +2, charm person", "effect": null, "hoard_recipe": [], "id": "sword_plus_2_charm_person", @@ -5965,8 +5971,8 @@ "cursed": false, "curses": [], "damage_bonus": 3, - "display_name": "", - "display_name_plural": "", + "display_name": "sword +3", + "display_name_plural": "swords +3", "effect": null, "hoard_recipe": [], "id": "sword_plus_3", @@ -5999,8 +6005,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map I", + "display_name_plural": "treasure maps I", "effect": null, "hoard_recipe": [ { @@ -6052,8 +6058,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map II", + "display_name_plural": "treasure maps II", "effect": null, "hoard_recipe": [ { @@ -6104,8 +6110,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map III", + "display_name_plural": "treasure maps III", "effect": null, "hoard_recipe": [ { @@ -6157,8 +6163,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map IV", + "display_name_plural": "treasure maps IV", "effect": null, "hoard_recipe": [ { @@ -6212,8 +6218,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map IX", + "display_name_plural": "treasure maps IX", "effect": null, "hoard_recipe": [ { @@ -6260,8 +6266,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map V", + "display_name_plural": "treasure maps V", "effect": null, "hoard_recipe": [ { @@ -6330,8 +6336,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map VI", + "display_name_plural": "treasure maps VI", "effect": null, "hoard_recipe": [ { @@ -6417,8 +6423,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map VII", + "display_name_plural": "treasure maps VII", "effect": null, "hoard_recipe": [ { @@ -6477,8 +6483,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map VIII", + "display_name_plural": "treasure maps VIII", "effect": null, "hoard_recipe": [ { @@ -6525,8 +6531,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map X", + "display_name_plural": "treasure maps X", "effect": null, "hoard_recipe": [ { @@ -6588,8 +6594,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map XI", + "display_name_plural": "treasure maps XI", "effect": null, "hoard_recipe": [ { @@ -6643,8 +6649,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "treasure map XII", + "display_name_plural": "treasure maps XII", "effect": null, "hoard_recipe": [ { @@ -6691,8 +6697,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of cold", + "display_name_plural": "wands of cold", "effect": { "condition": null, "damage_dice": "6d6", @@ -6747,8 +6753,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of enemy detection", + "display_name_plural": "wands of enemy detection", "effect": null, "hoard_recipe": [], "id": "wand_of_enemy_detection", @@ -6784,8 +6790,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of fear", + "display_name_plural": "wands of fear", "effect": { "condition": "afraid", "damage_dice": null, @@ -6842,8 +6848,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of fire balls", + "display_name_plural": "wands of fire balls", "effect": { "condition": null, "damage_dice": "6d6", @@ -6898,8 +6904,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of illusion", + "display_name_plural": "wands of illusion", "effect": null, "hoard_recipe": [], "id": "wand_of_illusion", @@ -6934,8 +6940,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of lightning bolts", + "display_name_plural": "wands of lightning bolts", "effect": { "condition": null, "damage_dice": "6d6", @@ -6992,8 +6998,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of magic detection", + "display_name_plural": "wands of magic detection", "effect": null, "hoard_recipe": [], "id": "wand_of_magic_detection", @@ -7029,8 +7035,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of metal detection", + "display_name_plural": "wands of metal detection", "effect": null, "hoard_recipe": [], "id": "wand_of_metal_detection", @@ -7067,8 +7073,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of negation", + "display_name_plural": "wands of negation", "effect": null, "hoard_recipe": [], "id": "wand_of_negation", @@ -7105,8 +7111,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of paralysation", + "display_name_plural": "wands of paralysation", "effect": { "condition": "paralysed", "damage_dice": null, @@ -7163,8 +7169,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of polymorph", + "display_name_plural": "wands of polymorph", "effect": null, "hoard_recipe": [], "id": "wand_of_polymorph", @@ -7199,8 +7205,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of secret door detection", + "display_name_plural": "wands of secret door detection", "effect": null, "hoard_recipe": [], "id": "wand_of_secret_door_detection", @@ -7234,8 +7240,8 @@ "cursed": false, "curses": [], "damage_bonus": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "wand of trap detection", + "display_name_plural": "wands of trap detection", "effect": null, "hoard_recipe": [], "id": "wand_of_trap_detection", @@ -7269,8 +7275,8 @@ "cursed": false, "curses": [], "damage_bonus": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "war hammer +1", + "display_name_plural": "war hammers +1", "effect": null, "hoard_recipe": [], "id": "war_hammer_plus_1", @@ -7302,8 +7308,8 @@ "cursed": false, "curses": [], "damage_bonus": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "war hammer +2", + "display_name_plural": "war hammers +2", "effect": null, "hoard_recipe": [], "id": "war_hammer_plus_2", @@ -7335,8 +7341,8 @@ "cursed": false, "curses": [], "damage_bonus": 3, - "display_name": "", - "display_name_plural": "", + "display_name": "war hammer +3, dwarven thrower", + "display_name_plural": "war hammers +3, dwarven thrower", "effect": null, "hoard_recipe": [], "id": "war_hammer_plus_3_dwarven_thrower", diff --git a/tests/goldens/phase1_party.json b/tests/goldens/phase1_party.json index c2edd0c7..675ef702 100644 --- a/tests/goldens/phase1_party.json +++ b/tests/goldens/phase1_party.json @@ -27,13 +27,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -59,8 +62,8 @@ "template": { "cost_gp": 5, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "mace", + "display_name_plural": "maces", "id": "mace", "item_type": "weapon", "material": "standard", @@ -84,12 +87,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -130,13 +136,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "iron spike", + "display_name_plural": "iron spikes", "id": "iron_spikes", "item_type": "gear", "lot_size": 12, "name": "Iron spikes (12)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "wedges_doors": true } @@ -155,13 +164,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -187,8 +199,8 @@ "template": { "cost_gp": 5, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "war hammer", + "display_name_plural": "war hammers", "id": "war_hammer", "item_type": "weapon", "material": "standard", @@ -212,12 +224,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -268,8 +283,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -292,12 +307,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -350,8 +368,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -374,12 +392,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -421,8 +442,8 @@ "quantity": 1, "template": { "cost_gp": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "sling stone", + "display_name_plural": "sling stones", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -439,13 +460,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -469,8 +493,8 @@ "template": { "cost_gp": 2, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "sling", + "display_name_plural": "slings", "id": "sling", "item_type": "weapon", "material": "standard", @@ -507,12 +531,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -573,13 +600,16 @@ ] }, "cost_gp": 2, - "display_name": "", - "display_name_plural": "", + "display_name": "flask of oil", + "display_name_plural": "flasks of oil", "id": "oil_flask", "item_type": "gear", "lot_size": 1, "name": "Oil (1 flask)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "fuels_lantern": true } @@ -598,13 +628,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -619,13 +652,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -638,8 +674,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -668,8 +704,8 @@ "template": { "cost_gp": 3, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "dagger", + "display_name_plural": "daggers", "id": "dagger", "item_type": "weapon", "material": "standard", @@ -739,13 +775,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "50’ coil of rope", + "display_name_plural": "50’ coils of rope", "id": "rope", "item_type": "gear", "lot_size": 1, "name": "Rope (50’)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": {} } }, @@ -762,13 +801,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -794,8 +836,8 @@ "template": { "cost_gp": 3, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "dagger", + "display_name_plural": "daggers", "id": "dagger", "item_type": "weapon", "material": "standard", @@ -832,12 +874,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } diff --git a/tests/goldens/phase5_milestone.json b/tests/goldens/phase5_milestone.json index 93144dc2..5988af28 100644 --- a/tests/goldens/phase5_milestone.json +++ b/tests/goldens/phase5_milestone.json @@ -3810,8 +3810,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -3827,8 +3827,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -3851,8 +3851,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of chainmail", + "display_name_plural": "suits of chainmail", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -3907,8 +3907,8 @@ "template": { "cost_gp": 5, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "mace", + "display_name_plural": "maces", "id": "mace", "item_type": "weapon", "material": "standard", @@ -3932,8 +3932,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of chainmail", + "display_name_plural": "suits of chainmail", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -3988,8 +3988,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -4012,12 +4012,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -4068,8 +4071,8 @@ "template": { "cost_gp": 3, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "dagger", + "display_name_plural": "daggers", "id": "dagger", "item_type": "weapon", "material": "standard", diff --git a/tests/goldens/phase5_npc_parties.json b/tests/goldens/phase5_npc_parties.json index c15f9d3c..300b2851 100644 --- a/tests/goldens/phase5_npc_parties.json +++ b/tests/goldens/phase5_npc_parties.json @@ -19,8 +19,8 @@ "quantity": 1, "template": { "cost_gp": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "sling stone", + "display_name_plural": "sling stones", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -37,13 +37,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -56,8 +59,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -81,13 +84,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -113,8 +119,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -130,8 +136,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -150,8 +156,8 @@ "template": { "cost_gp": 2, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "sling", + "display_name_plural": "slings", "id": "sling", "item_type": "weapon", "material": "standard", @@ -188,12 +194,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -236,8 +245,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -252,13 +261,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -271,8 +283,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -296,13 +308,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -328,8 +343,8 @@ "template": { "cost_gp": 7, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "battle axe", + "display_name_plural": "battle axes", "id": "battle_axe", "item_type": "weapon", "material": "standard", @@ -354,8 +369,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of chainmail", + "display_name_plural": "suits of chainmail", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -400,13 +415,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, - "display_name": "", - "display_name_plural": "", + "display_name": "set of thieves’ tools", + "display_name_plural": "sets of thieves’ tools", "id": "thieves_tools", "item_type": "gear", "lot_size": 1, "name": "Thieves’ tools", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "required_for": "open_locks" } @@ -419,13 +437,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -438,8 +459,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -463,13 +484,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -495,8 +519,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -519,12 +543,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -567,8 +594,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -583,13 +610,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -602,8 +632,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -627,13 +657,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -659,8 +692,8 @@ "template": { "cost_gp": 7, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "battle axe", + "display_name_plural": "battle axes", "id": "battle_axe", "item_type": "weapon", "material": "standard", @@ -685,8 +718,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of chainmail", + "display_name_plural": "suits of chainmail", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -729,8 +762,8 @@ "quantity": 20, "template": { "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "arrow", + "display_name_plural": "arrows", "id": "arrows", "item_type": "ammunition", "lot_size": 20, @@ -747,13 +780,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -766,8 +802,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -791,13 +827,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -823,8 +862,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -843,8 +882,8 @@ "template": { "cost_gp": 40, "damage": "1d6", - "display_name": "", - "display_name_plural": "", + "display_name": "long bow", + "display_name_plural": "long bows", "id": "long_bow", "item_type": "weapon", "material": "standard", @@ -881,8 +920,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 40, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of chainmail", + "display_name_plural": "suits of chainmail", "id": "chainmail", "item_type": "armour", "name": "Chainmail", @@ -973,13 +1012,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -992,8 +1034,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1017,13 +1059,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -1052,8 +1097,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -1114,8 +1159,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1138,8 +1183,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 60, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of plate mail", + "display_name_plural": "suits of plate mail", "id": "plate_mail", "item_type": "armour", "name": "Plate mail", @@ -1182,8 +1227,8 @@ "quantity": 1, "template": { "cost_gp": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "sling stone", + "display_name_plural": "sling stones", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -1200,13 +1245,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -1219,8 +1267,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1244,13 +1292,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -1267,8 +1318,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -1317,8 +1368,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1337,8 +1388,8 @@ "template": { "cost_gp": 2, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "sling", + "display_name_plural": "slings", "id": "sling", "item_type": "weapon", "material": "standard", @@ -1375,12 +1426,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -1419,8 +1473,8 @@ "quantity": 1, "template": { "cost_gp": 0, - "display_name": "", - "display_name_plural": "", + "display_name": "sling stone", + "display_name_plural": "sling stones", "id": "sling_stones", "item_type": "ammunition", "lot_size": 1, @@ -1437,13 +1491,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -1456,8 +1513,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1481,13 +1538,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -1525,8 +1585,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -1542,8 +1602,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1562,8 +1622,8 @@ "template": { "cost_gp": 2, "damage": "1d4", - "display_name": "", - "display_name_plural": "", + "display_name": "sling", + "display_name_plural": "slings", "id": "sling", "item_type": "weapon", "material": "standard", @@ -1628,12 +1688,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -1674,13 +1737,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, - "display_name": "", - "display_name_plural": "", + "display_name": "set of thieves’ tools", + "display_name_plural": "sets of thieves’ tools", "id": "thieves_tools", "item_type": "gear", "lot_size": 1, "name": "Thieves’ tools", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "required_for": "open_locks" } @@ -1693,13 +1759,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -1712,8 +1781,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1737,13 +1806,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -1769,8 +1841,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1793,12 +1865,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -1839,13 +1914,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -1858,8 +1936,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -1883,13 +1961,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -1939,8 +2020,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -1956,8 +2037,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -1992,8 +2073,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 60, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of plate mail", + "display_name_plural": "suits of plate mail", "id": "plate_mail", "item_type": "armour", "name": "Plate mail", @@ -2038,13 +2119,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 25, - "display_name": "", - "display_name_plural": "", + "display_name": "set of thieves’ tools", + "display_name_plural": "sets of thieves’ tools", "id": "thieves_tools", "item_type": "gear", "lot_size": 1, "name": "Thieves’ tools", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "required_for": "open_locks" } @@ -2057,13 +2141,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -2076,8 +2163,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -2101,13 +2188,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -2133,8 +2223,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -2169,12 +2259,15 @@ "ac_bonus": null, "category": "light", "cost_gp": 20, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour", "id": "leather", "item_type": "armour", "name": "Leather", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "weight_coins": 200 } } @@ -2215,13 +2308,16 @@ "capacity_coins": null, "combat": null, "cost_gp": 5, - "display_name": "", - "display_name_plural": "", + "display_name": "standard ration", + "display_name_plural": "standard rations", "id": "rations_standard", "item_type": "gear", "lot_size": 7, "name": "Rations (standard, 7 days)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "ration": true } @@ -2234,8 +2330,8 @@ "capacity_coins": null, "combat": null, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "waterskin", + "display_name_plural": "waterskins", "id": "waterskin", "item_type": "gear", "lot_size": 1, @@ -2259,13 +2355,16 @@ ] }, "cost_gp": 1, - "display_name": "", - "display_name_plural": "", + "display_name": "torch", + "display_name_plural": "torches", "id": "torch", "item_type": "gear", "lot_size": 6, "name": "Torches (6)", - "overrides_applied": [], + "overrides_applied": [ + "display_name", + "display_name_plural" + ], "params": { "brightness": "flame", "burn_turns": 6, @@ -2291,8 +2390,8 @@ "ac_bonus": 1, "category": null, "cost_gp": 10, - "display_name": "", - "display_name_plural": "", + "display_name": "shield", + "display_name_plural": "shields", "id": "shield", "item_type": "armour", "name": "Shield", @@ -2308,8 +2407,8 @@ "template": { "cost_gp": 10, "damage": "1d8", - "display_name": "", - "display_name_plural": "", + "display_name": "sword", + "display_name_plural": "swords", "id": "sword", "item_type": "weapon", "material": "standard", @@ -2332,8 +2431,8 @@ "ac_bonus": null, "category": "heavy", "cost_gp": 60, - "display_name": "", - "display_name_plural": "", + "display_name": "suit of plate mail", + "display_name_plural": "suits of plate mail", "id": "plate_mail", "item_type": "armour", "name": "Plate mail", diff --git a/tools/srd_compile/equipment.py b/tools/srd_compile/equipment.py index 5bde5f66..ba123301 100644 --- a/tools/srd_compile/equipment.py +++ b/tools/srd_compile/equipment.py @@ -16,11 +16,20 @@ size 1; `Stakes (3) and mallet` is one kit item; the ammunition table has no weight column and compiles to weight 0 — per the SRD, missile weapon weights already include the ammunition and its container. + +Every entry gets the names a sentence uses for one unit and for two or more. The display name +is the printed name in lowercase with a trailing parenthesis dropped, and body armour is named +as a suit. Ammunition names one unit, so its plural ending goes too: `Arrows (quiver of 20)` is +"arrow". The plural comes from `plural`. Gear whose printed name is a lot or a substance, like +`Torches (6)` and `Holy water (vial)`, and the armour the SRD prints as `Leather`, get the name +of the unit the session counts from `overrides/equipment.json`. """ import re from pathlib import Path +from osrlib.core.monsters import _regular_plural + from .pipetable import parse_range, section_prose, slugify, tables_after_heading SOURCE_PAGES = ("Weapons_and_Armour.md", "Adventuring_Gear.md", "Time%2C_Weight%2C_Movement.md") @@ -117,6 +126,40 @@ _MISSILE_PATTERN = re.compile(r"Missile \(([^)]*)\)") +TRAILING_PARENTHESIS = re.compile(r"\s*\([^)]*\)$") + +# The plural of every head noun that doesn't take the regular English ending. +_IRREGULAR_PLURALS = {"staff": "staves"} + +# Where the words that name the item end and the words that qualify it begin: "of", "with", or +# "vs", a comma, a bonus like "+1", or a closing Roman numeral. +_HEAD_END = re.compile(r" (?:of|with|vs) |, | [+-]\d| (?=[IVX]+$)") + + +def plural(singular: str) -> str: + """Return what to call two or more of an item, from its display name. + + The ending goes on the last word of the words that name the item, before any `of`, `with`, + `vs`, comma, bonus, or Roman numeral, so `"vial of holy water"` becomes `"vials of holy + water"` and `"sword +1"` becomes `"swords +1"`. The word takes the regular English ending + unless `_IRREGULAR_PLURALS` lists it. + + Args: + singular: The display name, like `"potion of healing"`. + + Returns: + The plural, like `"potions of healing"`. + """ + end = _HEAD_END.search(singular) + head, tail = (singular[: end.start()], singular[end.start() :]) if end else (singular, "") + *words, noun = head.split(" ") + return " ".join([*words, _IRREGULAR_PLURALS.get(noun) or _regular_plural(noun)]) + tail + + +def display_names(singular: str) -> dict[str, str]: + """Return an entry's `display_name` and `display_name_plural` fields for a display name.""" + return {"display_name": singular, "display_name_plural": plural(singular)} + def _weapon_id(name: str) -> str: return name.lower().replace("-", "_").replace(" ", "_") @@ -181,6 +224,7 @@ def compile_equipment(srd_dir: Path) -> dict[str, object]: weapon: dict[str, object] = { "id": _weapon_id(name), "name": name, + **display_names(name.lower()), "cost_gp": _parse_cost(cost_cell), "weight_coins": int(weight_cell), "damage": damage, @@ -203,6 +247,7 @@ def compile_equipment(srd_dir: Path) -> dict[str, object]: { "id": ammunition_id, "name": name, + **display_names(TRAILING_PARENTHESIS.sub("", name).lower().removesuffix("s")), "cost_gp": _parse_cost(cost_cell), "lot_size": lot_size, "weight_coins": 0, @@ -223,7 +268,9 @@ def compile_equipment(srd_dir: Path) -> dict[str, object]: bonus_match = re.fullmatch(r"\+(\d+) bonus", ac_cell) if bonus_match: entry["ac_bonus"] = int(bonus_match[1]) + entry.update(display_names(name.lower())) else: + entry.update(display_names(f"suit of {name.lower()}")) ac_match = re.fullmatch(r"(\d+) \[(\d+)\]", ac_cell) if ac_match is None: raise ValueError(f"unparseable AC cell {ac_cell!r}") @@ -250,6 +297,7 @@ def compile_equipment(srd_dir: Path) -> dict[str, object]: entry = { "id": gear_id, "name": name, + **display_names(TRAILING_PARENTHESIS.sub("", name).lower()), "cost_gp": _parse_cost(cost_cell), "lot_size": _GEAR_LOT_SIZES.get(gear_id, 1), } diff --git a/tools/srd_compile/magic_items.py b/tools/srd_compile/magic_items.py index da1d1e76..626dd257 100644 --- a/tools/srd_compile/magic_items.py +++ b/tools/srd_compile/magic_items.py @@ -41,12 +41,17 @@ exactly the Phase 5 wired census; everything else ships `manual`-tagged prose. `Helm_of_Telepathy.md` is truncated mid-sentence in the SRD dump — its description completes via `overrides/magic_items.json` with provenance. + +Every item gets the names a sentence uses for one and for two or more, from `display_names`. +The two items that are a set rather than one thing, the drums of panic and the elven cloak and +boots, get theirs from `overrides/magic_items.json`. """ import re from pathlib import Path from urllib.parse import quote +from .equipment import TRAILING_PARENTHESIS, plural from .pipetable import slugify, strip_emphasis, strip_links, tables_after_heading from .treasure import parse_treasure_segment @@ -600,6 +605,52 @@ def _apply_mechanics(template: dict[str, object]) -> None: template[key] = value +_SPELL_COUNT = re.compile(r"(?P.+) \((?P\d+ spells?)\)") +_ROMAN_NUMERAL = re.compile(r"[IVX]+") +_PAIRS = ("boots", "gauntlets") + + +def display_names(printed_name: str, category: str, base_item_id: str | None) -> dict[str, str]: + """Return an item's `display_name` and `display_name_plural` fields, from its printed name. + + The SRD prints names for a table, so the compiler rewrites them for a sentence: + + - A spell scroll's parenthesis says how many spells it holds, so it becomes a `with` phrase: + `Spell Scroll (1 spell)` is "spell scroll with 1 spell". Any other trailing parenthesis goes, + like the generated count in `Arrows +1 (3d10 arrows)`. + - A label after a colon moves to the front, `Elemental Summoning Device: Air` becoming "air + elemental summoning device", except a treasure map's Roman numeral, which stays at the end. + - Every word is lowercase, except a word printed all in capitals, which is an abbreviation or + a Roman numeral: "potion of ESP", "treasure map II". + - Enchanted ammunition names one unit, so `Arrows +1` is "arrow +1". + - Enchanted body armour is named as a suit, "suit of armour +1", and boots and gauntlets as a + pair, "pair of boots of speed". + + The plural comes from [`plural`][tools.srd_compile.equipment.plural]. + + Args: + printed_name: The item's `name`, like `"Potion of Healing"`. + category: The item's category. + base_item_id: The mundane item the enchantment overlays, or `None`. + + Returns: + The two fields. + """ + spells = _SPELL_COUNT.fullmatch(printed_name) + name = f"{spells['name']} with {spells['count']}" if spells else TRAILING_PARENTHESIS.sub("", printed_name) + head, colon, label = name.partition(": ") + if colon: + name = f"{head} {label}" if _ROMAN_NUMERAL.fullmatch(label) else f"{label} {head}" + singular = " ".join(word if word.isupper() else word.lower() for word in name.split(" ")) + if base_item_id in _AMMUNITION_BASES: + singular = re.sub(r"s(?= [+-]\d)", "", singular, count=1) + if category == "armour" and base_item_id != "shield": + singular = f"suit of {singular}" + elif singular.startswith(_PAIRS): + singular = f"pair of {singular}" + return {"display_name": singular, "display_name_plural": plural(singular)} + + def _template( item_id: str, name: str, @@ -609,9 +660,11 @@ def _template( weight_coins: int = 0, **fields: object, ) -> dict[str, object]: + base_item_id = fields.get("base_item_id") template: dict[str, object] = { "id": item_id, "name": name, + **display_names(name, category, base_item_id if isinstance(base_item_id, str) else None), "category": category, "manual": manual or [], "weight_coins": weight_coins, diff --git a/tools/srd_compile/overrides/equipment.json b/tools/srd_compile/overrides/equipment.json new file mode 100644 index 00000000..d8874be0 --- /dev/null +++ b/tools/srd_compile/overrides/equipment.json @@ -0,0 +1,146 @@ +[ + { + "id": "garlic", + "reason": "The price list prints 'Garlic' with no unit, and one unit is a bulb.", + "set": { + "display_name": "bulb of garlic", + "display_name_plural": "bulbs of garlic" + } + }, + { + "id": "hammer", + "reason": "The price list prints 'Hammer (small)', a size the display name puts in front.", + "set": { + "display_name": "small hammer", + "display_name_plural": "small hammers" + } + }, + { + "id": "holy_water", + "reason": "Holy water is a substance, and the description says it is 'stored in a special vial', so a unit is a vial.", + "set": { + "display_name": "vial of holy water", + "display_name_plural": "vials of holy water" + } + }, + { + "id": "iron_spikes", + "reason": "'Iron spikes (12)' is a lot of 12, and the session counts single spikes.", + "set": { + "display_name": "iron spike", + "display_name_plural": "iron spikes" + } + }, + { + "id": "leather", + "reason": "The armour table prints the bare 'Leather', and the prose under it says 'Leather armour counts as light armour', so a suit is of leather armour.", + "set": { + "display_name": "suit of leather armour", + "display_name_plural": "suits of leather armour" + } + }, + { + "id": "mirror", + "reason": "The price list prints 'Mirror (hand-sized, steel)', and the display name keeps the size.", + "set": { + "display_name": "hand mirror", + "display_name_plural": "hand mirrors" + } + }, + { + "id": "oil_flask", + "reason": "'Oil (1 flask)' is a substance, and the description says 'A flask of oil fuels a lantern', so a unit is a flask.", + "set": { + "display_name": "flask of oil", + "display_name_plural": "flasks of oil" + } + }, + { + "id": "pole", + "reason": "The price list prints 'Pole (10’ long, wooden)', and the description heading is 'Pole, 10’'.", + "set": { + "display_name": "10’ pole", + "display_name_plural": "10’ poles" + } + }, + { + "id": "rations_iron", + "reason": "'Rations (iron, 7 days)' is a lot of 7, and the session counts one day's iron ration.", + "set": { + "display_name": "iron ration", + "display_name_plural": "iron rations" + } + }, + { + "id": "rations_standard", + "reason": "'Rations (standard, 7 days)' is a lot of 7, and the session counts one day's standard ration.", + "set": { + "display_name": "standard ration", + "display_name_plural": "standard rations" + } + }, + { + "id": "rope", + "reason": "Rope is a substance, and 'Rope (50’)' sells one 50’ length, which is a coil.", + "set": { + "display_name": "50’ coil of rope", + "display_name_plural": "50’ coils of rope" + } + }, + { + "id": "sack_large", + "reason": "The price list prints 'Sack (large)', a size the display name puts in front.", + "set": { + "display_name": "large sack", + "display_name_plural": "large sacks" + } + }, + { + "id": "sack_small", + "reason": "The price list prints 'Sack (small)', a size the display name puts in front.", + "set": { + "display_name": "small sack", + "display_name_plural": "small sacks" + } + }, + { + "id": "stakes_and_mallet", + "reason": "'Stakes (3) and mallet' is one kit, which the description calls 'A wooden mallet and three 18” long stakes'.", + "set": { + "display_name": "set of stakes and mallet", + "display_name_plural": "sets of stakes and mallet" + } + }, + { + "id": "thieves_tools", + "reason": "The description says 'A set of lock picking tools in a small case'.", + "set": { + "display_name": "set of thieves’ tools", + "display_name_plural": "sets of thieves’ tools" + } + }, + { + "id": "torch", + "reason": "'Torches (6)' is a lot of 6, and the session counts single torches.", + "set": { + "display_name": "torch", + "display_name_plural": "torches" + } + }, + { + "id": "wine", + "reason": "'Wine (2 pints)' is a substance sold in a lot of 2, and the session counts pints.", + "set": { + "display_name": "pint of wine", + "display_name_plural": "pints of wine" + } + }, + { + "id": "wolfsbane", + "reason": "'Wolfsbane (1 bunch)' is a herb, and a unit is a bunch.", + "set": { + "display_name": "bunch of wolfsbane", + "display_name_plural": "bunches of wolfsbane" + } + } +] diff --git a/tools/srd_compile/overrides/magic_items.json b/tools/srd_compile/overrides/magic_items.json index 65c83963..09f00247 100644 --- a/tools/srd_compile/overrides/magic_items.json +++ b/tools/srd_compile/overrides/magic_items.json @@ -5,5 +5,21 @@ "set": { "manual.4": "Bidirectional communication: The wearer may initiate bidirectional, telepathic communication, though the creature is not compelled to respond." } + }, + { + "id": "drums_of_panic", + "reason": "The page describes 'Large war drums', one item of several drums, so a sentence names it as a set and the plural can differ from the singular.", + "set": { + "display_name": "set of drums of panic", + "display_name_plural": "sets of drums of panic" + } + }, + { + "id": "elven_cloak_and_boots", + "reason": "The page describes 'A set of enchanted boots and a matching cloak', one item of two pieces, so a sentence names it as a set.", + "set": { + "display_name": "set of elven cloak and boots", + "display_name_plural": "sets of elven cloak and boots" + } } ] From 908eb175a6ba890000d0378c6b4f0cd27391041d Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:19:39 -0800 Subject: [PATCH 03/14] Document the item display names and the masks they follow 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 --- CHANGELOG.md | 12 ++++++++++++ docs/adaptations.md | 14 +++++++++++++- docs/front-ends/fastapi-pattern.md | 2 +- docs/guides/authoring-custom-content.md | 18 ++++++++++++++++-- docs/guides/views-and-visibility.md | 6 ++++-- docs/spec.md | 2 +- src/osrlib/crawl/views.py | 2 +- tools/srd_compile/overrides/equipment.json | 8 ++++---- tools/srd_compile/overrides/magic_items.json | 4 ++-- 9 files changed, 54 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715094eb..4b344c6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +### Added + +- Every equipment and magic item template has a `display_name` and a `display_name_plural`, what to call one unit and two or more in a sentence, such as `"vial of holy water"` and `"vials of holy water"` for the gear printed as `Holy water (vial)` (#316). They're on [`WeaponTemplate`][osrlib.core.items.WeaponTemplate], [`ArmourTemplate`][osrlib.core.items.ArmourTemplate], [`GearTemplate`][osrlib.core.items.GearTemplate], [`AmmunitionTemplate`][osrlib.core.items.AmmunitionTemplate], and [`MagicItemTemplate`][osrlib.core.items.MagicItemTemplate]. Each name refers to the unit that an instance's `quantity` counts, not to a lot from the price list, so `Torches (6)` is `"torch"` and `Arrows +1 (3d10 arrows)` is `"arrow +1"`. The SRD compiler fills them for the built-in catalogs. A template you write that leaves them out gets its `name` and the regular English plural of the display name, so an adventure document from 2.7.0 still loads. +- [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] name every item whose id the view shows, keyed by that id: a mundane stack's catalog id, and a magic item's or a valuable's instance id, in a member's inventory or a known pile (#316). A stack a member carries is named from the template it embeds, and a stack in a pile from [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], so an item the adventure bundles is named. An unidentified magic item is named by its masked name without the article, like `"potion"` or `"shield with a faint aura"`, so a cursed item has the names of the item it passes for, and the view never includes its template id. An identified item is named by its template's display names, under both its instance id and its template id. A gem is `"gem"` and a piece of jewellery `"piece of jewellery"`. Before, a client with only the view and the events couldn't word "The party finds 2 vials of holy water". +- [`PileView.contents`][osrlib.crawl.views.PileView.contents] gives each thing in a pile as a [`PileItemView`][osrlib.crawl.views.PileItemView], with the id that the events use for it and its count, in the order of `items` (#316). A client reads `"holy_water"` and 2 there where `items` has `"holy_water×2"`. `items` doesn't change. +- [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] has two new fields, `display_name` and `display_name_plural`, the identified item's display names, like `"potion of healing"` (#316). A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, but the event does. An event recorded before this release has empty names. Every field this release adds has a default, so a 2.7.0 save, view, or event still parses, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. + +### Fixed + +- [`EquipmentDestroyedEvent`][osrlib.core.events.EquipmentDestroyedEvent], which the players see, names an unidentified magic item by its masked name, like `"a sword with a faint aura"`, the `display` the inventory showed for it (#316). Before, it named the item by its true name, like `"Sword +1"`, so a breath weapon that killed a member told the players what the member's unidentified items were. +- The masked `display` of an unidentified enchanted arm in [`MemberView.inventory`][osrlib.crawl.views.MemberView.inventory] and [`PileView.items`][osrlib.crawl.views.PileView.items] is built from one unit of the mundane item underneath it, its display name with "a" or "an" (#316). Enchanted arrows read `"an arrow with a faint aura"`, where they read `"a arrows (quiver of 20) with a faint aura"`, enchanted crossbow bolts read `"a crossbow bolt with a faint aura"`, where they read `"a crossbow bolts (case of 30) with a faint aura"`, enchanted chainmail reads `"a suit of chainmail with a faint aura"`, where it read `"a chainmail with a faint aura"`, and enchanted armour with no mundane armour recorded reads `"a suit of armour with a faint aura"`, where it read `"a arm with a faint aura"`. Enchanted leather and plate mail read `"a suit of leather armour with a faint aura"` and `"a suit of plate mail with a faint aura"`, where they read `"a leather with a faint aura"` and `"a plate mail with a faint aura"`. The shield, sword, dagger, staff, and other weapon strings don't change. A front end that matches on the changed strings needs updating. + ## [2.7.0] - 2026-11-25 ### Added diff --git a/docs/adaptations.md b/docs/adaptations.md index f104be91..b2830af2 100644 --- a/docs/adaptations.md +++ b/docs/adaptations.md @@ -153,6 +153,18 @@ Ammunition compiles with a weight of 0. The ammunition table has no weight colum Sling stones cost 0 and are bought one at a time. The table entry for their cost reads `Free`, so osrlib sets the cost to 0 and the purchase lot to 1. Locked by `test_srd_data.py::TestEquipmentData`. +### Item display names name the unit the session counts + +The SRD prints item names for a price list or a treasure table, like `Torches (6)`, `Holy water (vial)`, and `Arrows +1 (3d10 arrows)`, so they name a lot and have no plural. Every compiled equipment and magic item template also has a `display_name` for one unit in a sentence and a `display_name_plural` for two or more. The compiler writes them by these rules: + +- The display name is the printed name with a trailing parenthesis dropped, in lowercase. A word printed all in capitals keeps its capitals, because it's an abbreviation or a Roman numeral: "potion of ESP", "treasure map II". +- It names one of the units that the item's `quantity` counts, not a lot. The compiler drops the plural ending from ammunition, so `Arrows (quiver of 20)` is "arrow" and `Arrows +1` is "arrow +1". Gear sold in a lot or as a substance is named by the unit or the container the SRD's descriptions give, so `Torches (6)` is "torch", `Holy water (vial)` is "vial of holy water", and `Oil (1 flask)` is "flask of oil". Those names come from `overrides/equipment.json`, with a reason for each. +- Body armour is a suit, "suit of chainmail" and "suit of armour +1", and the SRD's `Leather` is "suit of leather armour". Boots and gauntlets are a pair, "pair of boots of speed". The drums of panic and the elven cloak and boots are each a set. +- A spell scroll keeps its spell count, "spell scroll with 3 spells". The compiler moves a label after a colon to the front, so `Elemental Summoning Device: Air` is "air elemental summoning device", except a treasure map's numeral, which stays at the end. +- The plural ending goes on the word that names the item, before any `of`, `with`, `vs`, comma, bonus, or numeral, so the plurals read "vials of holy water", "swords +1, +3 vs undead", and "treasure maps II". The ending is the regular English one, except that "staff" becomes "staves". + +A template you write without the fields gets its `name` and the regular plural of the display name. Locked by `test_item_display_names.py`. + ### INT-granted languages come from the Other Languages table and may not duplicate natives A character with high INT picks extra languages from the twenty Other Languages, and can't pick a language their class already speaks. So a dwarf can't spend an INT language on Dwarvish. @@ -1650,7 +1662,7 @@ Locked by `test_srd_data.py` and the `test_magic_items.py` census. ### Magic items enter play unidentified, identify on first meaningful use, and curses stick -A magic item shows a generic name until it's identified: an enchanted weapon or armour is "a {base} with a faint aura", and a miscellaneous item is "a curious device". An item is identified by any of these: +A magic item shows a generic name until it's identified. An enchanted weapon, piece of ammunition, suit of armour, or shield is named after one unit of the mundane item underneath it, "a {base} with a faint aura", like "an arrow with a faint aura" or "a suit of chainmail with a faint aura", and a suit of enchanted armour whose mundane armour isn't recorded is "a suit of armour with a faint aura". A miscellaneous item is "a curious device". The player view's `item_names` and `EquipmentDestroyedEvent` name an unidentified item the same way, so a cursed item reads as the item it passes for. An item is identified by any of these: - Its first meaningful use. - The referee's `IdentifyItem`. diff --git a/docs/front-ends/fastapi-pattern.md b/docs/front-ends/fastapi-pattern.md index e7a85c5d..474b8bf9 100644 --- a/docs/front-ends/fastapi-pattern.md +++ b/docs/front-ends/fastapi-pattern.md @@ -176,7 +176,7 @@ except SaveVersionError: --8<-- "examples/fastapi_crawler/app.py:player-view" ``` -[`PlayerView`][osrlib.crawl.views.PlayerView] allowlists only fields safe for an untrusted client: explored and lit dungeon cells, entered areas, known features and transitions, public character sheets, masked descriptions for unidentified magic items, encounter groups without monster hit points, `journal` entries, and active `quests` with their revealed objectives. Pass each known [`MapFeatureView.id`][osrlib.crawl.views.MapFeatureView.id] back in a treasure command's `feature_id`. Unexplored geometry, raw ids in the feature list, cache contents, undiscovered secret doors and traps, transition destinations, monster stats, `flags`, narrator `guidance`, the player-handle key, and RNG state are excluded from the model (see [Views and visibility](../guides/views-and-visibility.md)). The established `emptied_caches` diagnostic may contain a fully qualified raw id only after use. +[`PlayerView`][osrlib.crawl.views.PlayerView] allowlists only fields safe for an untrusted client: explored and lit dungeon cells, entered areas, known features and transitions, public character sheets, masked descriptions for unidentified magic items, display names for every item the view shows (`item_names` and `item_names_plural`), the id and count of each thing in a known pile (`PileView.contents`), encounter groups without monster hit points, `journal` entries, and active `quests` with their revealed objectives. Pass each known [`MapFeatureView.id`][osrlib.crawl.views.MapFeatureView.id] back in a treasure command's `feature_id`. Unexplored geometry, raw ids in the feature list, cache contents, undiscovered secret doors and traps, transition destinations, monster stats, `flags`, narrator `guidance`, the player-handle key, and RNG state are excluded from the model (see [Views and visibility](../guides/views-and-visibility.md)). The established `emptied_caches` diagnostic may contain a fully qualified raw id only after use. Authored narrative also reaches web clients through `POST /sessions/{session_id}/commands` responses in two places: diff --git a/docs/guides/authoring-custom-content.md b/docs/guides/authoring-custom-content.md index 40af96d8..294889b6 100644 --- a/docs/guides/authoring-custom-content.md +++ b/docs/guides/authoring-custom-content.md @@ -657,6 +657,8 @@ Unlike spells, monsters, and items, custom classes are stored on each character Add custom [`WeaponTemplate`][osrlib.core.items.WeaponTemplate], [`ArmourTemplate`][osrlib.core.items.ArmourTemplate], [`GearTemplate`][osrlib.core.items.GearTemplate], and [`AmmunitionTemplate`][osrlib.core.items.AmmunitionTemplate] instances (discriminated by `item_type`) to `Adventure.items`. [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment] unions `load_equipment()` with `Adventure.items`, resolving bundled IDs in treasure caches (`FeatureSpec.item_ids`), [`GrantItem`][osrlib.crawl.commands.GrantItem], and dropped item piles. Once acquired, [`ItemInstance`][osrlib.core.items.ItemInstance] embeds its template for equipping, encumbrance, combat, item transfers, saves, and replay. +You can also set what the players call a bundled item in a sentence. Set [`display_name`][osrlib.core.items.GearTemplate.display_name] to what to call one, in lowercase with no article, like `"idol of the drowned saint"`, and [`display_name_plural`][osrlib.core.items.GearTemplate.display_name_plural] to what to call two or more. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] give them to the players' client. A template that leaves `display_name` out gets its `name`, and one that leaves `display_name_plural` out gets the display name with the regular English ending on its last word, so set the plural yourself when that ending is wrong, as for "idols of the drowned saint". + [`validate_adventure`][osrlib.crawl.adventure.validate_adventure] requires every bundled item ID to be unique across `Adventure.items`, the built-in equipment catalog ([the equipment id index][equipment-index]), and the built-in magic-item catalog (treasure encumbrance row IDs such as `coin`, `gem`, and `jewellery` do not count as item IDs): ```python @@ -672,8 +674,17 @@ from osrlib.crawl.party import Party from osrlib.crawl.session import GameSession from osrlib.data import load_equipment, load_monsters -# The quest object: a gear item with no shop price, carried like any other kit. -TEMPLE_IDOL = GearTemplate.model_validate({"id": "temple_idol", "name": "Idol of the drowned saint", "cost_gp": 0}) +# The quest object: a gear item with no shop price, carried like any other kit. Its +# display names are what the players' client shows in a sentence. +TEMPLE_IDOL = GearTemplate.model_validate( + { + "id": "temple_idol", + "name": "Idol of the drowned saint", + "cost_gp": 0, + "display_name": "idol of the drowned saint", + "display_name_plural": "idols of the drowned saint", + } +) # The saint's own arms and armour: each kind is the model its built-in list is made # of, so a weapon carries damage and qualities, body armour both AC formats and its @@ -703,6 +714,9 @@ BLESSED_STONES = AmmunitionTemplate.model_validate( {"id": "blessed_stones", "name": "Blessed sling stones", "cost_gp": 0, "lot_size": 20} ) +# A template written without display names gets its name and the regular plural. +assert (DROWNED_BLADE.display_name, DROWNED_BLADE.display_name_plural) == ("Drowned blade", "Drowned blades") + # Bundle them: the adventure document carries the templates, and a cache places # them by id like any built-in item. BUNDLED_IDS = ("temple_idol", "drowned_blade", "saints_scale", "blessed_stones") diff --git a/docs/guides/views-and-visibility.md b/docs/guides/views-and-visibility.md index ab9f0f65..a5a42eef 100644 --- a/docs/guides/views-and-visibility.md +++ b/docs/guides/views-and-visibility.md @@ -34,13 +34,15 @@ Each party member appears in `PlayerView.party` as a [`MemberView`][osrlib.crawl A member's spell book and memorized spells name each spell by id, and so does the `kind` of a spell's effect in `PlayerView.effects`. Show the names in [`PlayerView.spell_names`][osrlib.crawl.views.PlayerView.spell_names], keyed by those ids, and the names of reversed forms, like *darkness* for *light*, in [`PlayerView.reversed_spell_names`][osrlib.crawl.views.PlayerView.reversed_spell_names]. The view reads both from the session's catalog, so a spell the adventure bundles has its name there too. Neither includes a spell that is absent from the rest of the view, like one on a scroll. +Items work the same way. An inventory identifies a mundane stack by its template's catalog id, like `"holy_water"`, and a magic item or a gem or piece of jewellery by its instance id, like `"magic-item-0003"`, and the item events use the same ids. Show the names in [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names], a noun phrase for one with no article, like `"vial of holy water"`, and in [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] for a count, so you can word "The party finds 2 vials of holy water". Both have a key for each item id that the inventories and the known piles show, and only for those ids. A stack a member carries is named from the template it embeds, and a stack in a pile from the session's catalog, so an item the adventure bundles has its name there too. A valuable is named by its kind, `"gem"` or `"piece of jewellery"`, whereas the inventory's `valuables` contain the piece's name and value. A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, and the [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] contains its names instead. + Derived combat and exploration stats include bonuses from worn equipment (such as armour, a shield, or a ring of protection), even before the party identifies a magic item: - **Armour class**: `armour_class` and `armour_class_ascending` reflect worn magic armour or shields immediately, because a magic item works when it's worn, while `inventory` still displays a masked description such as `"a shield with a faint aura"`. A cursed shield or suit of armour is the exception. The OSE SRD says every test shows it as enchanted with a +1 bonus until it's used in deadly combat, so until the session reveals the curse, the player view counts it as the +1 item it tests as. An unarmoured fighter with an unidentified cursed shield -2 reads AC 7, as with a shield +1, while the monsters roll against the real AC 10. The real number appears when the curse is revealed, the first time the member is attacked in a battle or when a referee sends `IdentifyItem`. [`Character.armour_class`][osrlib.core.character.Character.armour_class] and the referee view always have the real number. - **Strength overrides**: Items that set Strength (such as gauntlets of ogre power setting STR 18, or a cursed ring of weakness setting STR 3) update [`effective_strength`][osrlib.crawl.views.MemberView.effective_strength], `melee_modifier`, and `open_doors_chance`, while `scores["str"]` preserves the rolled score. Display both `scores["str"]` and `effective_strength` if you want players to see the item's effect. - **Timed effects**: Temporary spell and potion modifiers appear in [`PlayerView.effects`][osrlib.crawl.views.PlayerView.effects] rather than in `MemberView` stat totals. Each entry includes its remaining duration, except for potions, whose duration a B/X referee tracks secretly, so `PlayerView` reports it as unknown. -In `MemberView.inventory`, unidentified magic items use a category description from [`MagicItemCategory`][osrlib.core.items.MagicItemCategory] instead of their true name, bonus, curse state, or template ID. When an unidentified item's display string names a weapon, such as an enchanted blade (`"a sword with a faint aura"`) or a magic staff (`"a staff"`), its inventory dict also includes the base weapon's `qualities` and (when applicable) `missile_ranges` so your UI can distinguish melee from missile attacks without revealing the enchantment. Non-weapon categories, such as `"a wand"`, omit both keys. +In `MemberView.inventory`, unidentified magic items use a category description from [`MagicItemCategory`][osrlib.core.items.MagicItemCategory] instead of their true name, bonus, curse state, or template ID. An enchanted weapon, piece of ammunition, suit of armour, or shield is named after one unit of the mundane item underneath it, so enchanted arrows display as `"an arrow with a faint aura"`, enchanted chainmail as `"a suit of chainmail with a faint aura"`, and enchanted armour with no recorded mundane armour displays as `"a suit of armour with a faint aura"`. `PlayerView.item_names` names an unidentified item by the same description without the article, like `"arrow with a faint aura"`, so a cursed item and the item it passes for read the same there too. When an unidentified item's display string names a weapon, such as an enchanted blade (`"a sword with a faint aura"`) or a magic staff (`"a staff"`), its inventory dict also includes the base weapon's `qualities` and (when applicable) `missile_ranges` so your UI can distinguish melee from missile attacks without revealing the enchantment. Non-weapon categories, such as `"a wand"`, omit both keys. ## Render maps, encounters, and battle positions @@ -48,7 +50,7 @@ In `MemberView.inventory`, unidentified magic items use a category description f Each level also reports the authored areas the party entered, with only walked area cells. When areas overlap, the first area in the level's list owns the shared cell and only that owner can enter through it. A known custom feature or treasure cache appears as a [`MapFeatureView`][osrlib.crawl.views.MapFeatureView] on its visible cell. An area-bound feature appears after the party enters that area, and a construction trick appears only after search marks it in `found_tricks`. An explicit feature on a shared cell belongs to the owning area only. Use the feature's opaque `id` in `feature_id`; the feature list never exposes the authored or generated raw id. The fields list the safe kind, description, location, area id after entry, and trap state (`"found"`, `"sprung"`, or `"removed"`). They never include cache contents, trap or trigger mechanics, destinations, gates, or an unannounced secret. -Generated area caches appear after their cells become known. A generated lair cache stays out of the view and refuses feature commands until the party resolves the area's keyed encounter. [`TransitionView`][osrlib.crawl.views.TransitionView] exposes the kind and safe position of each transition on a known cell, but not its destination or gate. `ExploredLevelView.entrance` appears only when the party knows the entrance cell, and `PlayerView.can_travel_to_town` is true only when the party can issue [`TravelToTown`][osrlib.crawl.commands.TravelToTown] from there. Known dropped piles stay in `PlayerView.piles`. +Generated area caches appear after their cells become known. A generated lair cache stays out of the view and refuses feature commands until the party resolves the area's keyed encounter. [`TransitionView`][osrlib.crawl.views.TransitionView] exposes the kind and safe position of each transition on a known cell, but not its destination or gate. `ExploredLevelView.entrance` appears only when the party knows the entrance cell, and `PlayerView.can_travel_to_town` is true only when the party can issue [`TravelToTown`][osrlib.crawl.commands.TravelToTown] from there. Known dropped piles stay in `PlayerView.piles`. Each [`PileView`][osrlib.crawl.views.PileView] lists its things twice, in the same order: `items` as display strings like `"holy_water×2"`, and `contents` as [`PileItemView`][osrlib.crawl.views.PileItemView] entries with the id and the count, which you name from `PlayerView.item_names`. `PlayerView.emptied_caches` keeps its established raw feature references as a post-use compatibility diagnostic. A raw authored feature id can appear there after the party uses it, but it never appears in `MapFeatureView.id` and isn't the preferred command identifier. diff --git a/docs/spec.md b/docs/spec.md index 7ca3a88e..d4045cd0 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -127,7 +127,7 @@ for event in result.events: view = session.view(Visibility.PLAYER) ``` -The player view is a safe projection: party status, explored map cells, entered dungeons and areas, known features and transitions, known active effects, active quests (id, name, display narrative with the block's speaker attribution beside it, since a wire client holds no adventure document to resolve one from, and visible objectives with their ids, display names, and states), and the journal. When areas overlap, the first area in `LevelSpec.areas` owns a shared cell, matching `LevelSpec.area_at`. An area enters only when the party walks an owned cell. An entered area exposes its authored id, name, description, and only those owned cells the party walked. A `MapFeatureView` exposes a stable `feature:` handle, public kind, description, safe location, and a `trap_state` limited to `"found"`, `"sprung"`, or `"removed"`. The handle is HMAC-SHA-256 over a length-prefixed tuple of dungeon id, level number, and authored feature id or generated cache key, with separate domains for those two identity types. Individual dungeon, area, and feature ids may contain colons. Validation requires every canonical `"{dungeon}:{level}:{id}"` area and feature reference to occur once, so repeated definitions and colon-delimited component collisions both fail. New sessions and loaded saves fail closed before they can use ambiguous state. A server adapter supplies an independent key of at least 32 bytes. Omitting the key derives a deterministic pseudonym from the master seed, which is not confidential from someone who knows or can guess that seed. A generated lair cache appears only after the party resolves its keyed encounter. Feature commands resolve only current-location authored features and available generated caches. An ambiguous legacy raw id rejects, and an id that starts with `feature:` never falls back to a raw id. A feature with no trap and a cache with an unfound trap give the same `exploration.feature.unknown` response to trap removal. The map feature list never exposes a raw internal id. `PlayerView.emptied_caches` retains its existing fully qualified raw references only as a post-use compatibility diagnostic. `PlayerView.can_travel_to_town` is true only while the mode is exploring, the current level has an entrance, and the party stands on it. The player view never contains unexplored geometry, cache contents, hidden trap or construction data, a transition destination or gate, monster HP, referee-only roll outcomes, session flags, hidden objectives, gate or trigger wiring, the player-handle key, or the master seed. +The player view is a safe projection: party status, explored map cells, entered dungeons and areas, known features and transitions, known active effects, active quests (id, name, display narrative with the block's speaker attribution beside it, since a wire client holds no adventure document to resolve one from, and visible objectives with their ids, display names, and states), and the journal. When areas overlap, the first area in `LevelSpec.areas` owns a shared cell, matching `LevelSpec.area_at`. An area enters only when the party walks an owned cell. An entered area exposes its authored id, name, description, and only those owned cells the party walked. A `MapFeatureView` exposes a stable `feature:` handle, public kind, description, safe location, and a `trap_state` limited to `"found"`, `"sprung"`, or `"removed"`. The handle is HMAC-SHA-256 over a length-prefixed tuple of dungeon id, level number, and authored feature id or generated cache key, with separate domains for those two identity types. Individual dungeon, area, and feature ids may contain colons. Validation requires every canonical `"{dungeon}:{level}:{id}"` area and feature reference to occur once, so repeated definitions and colon-delimited component collisions both fail. New sessions and loaded saves fail closed before they can use ambiguous state. A server adapter supplies an independent key of at least 32 bytes. Omitting the key derives a deterministic pseudonym from the master seed, which is not confidential from someone who knows or can guess that seed. A generated lair cache appears only after the party resolves its keyed encounter. Feature commands resolve only current-location authored features and available generated caches. An ambiguous legacy raw id rejects, and an id that starts with `feature:` never falls back to a raw id. A feature with no trap and a cache with an unfound trap give the same `exploration.feature.unknown` response to trap removal. The map feature list never exposes a raw internal id. `PlayerView.emptied_caches` retains its existing fully qualified raw references only as a post-use compatibility diagnostic. `PlayerView.can_travel_to_town` is true only while the mode is exploring, the current level has an entrance, and the party stands on it. The player view names every item id it shows, a mundane stack's catalog id and a magic item's or valuable's instance id, in `item_names` and `item_names_plural`, read from the template a stack embeds or the session's catalog, and a pile lists each thing's id and count in `PileView.contents`. An unidentified magic item is named by its category mask or its base, like "potion" or "arrow with a faint aura", never by its true name or template id, and a valuable by its kind. The player view never contains unexplored geometry, cache contents, hidden trap or construction data, a transition destination or gate, monster HP, referee-only roll outcomes, session flags, hidden objectives, gate or trigger wiring, the player-handle key, or the master seed. Generated caches record whether they came from an area, a lair, or a legacy save with no provenance. A legacy cache stays hidden and refuses commands when any keyed encounter in an area containing its parsed cell remains unresolved. Malformed or unresolvable legacy cell references fail closed. After resolution establishes safety, the old cache becomes available. diff --git a/src/osrlib/crawl/views.py b/src/osrlib/crawl/views.py index 65671be6..79170a74 100644 --- a/src/osrlib/crawl/views.py +++ b/src/osrlib/crawl/views.py @@ -1560,7 +1560,7 @@ def _item_names(session, piles: Iterable[DropPile]) -> tuple[dict[str, str], dic # Each id the inventories and the known piles show gets one entry, from the first place it appears. A # stack a member carries is named from the template it embeds, and a pile's stack from the session's # catalog, which has the items the adventure bundles. An unidentified magic item keeps its mask, and - # its template id stays out. + # its template id never becomes a key. names: dict[str, str] = {} plurals: dict[str, str] = {} diff --git a/tools/srd_compile/overrides/equipment.json b/tools/srd_compile/overrides/equipment.json index d8874be0..d4e5b24f 100644 --- a/tools/srd_compile/overrides/equipment.json +++ b/tools/srd_compile/overrides/equipment.json @@ -9,7 +9,7 @@ }, { "id": "hammer", - "reason": "The price list prints 'Hammer (small)', a size the display name puts in front.", + "reason": "The price list prints 'Hammer (small)', so the size goes in front of the noun.", "set": { "display_name": "small hammer", "display_name_plural": "small hammers" @@ -41,7 +41,7 @@ }, { "id": "mirror", - "reason": "The price list prints 'Mirror (hand-sized, steel)', and the display name keeps the size.", + "reason": "The price list prints 'Mirror (hand-sized, steel)', so the display name keeps the size.", "set": { "display_name": "hand mirror", "display_name_plural": "hand mirrors" @@ -89,7 +89,7 @@ }, { "id": "sack_large", - "reason": "The price list prints 'Sack (large)', a size the display name puts in front.", + "reason": "The price list prints 'Sack (large)', so the size goes in front of the noun.", "set": { "display_name": "large sack", "display_name_plural": "large sacks" @@ -97,7 +97,7 @@ }, { "id": "sack_small", - "reason": "The price list prints 'Sack (small)', a size the display name puts in front.", + "reason": "The price list prints 'Sack (small)', so the size goes in front of the noun.", "set": { "display_name": "small sack", "display_name_plural": "small sacks" diff --git a/tools/srd_compile/overrides/magic_items.json b/tools/srd_compile/overrides/magic_items.json index 09f00247..88012e19 100644 --- a/tools/srd_compile/overrides/magic_items.json +++ b/tools/srd_compile/overrides/magic_items.json @@ -8,7 +8,7 @@ }, { "id": "drums_of_panic", - "reason": "The page describes 'Large war drums', one item of several drums, so a sentence names it as a set and the plural can differ from the singular.", + "reason": "The page describes 'Large war drums', a single item made of several drums, so the display name calls it a set, which also gives it a plural that differs from the singular.", "set": { "display_name": "set of drums of panic", "display_name_plural": "sets of drums of panic" @@ -16,7 +16,7 @@ }, { "id": "elven_cloak_and_boots", - "reason": "The page describes 'A set of enchanted boots and a matching cloak', one item of two pieces, so a sentence names it as a set.", + "reason": "The page describes 'A set of enchanted boots and a matching cloak', a single item made of two pieces, so the display name calls it a set.", "set": { "display_name": "set of elven cloak and boots", "display_name_plural": "sets of elven cloak and boots" From 327815483196a158f168ea6dfe68fe73fe082281 Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:23:56 -0800 Subject: [PATCH 04/14] List the item display names on the equipment and magic item id indexes 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 --- tools/docs/gen_content_ids.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/docs/gen_content_ids.py b/tools/docs/gen_content_ids.py index c31d5c98..bf630ae1 100644 --- a/tools/docs/gen_content_ids.py +++ b/tools/docs/gen_content_ids.py @@ -80,7 +80,8 @@ def _page(filename: str, title: str, loader_ref: str, intro: str): "equipment.md", "Equipment ids", "[`load_equipment`][osrlib.data.load_equipment]", - "Every mundane equipment id — weapons, armour, gear, and ammunition — with its display name.", + "Every mundane equipment id (weapons, armour, gear, and ammunition), with its name as the SRD's price list " + "prints it, and its display names, what a sentence calls one unit and two or more.", ) as page: catalog = data.load_equipment() for section_title, entries in ( @@ -90,18 +91,26 @@ def _page(filename: str, title: str, loader_ref: str, intro: str): ("Ammunition", catalog.ammunition), ): page.write(f"## {section_title}\n\n") - _table(page, ("Id", "Name"), [(f"`{e.id}`", e.name) for e in entries]) + _table( + page, + ("Id", "Name", "Display name", "Display name plural"), + [(f"`{e.id}`", e.name, e.display_name, e.display_name_plural) for e in entries], + ) with _page( "magic-items.md", "Magic item ids", "[`load_magic_items`][osrlib.data.load_magic_items]", - "Every magic item template id, with its display name and category.", + "Every magic item template id, with its name as the SRD prints it, its display names, what a sentence calls " + "one identified item and two or more, and its category.", ) as page: _table( page, - ("Id", "Name", "Category"), - [(f"`{i.id}`", i.name, f"`{i.category}`") for i in data.load_magic_items().items], + ("Id", "Name", "Display name", "Display name plural", "Category"), + [ + (f"`{i.id}`", i.name, i.display_name, i.display_name_plural, f"`{i.category}`") + for i in data.load_magic_items().items + ], ) with _page( From 234100452ecb5ec9bf57fa7a3cedd5145173551a Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:37:36 -0800 Subject: [PATCH 05/14] Amend the item names contract: catalog names, pile ids, head-noun plurals, 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 --- src/osrlib/core/items.py | 59 +- src/osrlib/crawl/views.py | 27 +- tests/saves/view_item_names_2.7.0.json | 850 +++++++++++++++++++ tests/saves/view_item_names_party_2.7.0.json | 384 +++++++++ tests/test_item_display_names.py | 107 ++- tests/test_view_item_names.py | 259 +++++- 6 files changed, 1656 insertions(+), 30 deletions(-) create mode 100644 tests/saves/view_item_names_2.7.0.json create mode 100644 tests/saves/view_item_names_party_2.7.0.json diff --git a/src/osrlib/core/items.py b/src/osrlib/core/items.py index a7d7cb82..45c7eccc 100644 --- a/src/osrlib/core/items.py +++ b/src/osrlib/core/items.py @@ -397,9 +397,14 @@ class WeaponTemplate(_Model): """What to call two or more of these weapons, like `"swords"` or `"staves"`. [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you write that leaves it out gets `display_name` with the regular English ending: `s`, or - `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set it yourself - when the plural is irregular. + client. A template you write that leaves it out gets `display_name` with the regular English ending on the word + that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a + closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of + the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns + (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that + follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes + `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself + when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one weapon.""" @@ -486,10 +491,14 @@ class ArmourTemplate(_Model): """What to call two or more of these, like `"shields"` or `"suits of chainmail"`. [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you write that leaves it out gets `display_name` with the regular English ending on its last - word: `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set - it yourself when the plural is irregular, or when the word that takes the ending isn't the last, as in `"suits - of chainmail"`. + client. A template you write that leaves it out gets `display_name` with the regular English ending on the word + that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a + closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of + the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns + (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that + follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes + `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself + when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. """ cost_gp: int = Field(ge=0) """The listed price in gold pieces.""" @@ -625,10 +634,14 @@ class GearTemplate(_Model): """What to call two or more units, like `"torches"` or `"vials of holy water"`. [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you write that leaves it out gets `display_name` with the regular English ending on its last - word: `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set - it yourself when the plural is irregular, or when the word that takes the ending isn't the last, as in `"vials - of holy water"`. + client. A template you write that leaves it out gets `display_name` with the regular English ending on the word + that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a + closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of + the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns + (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that + follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes + `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself + when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one lot.""" @@ -697,9 +710,14 @@ class AmmunitionTemplate(_Model): """What to call two or more units, like `"arrows"` or `"crossbow bolts"`. [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you write that leaves it out gets `display_name` with the regular English ending on its last - word: `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set - it yourself when the plural is irregular. + client. A template you write that leaves it out gets `display_name` with the regular English ending on the word + that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a + closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of + the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns + (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that + follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes + `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself + when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one lot. 0 for sling stones.""" @@ -1091,10 +1109,15 @@ class MagicItemTemplate(_Model): display_name_plural: str = Field(default="", validate_default=True) """What to call two or more of these items, like `"potions of healing"` or `"swords +1"`. - The ending goes on the word that names the item, which is often not the last word. A template you - construct yourself that leaves it out gets `display_name` with the regular English ending on its - last word: `s`, or `es` after `s`, `x`, - `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant. Set it yourself when that isn't the plural. + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' + client. A template you construct yourself that leaves it out gets `display_name` with the regular English ending + on the word that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus + like `+1`, a closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. + So `"Idol of the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes + `"Lanterns (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` + that follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes + `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself + when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. """ category: MagicItemCategory """What kind of item it is. See [`MagicItemCategory`][osrlib.core.items.MagicItemCategory].""" diff --git a/src/osrlib/crawl/views.py b/src/osrlib/crawl/views.py index 79170a74..0d94f0fe 100644 --- a/src/osrlib/crawl/views.py +++ b/src/osrlib/crawl/views.py @@ -1077,21 +1077,28 @@ class PlayerView(_Model): - The catalog id of a mundane stack, like `"holy_water"`, in a member's [`inventory`][osrlib.crawl.views.MemberView.inventory] and in a pile's - [`contents`][osrlib.crawl.views.PileView.contents]. Its name is the template's - [`display_name`][osrlib.core.items.GearTemplate.display_name]. For a stack a member carries, - it's read from the template the stack embeds, and for a pile, from the session's catalog, - [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], so an - item the adventure bundles is named. A pile's catalog id that the session's catalog doesn't - have has no entry. + [`contents`][osrlib.crawl.views.PileView.contents]. Its name is the + [`display_name`][osrlib.core.items.GearTemplate.display_name] of the template the session's + catalog, [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], + has under that id, so an item the adventure bundles is named. The catalog's template is used + even for a stack a member carries, which embeds a template of its own, because a stack from a + save or a party document that osrlib 2.7.0 wrote embeds a template without display names. A + bundled id can't shadow a built-in one, because a session refuses an adventure whose bundled + id collides with a built-in id. A + carried stack whose id the catalog doesn't have, like an item another adventure bundled, is + named from the template the stack embeds. A pile's catalog id that the catalog doesn't have has + no entry. - The instance id of a magic item, like `"magic-item-0003"`, in an inventory and in a pile. Until the party identifies the item, its name is the masked name the inventory shows, without the article: `"potion"`, `"curious device"`, or `"shield with a faint aura"`. So a cursed item and the item it passes for have the same name, and the name tells nothing the inventory - doesn't. Once the item is identified, its name is the template's - [`display_name`][osrlib.core.items.MagicItemTemplate.display_name], like `"potion of healing"`. + doesn't. Once the item is identified, its name is the + [`display_name`][osrlib.core.items.MagicItemTemplate.display_name] of its template in the magic + item catalog, like `"potion of healing"`. - The template id of an identified magic item, like `"potion_of_healing"`, which the inventory - shows once the item is identified, with the same name. An unidentified item's template id is - never a key. + shows once the item is identified, with the same name. A pile shows a magic item by its + instance id alone, identified or not, so an identified item's template id is a key only while + a member carries it. An unidentified item's template id is never a key. - The instance id of a gem or a piece of jewellery, like `"valuable-0007"`. Its name is its kind, `"gem"` or `"piece of jewellery"`. The players see everything else about it from the moment they take it, its own name and its value in gold pieces included, in the inventory's diff --git a/tests/saves/view_item_names_2.7.0.json b/tests/saves/view_item_names_2.7.0.json new file mode 100644 index 00000000..438909ed --- /dev/null +++ b/tests/saves/view_item_names_2.7.0.json @@ -0,0 +1,850 @@ +{ + "engine_version": "2.7.0", + "kind": "save", + "payload": { + "adventure": { + "description": "", + "dungeons": [ + { + "id": "shrine", + "levels": [ + { + "areas": [], + "edges": {}, + "entrance": [ + 0, + 0 + ], + "features": [], + "guidance": "", + "height": 1, + "number": 1, + "transitions": [], + "wandering": { + "chance_in_six": 1, + "interval_turns": 2, + "table": null + }, + "width": 1 + } + ], + "name": "The Shrine" + } + ], + "hooks": [], + "items": [ + { + "capacity_coins": null, + "combat": null, + "cost_gp": 0, + "id": "temple_idol", + "item_type": "gear", + "lot_size": 1, + "name": "Idol of the drowned saint", + "overrides_applied": [], + "params": {} + } + ], + "monsters": [], + "name": "The Drowned Saint", + "party": null, + "quests": [], + "spells": [], + "town": { + "description": "", + "healing_prices": {}, + "name": "Threshold", + "services": [], + "travel_turns": { + "shrine": 1 + } + }, + "triggers": [] + }, + "allocator": { + "counters": { + "character": 4, + "magic-item": 1 + } + }, + "battle": null, + "clock_rounds": 60, + "command_log": [ + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "holy_water", + "quantity": 2, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "torch", + "quantity": 6, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "sword", + "quantity": 1, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "chainmail", + "quantity": 1, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "arrows", + "quantity": 20, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "short_bow", + "quantity": 1, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "temple_idol", + "quantity": 2, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "oil_flask", + "quantity": 2, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "grant_item", + "item_id": "potion_of_healing", + "quantity": 1, + "source": null + }, + { + "character_id": "character-0001", + "command_type": "equip_item", + "item_id": "sword", + "source": null + }, + { + "character_id": "character-0001", + "command_type": "equip_item", + "item_id": "chainmail", + "source": null + }, + { + "command_type": "enter_dungeon", + "dungeon_id": "shrine", + "source": null + }, + { + "character_id": "character-0001", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "command_type": "drop_items", + "item_ids": [ + "oil_flask", + "oil_flask", + "temple_idol" + ], + "source": null + } + ], + "death_records": {}, + "defeated_monsters": [], + "deprivation": {}, + "dungeon_state": { + "doors": {}, + "emptied_caches": [], + "explored": { + "shrine:1": [ + [ + 0, + 0 + ] + ] + }, + "found_traps": [], + "found_tricks": [], + "generated_caches": {}, + "generated_lair_hoards": [], + "generated_treasure_areas": [], + "inspect_attempts": {}, + "listen_attempts": {}, + "location": { + "dungeon_id": "shrine", + "facing": "north", + "kind": "dungeon", + "level_number": 1, + "position": [ + 0, + 0 + ] + }, + "lock_failures": {}, + "piles": { + "cell:shrine:1:0,0": { + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "items": [ + { + "item_id": "oil_flask", + "quantity": 2 + }, + { + "item_id": "temple_idol", + "quantity": 1 + } + ], + "magic_items": [], + "valuables": [] + } + }, + "removal_attempts": {}, + "removed_traps": [], + "resolved_encounters": [], + "search_attempts": {}, + "seen": {}, + "sprung_traps": [] + }, + "encounter": null, + "event_log": [ + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "holy_water", + "holy_water" + ], + "origin": "grant", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "torch", + "torch", + "torch", + "torch", + "torch", + "torch" + ], + "origin": "grant", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "sword" + ], + "origin": "grant", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "chainmail" + ], + "origin": "grant", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows", + "arrows" + ], + "origin": "grant", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "short_bow" + ], + "origin": "grant", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "temple_idol", + "temple_idol" + ], + "origin": "grant", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "oil_flask", + "oil_flask" + ], + "origin": "grant", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.acquired", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "item_acquired", + "item_ids": [ + "magic-item-0001" + ], + "origin": "grant", + "visibility": "player" + }, + { + "code": "exploration.location.entered", + "dungeon_id": null, + "event_type": "location_entered", + "level_number": 1, + "location_id": "shrine", + "location_kind": "dungeon", + "narrative": null, + "transition_ref": null, + "via": "entrance", + "visibility": "player" + }, + { + "character_id": "character-0001", + "code": "exploration.item.dropped", + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "coins_gp_value": 0, + "event_type": "items_dropped", + "item_ids": [ + "oil_flask", + "oil_flask", + "temple_idol" + ], + "visibility": "player" + } + ], + "exploration": { + "alerted_areas": [], + "heard_areas": [], + "last_prepared_sleep": {}, + "noise_since_check": false, + "odometer_thirds": 0, + "provisions_day": 0, + "sleep_count": 0, + "turns_since_rest": 0, + "wandering_counter": 0 + }, + "fired_triggers": [], + "flags": {}, + "journal": [], + "ledger": { + "effects": [] + }, + "listener_state": {}, + "master_seed": 5, + "mode": "exploring", + "monsters": [], + "npcs": [], + "party": { + "members": [ + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "fighter", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0001", + "inventory": { + "items": [ + { + "instance_type": "item", + "quantity": 2, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d8", + "missile_ranges": { + "long": { + "max_feet": 50, + "min_feet": 31 + }, + "medium": { + "max_feet": 30, + "min_feet": 11 + }, + "short": { + "max_feet": 10, + "min_feet": 5 + } + }, + "qualities": [ + "missile", + "splash" + ] + }, + "cost_gp": 25, + "id": "holy_water", + "item_type": "gear", + "lot_size": 1, + "name": "Holy water (vial)", + "overrides_applied": [], + "params": {} + } + }, + { + "instance_type": "item", + "quantity": 6, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d4", + "missile_ranges": null, + "qualities": [ + "melee" + ] + }, + "cost_gp": 1, + "id": "torch", + "item_type": "gear", + "lot_size": 6, + "name": "Torches (6)", + "overrides_applied": [], + "params": { + "brightness": "flame", + "burn_turns": 6, + "light_radius_feet": 30 + } + } + }, + { + "instance_type": "item", + "quantity": 20, + "template": { + "cost_gp": 5, + "id": "arrows", + "item_type": "ammunition", + "lot_size": 20, + "material": "standard", + "name": "Arrows (quiver of 20)", + "overrides_applied": [], + "weight_coins": 0 + } + }, + { + "instance_type": "item", + "quantity": 1, + "template": { + "cost_gp": 25, + "damage": "1d6", + "id": "short_bow", + "item_type": "weapon", + "material": "standard", + "missile_ranges": { + "long": { + "max_feet": 150, + "min_feet": 101 + }, + "medium": { + "max_feet": 100, + "min_feet": 51 + }, + "short": { + "max_feet": 50, + "min_feet": 5 + } + }, + "name": "Short bow", + "overrides_applied": [], + "qualities": [ + "missile", + "two_handed" + ], + "weight_coins": 30 + } + }, + { + "instance_type": "item", + "quantity": 1, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 0, + "id": "temple_idol", + "item_type": "gear", + "lot_size": 1, + "name": "Idol of the drowned saint", + "overrides_applied": [], + "params": {} + } + }, + { + "base_item_id": null, + "charges_remaining": null, + "cursed_revealed": false, + "identified": false, + "instance_id": "magic-item-0001", + "instance_type": "magic_item", + "quantity": 1, + "sentience": null, + "state": {}, + "template_id": "potion_of_healing" + } + ], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [ + { + "instance_type": "item", + "quantity": 1, + "template": { + "cost_gp": 10, + "damage": "1d8", + "id": "sword", + "item_type": "weapon", + "material": "standard", + "missile_ranges": null, + "name": "Sword", + "overrides_applied": [], + "qualities": [ + "melee" + ], + "weight_coins": 60 + } + } + ], + "worn_armour": { + "instance_type": "item", + "quantity": 1, + "template": { + "ac": 5, + "ac_ascending": 14, + "ac_bonus": null, + "category": "heavy", + "cost_gp": 40, + "id": "chainmail", + "item_type": "armour", + "name": "Chainmail", + "overrides_applied": [], + "weight_coins": 400 + } + } + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Brakk", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "thief", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0002", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Sable", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "cleric", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0003", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Wynn", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 13 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "magic_user", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0004", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Elara", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [ + "sleep" + ], + "stat_modifiers": [], + "xp": 0 + } + ] + }, + "quests": {}, + "rng_streams": { + "effects": { + "inc": 83995303103106262482337783037166368733, + "state": 170194833506817835568259385413023180433 + }, + "treasure": { + "inc": 53476702257389784988669638314557571929, + "state": 310646460157342966311778912749120787293 + } + }, + "ruleset": { + "aoe_friendly_fire": true, + "back_stab_needs_both_skills": true, + "deprivation_penalties": false, + "encumbrance": "basic", + "failed_trap_removal_springs": true, + "formation_width_limit": true, + "hd5_counts_as_magical": false, + "hp_reroll_at_first_level": false, + "individual_initiative": false, + "magic_item_death_save": true, + "thac0_arithmetic": false, + "variable_weapon_damage": true, + "weapon_reload": false, + "xp_award_timing": "on_return" + }, + "treasure_snapshot_cp": 0 + }, + "schema_version": 4 +} diff --git a/tests/saves/view_item_names_party_2.7.0.json b/tests/saves/view_item_names_party_2.7.0.json new file mode 100644 index 00000000..fd3c8940 --- /dev/null +++ b/tests/saves/view_item_names_party_2.7.0.json @@ -0,0 +1,384 @@ +{ + "engine_version": "2.7.0", + "kind": "party", + "payload": { + "characters": [ + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "fighter", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0001", + "inventory": { + "items": [ + { + "instance_type": "item", + "quantity": 2, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d8", + "missile_ranges": { + "long": { + "max_feet": 50, + "min_feet": 31 + }, + "medium": { + "max_feet": 30, + "min_feet": 11 + }, + "short": { + "max_feet": 10, + "min_feet": 5 + } + }, + "qualities": [ + "missile", + "splash" + ] + }, + "cost_gp": 25, + "id": "holy_water", + "item_type": "gear", + "lot_size": 1, + "name": "Holy water (vial)", + "overrides_applied": [], + "params": {} + } + }, + { + "instance_type": "item", + "quantity": 6, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d4", + "missile_ranges": null, + "qualities": [ + "melee" + ] + }, + "cost_gp": 1, + "id": "torch", + "item_type": "gear", + "lot_size": 6, + "name": "Torches (6)", + "overrides_applied": [], + "params": { + "brightness": "flame", + "burn_turns": 6, + "light_radius_feet": 30 + } + } + }, + { + "instance_type": "item", + "quantity": 20, + "template": { + "cost_gp": 5, + "id": "arrows", + "item_type": "ammunition", + "lot_size": 20, + "material": "standard", + "name": "Arrows (quiver of 20)", + "overrides_applied": [], + "weight_coins": 0 + } + }, + { + "instance_type": "item", + "quantity": 1, + "template": { + "cost_gp": 25, + "damage": "1d6", + "id": "short_bow", + "item_type": "weapon", + "material": "standard", + "missile_ranges": { + "long": { + "max_feet": 150, + "min_feet": 101 + }, + "medium": { + "max_feet": 100, + "min_feet": 51 + }, + "short": { + "max_feet": 50, + "min_feet": 5 + } + }, + "name": "Short bow", + "overrides_applied": [], + "qualities": [ + "missile", + "two_handed" + ], + "weight_coins": 30 + } + }, + { + "instance_type": "item", + "quantity": 2, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 0, + "id": "temple_idol", + "item_type": "gear", + "lot_size": 1, + "name": "Idol of the drowned saint", + "overrides_applied": [], + "params": {} + } + }, + { + "instance_type": "item", + "quantity": 2, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d8", + "missile_ranges": { + "long": { + "max_feet": 50, + "min_feet": 31 + }, + "medium": { + "max_feet": 30, + "min_feet": 11 + }, + "short": { + "max_feet": 10, + "min_feet": 5 + } + }, + "qualities": [ + "missile", + "splash" + ] + }, + "cost_gp": 2, + "id": "oil_flask", + "item_type": "gear", + "lot_size": 1, + "name": "Oil (1 flask)", + "overrides_applied": [], + "params": { + "fuels_lantern": true + } + } + }, + { + "base_item_id": null, + "charges_remaining": null, + "cursed_revealed": false, + "identified": false, + "instance_id": "magic-item-0001", + "instance_type": "magic_item", + "quantity": 1, + "sentience": null, + "state": {}, + "template_id": "potion_of_healing" + } + ], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [ + { + "instance_type": "item", + "quantity": 1, + "template": { + "cost_gp": 10, + "damage": "1d8", + "id": "sword", + "item_type": "weapon", + "material": "standard", + "missile_ranges": null, + "name": "Sword", + "overrides_applied": [], + "qualities": [ + "melee" + ], + "weight_coins": 60 + } + } + ], + "worn_armour": { + "instance_type": "item", + "quantity": 1, + "template": { + "ac": 5, + "ac_ascending": 14, + "ac_bonus": null, + "category": "heavy", + "cost_gp": 40, + "id": "chainmail", + "item_type": "armour", + "name": "Chainmail", + "overrides_applied": [], + "weight_coins": 400 + } + } + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Brakk", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "thief", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0002", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Sable", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "cleric", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0003", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Wynn", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 13 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "magic_user", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0004", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Elara", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [ + "sleep" + ], + "stat_modifiers": [], + "xp": 0 + } + ] + }, + "schema_version": 4 +} diff --git a/tests/test_item_display_names.py b/tests/test_item_display_names.py index 3c133a53..8dd09daf 100644 --- a/tests/test_item_display_names.py +++ b/tests/test_item_display_names.py @@ -149,10 +149,23 @@ def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): assert singular != plural, (template.id, singular) +BLADE = { + "id": "blade", + "name": "Drowned blade", + "cost_gp": 0, + "weight_coins": 60, + "damage": "1d8", + "qualities": ("melee",), +} +"""The fields a weapon template needs besides its names.""" + + @pytest.mark.parametrize( ("template", "names"), [ - # A template written without the fields gets its name, and the regular ending on the last word. + # A template written without the fields gets its name, and the regular ending on the word that names the + # item: the last word before " of ", " with ", " vs ", a comma, a bonus, a closing Roman numeral, or an + # opening parenthesis, or the last word when the name has none. pytest.param( GearTemplate.model_validate({"id": "crypt_key", "name": "Crypt key", "cost_gp": 0}), ("Crypt key", "Crypt keys"), @@ -238,6 +251,61 @@ def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): id="written_singular", marks=XFAIL, ), + pytest.param( + GearTemplate.model_validate({"id": "idol", "name": "Idol of the drowned saint", "cost_gp": 0}), + ("Idol of the drowned saint", "Idols of the drowned saint"), + id="of", + marks=XFAIL, + ), + # "staff" becomes "staves", as the compiler makes it, and keeps its capital. + pytest.param( + WeaponTemplate.model_validate({**BLADE, "id": "magi_staff", "name": "Staff of the Magi"}), + ("Staff of the Magi", "Staves of the Magi"), + id="staff_of", + marks=XFAIL, + ), + pytest.param( + WeaponTemplate.model_validate({**BLADE, "id": "oaken_staff", "name": "Oaken staff"}), + ("Oaken staff", "Oaken staves"), + id="staff_last", + marks=XFAIL, + ), + pytest.param( + GearTemplate.model_validate({"id": "hooded_lantern", "name": "Lantern (hooded)", "cost_gp": 0}), + ("Lantern (hooded)", "Lanterns (hooded)"), + id="parenthesis", + marks=XFAIL, + ), + pytest.param( + GearTemplate.model_validate({"id": "blue_lamp", "name": "Lamp with a blue flame", "cost_gp": 0}), + ("Lamp with a blue flame", "Lamps with a blue flame"), + id="with", + marks=XFAIL, + ), + pytest.param( + GearTemplate.model_validate({"id": "silver_ring", "name": "Ring, silver", "cost_gp": 0}), + ("Ring, silver", "Rings, silver"), + id="comma", + marks=XFAIL, + ), + pytest.param( + GearTemplate.model_validate({"id": "ward", "name": "Charm vs evil", "cost_gp": 0}), + ("Charm vs evil", "Charms vs evil"), + id="vs", + marks=XFAIL, + ), + pytest.param( + GearTemplate.model_validate({"id": "map_iv", "name": "Map fragment IV", "cost_gp": 0}), + ("Map fragment IV", "Map fragments IV"), + id="numeral", + marks=XFAIL, + ), + pytest.param( + MagicItemTemplate.model_validate({"id": "seeing_orb", "name": "Orb of Seeing", "category": "misc"}), + ("Orb of Seeing", "Orbs of Seeing"), + id="magic_item_of", + marks=XFAIL, + ), ], ) def test_a_template_you_write_without_the_fields_gets_them(template, names: tuple[str, str]): @@ -276,3 +344,40 @@ def test_a_bundled_items_display_names_survive_the_adventure_document(): "temple_idol": ("idol of the drowned saint", "idols of the drowned saint"), "crypt_key": ("Crypt key", "Crypt keys"), } + + +@XFAIL +def test_a_written_name_that_is_already_plural_keeps_its_parenthesis_last(): + """An author's `"Torches (6)"` takes the ending on `"Torches"`, before the parenthesis, never after it. + + The rule can't tell that `"Torches"` is already plural, so it adds the ending a word in "s" takes. The template + docstrings tell an author to set the plural of such a name. What this pins is where the ending goes: the plural + isn't `"Torches (6)s"`, and the lot stays at the end. + """ + template = GearTemplate.model_validate({"id": "torch_bundle", "name": "Torches (6)", "cost_gp": 1}) + + assert template.display_name == "Torches (6)" + assert template.display_name_plural.endswith(" (6)") + assert not template.display_name_plural.endswith(")s") + + +@XFAIL +def test_every_compiled_plural_is_the_default_plural_of_its_display_name(): + """The compiler and a template written without a plural follow one rule. + + Each compiled template, rebuilt with its `display_name` and without its plural, gets its compiled plural back. + No compiled template differs, because every plural an override in `tools/srd_compile/overrides/` sets is the + one the rule gives. + """ + catalog = load_equipment() + templates = (*catalog.weapons, *catalog.armour, *catalog.gear, *catalog.ammunition, *load_magic_items().items) + differs = {} + for template in templates: + document = template.model_dump() + del document["display_name_plural"] + rebuilt = type(template).model_validate(document) + if rebuilt.display_name_plural != template.display_name_plural: + differs[template.id] = (rebuilt.display_name_plural, template.display_name_plural) + + assert len(templates) == 51 + 164 + assert differs == {} diff --git a/tests/test_view_item_names.py b/tests/test_view_item_names.py index d237c80f..cc2d8678 100644 --- a/tests/test_view_item_names.py +++ b/tests/test_view_item_names.py @@ -13,17 +13,24 @@ which is why `tests/test_unrevealed_curse_view.py` pins a cursed shield to the view of a shield +1. """ +import json +from pathlib import Path + import pytest from crawl_fixtures import build_party +from osrlib.core.character import party_from_document from osrlib.core.events import Visibility from osrlib.core.items import GearTemplate, MagicItemInstance, ValuableInstance from osrlib.crawl.adventure import Adventure, TownSpec from osrlib.crawl.commands import DropItems, EnterDungeon, GrantItem, IdentifyItem, TakeTreasure, UseItem from osrlib.crawl.dungeon import AreaSpec, DungeonSpec, FeatureSpec, LevelSpec, ValuableSpec from osrlib.crawl.events import ItemAcquiredEvent, ItemIdentifiedEvent, ItemsDroppedEvent +from osrlib.crawl.party import Party from osrlib.crawl.session import GameSession from osrlib.crawl.views import PileItemView, PlayerView +from osrlib.data import load_equipment, load_magic_items +from osrlib.persistence import load_game from test_loot_and_traps import breath_kill XFAIL = pytest.mark.xfail(reason="chunk: view-item-names") @@ -189,16 +196,49 @@ def test_every_id_an_acquisition_names_is_a_key_in_the_view_after_it(): @XFAIL def test_the_view_names_exactly_the_ids_it_shows(): - """Every key is an id the inventories or the piles' contents show, and every such id is a key.""" + """Every key is an id the inventories or the piles' contents show, and every such id is a key. + + The state holds an identified magic item in each place: a ring of protection the fighter carries, which shows + its template id, and the reliquary's potion, identified and then dropped, which a pile shows by its instance id + alone. Without the identified potion in the pile, a view that keyed a pile item's template id would pass. + """ game, acquired = _looted() potion, _, _ = _ids_of(acquired) + ring = _granted(game, "ring_of_protection") + for instance_id in (ring, potion): + holder = _holders(game, instance_id)[0] + identified = game.execute(IdentifyItem(character_id=holder, item_id=instance_id)) + assert identified.accepted, [rejection.code for rejection in identified.rejections] _drop_everything(game, ["holy_water", potion]) view = _player_view(game) + assert "ring_of_protection" in _shown_ids(view) + assert potion in _shown_ids(view) and "potion_of_healing" not in _shown_ids(view) assert set(view.item_names) == _shown_ids(view) assert set(view.item_names_plural) == set(view.item_names) +@XFAIL +def test_an_identified_item_in_a_pile_is_named_by_its_instance_id_alone(): + """A wand of cold, identified and then dropped in the dungeon. + + The pile shows it by its instance id and its true name, never its template id, so `wand_of_cold` is no key. + """ + game = _town() + instance_id = _granted(game, "wand_of_cold") + assert game.execute(IdentifyItem(character_id=FIGHTER, item_id=instance_id)).accepted + assert game.execute(EnterDungeon(dungeon_id="shrine")).accepted + dropped = game.execute(DropItems(character_id=FIGHTER, item_ids=(instance_id,))) + assert dropped.accepted, [rejection.code for rejection in dropped.rejections] + + view = _player_view(game) + + (pile,) = view.piles.values() + assert pile.contents == (PileItemView(item_id=instance_id, quantity=1),) + assert view.item_names == {instance_id: "wand of cold"} + assert view.item_names_plural == {instance_id: "wands of cold"} + + def test_a_party_that_carries_nothing_has_no_item_names(): """The stock party starts with empty packs. This holds before the chunk too.""" game = GameSession.new(build_party(), _adventure(), seed=5) @@ -531,3 +571,220 @@ def test_a_destroyed_unidentified_item_is_named_by_its_mask(): assert event.visibility is Visibility.PLAYER assert event.item_names == ("a sword with a faint aura",) + + +# ---------------------------------------------------------------------- saves and parties from 2.7.0 + +SAVES = Path(__file__).parent / "saves" + +SAVE_2_7_0 = SAVES / "view_item_names_2.7.0.json" +"""A save that osrlib 2.7.0 wrote, before the templates had display names. It's kept as 2.7.0 wrote it. + +The adventure bundles `temple_idol`, named "Idol of the drowned saint", with no display names. The fighter carries +2 vials of holy water, 6 torches, 20 arrows, a short bow, an idol, and an unidentified potion of healing, and wears +chainmail and wields a sword. The party stands on the shrine's one cell, where the fighter dropped 2 flasks of oil +and the second idol. +""" + +PARTY_2_7_0 = SAVES / "view_item_names_party_2.7.0.json" +"""The same party as a party document that osrlib 2.7.0 wrote, in town, before the drop: the fighter also carries +the 2 flasks of oil and both idols.""" + +CATALOG_NAMES = { + "holy_water": ("vial of holy water", "vials of holy water"), + "torch": ("torch", "torches"), + "arrows": ("arrow", "arrows"), + "short_bow": ("short bow", "short bows"), + "chainmail": ("suit of chainmail", "suits of chainmail"), + "sword": ("sword", "swords"), + "oil_flask": ("flask of oil", "flasks of oil"), +} +"""The compiled catalog's names for the built-in items the fixtures hold, as `test_item_display_names.py` pins them.""" + +UNNAMED_IDOL = ("Idol of the drowned saint", "Idols of the drowned saint") +"""The names a template written without them gets: its `name`, and the ending on the word before " of ".""" + + +def _embedded_templates(document) -> list[dict]: + """Every template a document embeds in a mundane stack, wherever it sits.""" + found = [] + if isinstance(document, dict): + if document.get("instance_type") == "item": + found.append(document["template"]) + for value in document.values(): + found += _embedded_templates(value) + elif isinstance(document, list): + for value in document: + found += _embedded_templates(value) + return found + + +def _names(view: PlayerView) -> dict[str, tuple[str, str]]: + return {item_id: (view.item_names[item_id], view.item_names_plural.get(item_id, "")) for item_id in view.item_names} + + +def test_the_2_7_0_fixtures_embed_templates_without_display_names(): + """The precondition for the two tests below: osrlib 2.7.0 wrote them, so no embedded template has the fields.""" + for path in (SAVE_2_7_0, PARTY_2_7_0): + document = json.loads(path.read_text(encoding="utf-8")) + assert document["engine_version"] == "2.7.0" + templates = _embedded_templates(document) + assert {template["id"] for template in templates} >= {"holy_water", "torch", "chainmail", "temple_idol"} + assert all("display_name" not in template for template in templates) + + +@XFAIL +def test_a_2_7_0_save_names_built_in_items_from_the_catalog(): + """Each carried stack is named by the session's catalog, never by the template the save embedded. + + Named from the embedded template, holy water would read "Holy water (vial)", with the plural + "Holy water (vial)s". The bundled idol has no display names in the save's adventure either, so the catalog's + template gets the defaults, and the carried idol and the one in the pile read the same. + """ + game = load_game(json.loads(SAVE_2_7_0.read_text(encoding="utf-8"))) + + view = _player_view(game) + + (pile,) = view.piles.values() + assert pile.contents == ( + PileItemView(item_id="oil_flask", quantity=2), + PileItemView(item_id="temple_idol", quantity=1), + ) + assert _names(view) == {**CATALOG_NAMES, "temple_idol": UNNAMED_IDOL, "magic-item-0001": ("potion", "potions")} + + +@XFAIL +def test_a_2_7_0_party_document_starts_a_session_with_catalog_names(): + """The party document goes into a new session of an adventure whose idol has names its author wrote. + + The carried idol embeds 2.7.0's template, with no names, and the view names it as the catalog does. + """ + party = Party(members=party_from_document(json.loads(PARTY_2_7_0.read_text(encoding="utf-8")))) + game = GameSession.new(party, _adventure(), seed=5) + + view = _player_view(game) + + assert _names(view) == { + **CATALOG_NAMES, + "temple_idol": ("idol of the drowned saint", "idols of the drowned saint"), + "magic-item-0001": ("potion", "potions"), + } + + +@XFAIL +def test_a_carried_item_the_catalog_lacks_is_named_from_its_embedded_template(): + """The same party in an adventure that bundles no idol: the catalog has no `temple_idol`. + + The view still names the carried idol, from the template it embeds, with the defaults a template written without + names gets. Every built-in item still comes from the catalog. + """ + party = Party(members=party_from_document(json.loads(PARTY_2_7_0.read_text(encoding="utf-8")))) + level = LevelSpec(number=1, width=1, height=1, entrance=(0, 0)) + adventure = Adventure( + name="An Empty Crypt", + town=TownSpec(name="Threshold"), + dungeons=(DungeonSpec(id="crypt", name="Crypt", levels=(level,)),), + ) + game = GameSession.new(party, adventure, seed=5) + + view = _player_view(game) + + assert _names(view) == {**CATALOG_NAMES, "temple_idol": UNNAMED_IDOL, "magic-item-0001": ("potion", "potions")} + + +# ---------------------------------------------------------------------- masks that changed from 2.7.0 + +MASKS_2_7_0_BY_BASE = { + None: "a arm with a faint aura", + "battle_axe": "a battle axe with a faint aura", + "club": "a club with a faint aura", + "crossbow": "a crossbow with a faint aura", + "dagger": "a dagger with a faint aura", + "hand_axe": "a hand axe with a faint aura", + "javelin": "a javelin with a faint aura", + "lance": "a lance with a faint aura", + "long_bow": "a long bow with a faint aura", + "mace": "a mace with a faint aura", + "pole_arm": "a pole arm with a faint aura", + "short_bow": "a short bow with a faint aura", + "short_sword": "a short sword with a faint aura", + "silver_dagger": "a silver dagger with a faint aura", + "sling": "a sling with a faint aura", + "spear": "a spear with a faint aura", + "staff": "a staff with a faint aura", + "sword": "a sword with a faint aura", + "two_handed_sword": "a two-handed sword with a faint aura", + "war_hammer": "a war hammer with a faint aura", + "chainmail": "a chainmail with a faint aura", + "leather": "a leather with a faint aura", + "plate_mail": "a plate mail with a faint aura", + "shield": "a shield with a faint aura", + "arrows": "a arrows (quiver of 20) with a faint aura", + "crossbow_bolts": "a crossbow bolts (case of 30) with a faint aura", + "silver_tipped_arrow": "a silver tipped arrow (1) with a faint aura", + "sling_stones": "a sling stones with a faint aura", +} +"""The `display` osrlib 2.7.0 gave an unidentified enchanted weapon, suit of armour, or shield, by its base item. + +The base is the instance's `base_item_id`, or the template's when the instance has none. Computed by running 2.7.0's +masking over every magic item of the armour, sword, and weapon categories with no base and with each mundane weapon, +armour, and ammunition id as its base: 1,433 instances in all, each giving the string its base gives here. +""" + +MASKS_2_7_0_BY_CATEGORY = { + "misc": "a curious device", + "potion": "a potion", + "ring": "a ring", + "rod": "a rod", + "scroll": "a scroll", + "staff": "a staff", + "wand": "a wand", +} +"""The `display` osrlib 2.7.0 gave every unidentified magic item of the other categories, whatever its base.""" + +CHANGED_MASKS = { + "a arm with a faint aura": "a suit of armour with a faint aura", + "a arrows (quiver of 20) with a faint aura": "an arrow with a faint aura", + "a chainmail with a faint aura": "a suit of chainmail with a faint aura", + "a crossbow bolts (case of 30) with a faint aura": "a crossbow bolt with a faint aura", + "a leather with a faint aura": "a suit of leather armour with a faint aura", + "a plate mail with a faint aura": "a suit of plate mail with a faint aura", + "a silver tipped arrow (1) with a faint aura": "a silver tipped arrow with a faint aura", + "a sling stones with a faint aura": "a sling stone with a faint aura", +} +"""Every 2.7.0 mask that reads differently now, and what it reads as. Every other mask is unchanged.""" + +ARM_CATEGORIES = ("armour", "sword", "weapon") + + +def test_the_masks_that_changed_from_2_7_0_are_exactly_these(): + """Every unidentified magic item, with every base an arm can have, shows the 2.7.0 mask or its replacement. + + The instances sit in one fighter's pack, and the test reads each `display` from the player view. + """ + equipment = load_equipment() + bases = [None, *(template.id for template in (*equipment.weapons, *equipment.armour, *equipment.ammunition))] + game = _town() + pack = game.member(FIGHTER).inventory.items + expected: dict[str, str] = {} + changed: dict[str, str] = {} + for template in load_magic_items().items: + arm = template.category.value in ARM_CATEGORIES + for base in bases if arm else [None]: + instance_id = f"magic-item-{len(expected) + 1:05d}" + pack.append(MagicItemInstance(instance_id=instance_id, template_id=template.id, base_item_id=base)) + if arm: + old = MASKS_2_7_0_BY_BASE[base or template.base_item_id] + else: + old = MASKS_2_7_0_BY_CATEGORY[template.category.value] + expected[instance_id] = CHANGED_MASKS.get(old, old) + if old in CHANGED_MASKS: + changed[old] = CHANGED_MASKS[old] + + view = _player_view(game) + + assert len(expected) == 1433 + (member,) = (member for member in view.party if member.id == FIGHTER) + shown = {entry["instance_id"]: entry["display"] for entry in member.inventory["items"]} + assert shown == expected + assert changed == CHANGED_MASKS From 41a7a2cdfdfb9c2252c62ff10d9b9bcf3ba80986 Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:41:54 -0800 Subject: [PATCH 06/14] Name carried stacks from the catalog and share one plural rule 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 --- src/osrlib/core/items.py | 41 ++++++++++++++++++++++++++++---- src/osrlib/crawl/views.py | 34 +++++++++++++------------- tools/srd_compile/equipment.py | 34 ++++---------------------- tools/srd_compile/magic_items.py | 8 ++++--- 4 files changed, 62 insertions(+), 55 deletions(-) diff --git a/src/osrlib/core/items.py b/src/osrlib/core/items.py index 45c7eccc..add3593f 100644 --- a/src/osrlib/core/items.py +++ b/src/osrlib/core/items.py @@ -88,6 +88,7 @@ ``` """ +import re from collections.abc import Mapping from typing import TYPE_CHECKING, Annotated, Any, Literal @@ -362,6 +363,36 @@ def _check_missile_ranges(qualities: tuple[WeaponQuality, ...], missile_ranges: raise ValueError("missile ranges are present exactly when the missile quality is") +_IRREGULAR_PLURALS = {"staff": "staves"} +"""The plural of every word that names an item and doesn't take the regular English ending.""" + +_HEAD_NOUN_END = re.compile(r" (?:of|with|vs) |, | [+-]\d| (?=[IVX]+$)| \(") +"""Where the words that name an item end and the words that qualify it begin: `of`, `with`, or `vs`, a comma, a +bonus like `+1`, a closing Roman numeral, or an opening parenthesis.""" + + +def _item_plural(name: str) -> str: + """Return the plural of an item's display name, with the ending on the word that names the item. + + That word is the last one before the first match of `_HEAD_NOUN_END`, or the last word of a name with no match, so + `"vial of holy water"` becomes `"vials of holy water"` and `"Lantern (hooded)"` becomes `"Lanterns (hooded)"`. + It takes the ending of `_regular_plural`, unless `_IRREGULAR_PLURALS` lists it, and keeps its capital, so + `"Staff of the Magi"` becomes `"Staves of the Magi"`. The SRD compiler writes the plural of every built-in + template with this function, and a template written without a plural gets it from this function too. + """ + if not name: + return "" + end = _HEAD_NOUN_END.search(name) + head, tail = (name[: end.start()], name[end.start() :]) if end else (name, "") + *words, noun = head.split(" ") + irregular = _IRREGULAR_PLURALS.get(noun.lower()) + if irregular is None: + noun = _regular_plural(noun) + else: + noun = irregular.capitalize() if noun[:1].isupper() else irregular + return " ".join([*words, noun]) + tail + + class WeaponTemplate(_Model): """A mundane weapon, from the SRD's weapon table. @@ -435,7 +466,7 @@ def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str @field_validator("display_name_plural") @classmethod def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: - return value or _regular_plural(info.data.get("display_name", "")) + return value or _item_plural(info.data.get("display_name", "")) @field_validator("damage") @classmethod @@ -529,7 +560,7 @@ def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str @field_validator("display_name_plural") @classmethod def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: - return value or _regular_plural(info.data.get("display_name", "")) + return value or _item_plural(info.data.get("display_name", "")) @model_validator(mode="after") def _body_armour_or_shield(self) -> ArmourTemplate: @@ -674,7 +705,7 @@ def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str @field_validator("display_name_plural") @classmethod def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: - return value or _regular_plural(info.data.get("display_name", "")) + return value or _item_plural(info.data.get("display_name", "")) class AmmunitionTemplate(_Model): @@ -744,7 +775,7 @@ def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str @field_validator("display_name_plural") @classmethod def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: - return value or _regular_plural(info.data.get("display_name", "")) + return value or _item_plural(info.data.get("display_name", "")) ItemTemplate = Annotated[ @@ -1197,7 +1228,7 @@ def _display_name_defaults_to_name(cls, value: str, info: ValidationInfo) -> str @field_validator("display_name_plural") @classmethod def _plural_defaults_to_regular_ending(cls, value: str, info: ValidationInfo) -> str: - return value or _regular_plural(info.data.get("display_name", "")) + return value or _item_plural(info.data.get("display_name", "")) @field_validator("charges_dice", "quantity_dice") @classmethod diff --git a/src/osrlib/crawl/views.py b/src/osrlib/crawl/views.py index 0d94f0fe..ff0d2328 100644 --- a/src/osrlib/crawl/views.py +++ b/src/osrlib/crawl/views.py @@ -1565,49 +1565,49 @@ def _pile_view(pile: DropPile) -> PileView: def _item_names(session, piles: Iterable[DropPile]) -> tuple[dict[str, str], dict[str, str]]: # Each id the inventories and the known piles show gets one entry, from the first place it appears. A - # stack a member carries is named from the template it embeds, and a pile's stack from the session's - # catalog, which has the items the adventure bundles. An unidentified magic item keeps its mask, and - # its template id never becomes a key. + # mundane stack is named from the session's catalog, which has the items the adventure bundles, because a + # stack from a 2.7.0 save or party document embeds a template without display names. Only a carried stack + # whose id the catalog lacks is named from the template it embeds. An unidentified magic item keeps its + # mask, and a template id is a key only for an identified item a member carries, because a pile shows a + # magic item by its instance id alone. names: dict[str, str] = {} plurals: dict[str, str] = {} + equipment = session.effective_equipment + catalog = { + template.id: template + for template in (*equipment.weapons, *equipment.armour, *equipment.gear, *equipment.ammunition) + } def add(item_id: str, singular: str, plural: str) -> None: if item_id not in names: names[item_id] = singular plurals[item_id] = plural - def add_magic_item(instance: MagicItemInstance) -> None: + def add_magic_item(instance: MagicItemInstance, *, carried: bool) -> None: if instance.identified: template = magic_item_template(instance) add(instance.instance_id, template.display_name, template.display_name_plural) - add(instance.template_id, template.display_name, template.display_name_plural) + if carried: + add(instance.template_id, template.display_name, template.display_name_plural) else: add(instance.instance_id, *_masked_names(instance)) for member in session.party.members: for instance in member.inventory.all_instances(): if isinstance(instance, MagicItemInstance): - add_magic_item(instance) + add_magic_item(instance, carried=True) else: - add(instance.template.id, instance.template.display_name, instance.template.display_name_plural) + template = catalog.get(instance.template.id, instance.template) + add(template.id, template.display_name, template.display_name_plural) for valuable in member.inventory.valuables: add(valuable.instance_id, *_VALUABLE_NAMES[valuable.kind]) - catalog = { - template.id: template - for template in ( - *session.effective_equipment.weapons, - *session.effective_equipment.armour, - *session.effective_equipment.gear, - *session.effective_equipment.ammunition, - ) - } for pile in piles: for entry in pile.items: template = catalog.get(entry.item_id) if template is not None: add(entry.item_id, template.display_name, template.display_name_plural) for instance in pile.magic_items: - add_magic_item(instance) + add_magic_item(instance, carried=False) for valuable in pile.valuables: add(valuable.instance_id, *_VALUABLE_NAMES[valuable.kind]) return names, plurals diff --git a/tools/srd_compile/equipment.py b/tools/srd_compile/equipment.py index ba123301..d0980f71 100644 --- a/tools/srd_compile/equipment.py +++ b/tools/srd_compile/equipment.py @@ -20,7 +20,8 @@ Every entry gets the names a sentence uses for one unit and for two or more. The display name is the printed name in lowercase with a trailing parenthesis dropped, and body armour is named as a suit. Ammunition names one unit, so its plural ending goes too: `Arrows (quiver of 20)` is -"arrow". The plural comes from `plural`. Gear whose printed name is a lot or a substance, like +"arrow". The plural comes from `osrlib.core.items._item_plural`, the rule a template written without a plural +follows too. Gear whose printed name is a lot or a substance, like `Torches (6)` and `Holy water (vial)`, and the armour the SRD prints as `Leather`, get the name of the unit the session counts from `overrides/equipment.json`. """ @@ -28,7 +29,7 @@ import re from pathlib import Path -from osrlib.core.monsters import _regular_plural +from osrlib.core.items import _item_plural from .pipetable import parse_range, section_prose, slugify, tables_after_heading @@ -128,37 +129,10 @@ TRAILING_PARENTHESIS = re.compile(r"\s*\([^)]*\)$") -# The plural of every head noun that doesn't take the regular English ending. -_IRREGULAR_PLURALS = {"staff": "staves"} - -# Where the words that name the item end and the words that qualify it begin: "of", "with", or -# "vs", a comma, a bonus like "+1", or a closing Roman numeral. -_HEAD_END = re.compile(r" (?:of|with|vs) |, | [+-]\d| (?=[IVX]+$)") - - -def plural(singular: str) -> str: - """Return what to call two or more of an item, from its display name. - - The ending goes on the last word of the words that name the item, before any `of`, `with`, - `vs`, comma, bonus, or Roman numeral, so `"vial of holy water"` becomes `"vials of holy - water"` and `"sword +1"` becomes `"swords +1"`. The word takes the regular English ending - unless `_IRREGULAR_PLURALS` lists it. - - Args: - singular: The display name, like `"potion of healing"`. - - Returns: - The plural, like `"potions of healing"`. - """ - end = _HEAD_END.search(singular) - head, tail = (singular[: end.start()], singular[end.start() :]) if end else (singular, "") - *words, noun = head.split(" ") - return " ".join([*words, _IRREGULAR_PLURALS.get(noun) or _regular_plural(noun)]) + tail - def display_names(singular: str) -> dict[str, str]: """Return an entry's `display_name` and `display_name_plural` fields for a display name.""" - return {"display_name": singular, "display_name_plural": plural(singular)} + return {"display_name": singular, "display_name_plural": _item_plural(singular)} def _weapon_id(name: str) -> str: diff --git a/tools/srd_compile/magic_items.py b/tools/srd_compile/magic_items.py index 626dd257..4daaa8f5 100644 --- a/tools/srd_compile/magic_items.py +++ b/tools/srd_compile/magic_items.py @@ -51,7 +51,9 @@ from pathlib import Path from urllib.parse import quote -from .equipment import TRAILING_PARENTHESIS, plural +from osrlib.core.items import _item_plural + +from .equipment import TRAILING_PARENTHESIS from .pipetable import slugify, strip_emphasis, strip_links, tables_after_heading from .treasure import parse_treasure_segment @@ -626,7 +628,7 @@ def display_names(printed_name: str, category: str, base_item_id: str | None) -> - Enchanted body armour is named as a suit, "suit of armour +1", and boots and gauntlets as a pair, "pair of boots of speed". - The plural comes from [`plural`][tools.srd_compile.equipment.plural]. + The plural comes from `osrlib.core.items._item_plural`. Args: printed_name: The item's `name`, like `"Potion of Healing"`. @@ -648,7 +650,7 @@ def display_names(printed_name: str, category: str, base_item_id: str | None) -> singular = f"suit of {singular}" elif singular.startswith(_PAIRS): singular = f"pair of {singular}" - return {"display_name": singular, "display_name_plural": plural(singular)} + return {"display_name": singular, "display_name_plural": _item_plural(singular)} def _template( From 864a2718f4ef52da54109710b6922cee14fc6314 Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:41:54 -0800 Subject: [PATCH 07/14] Document catalog naming, pile keys, and the head-noun plural 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 --- CHANGELOG.md | 6 +++--- docs/adaptations.md | 4 ++-- docs/guides/authoring-custom-content.md | 5 +++-- docs/guides/views-and-visibility.md | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b344c6e..a52f6883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,15 +8,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Added -- Every equipment and magic item template has a `display_name` and a `display_name_plural`, what to call one unit and two or more in a sentence, such as `"vial of holy water"` and `"vials of holy water"` for the gear printed as `Holy water (vial)` (#316). They're on [`WeaponTemplate`][osrlib.core.items.WeaponTemplate], [`ArmourTemplate`][osrlib.core.items.ArmourTemplate], [`GearTemplate`][osrlib.core.items.GearTemplate], [`AmmunitionTemplate`][osrlib.core.items.AmmunitionTemplate], and [`MagicItemTemplate`][osrlib.core.items.MagicItemTemplate]. Each name refers to the unit that an instance's `quantity` counts, not to a lot from the price list, so `Torches (6)` is `"torch"` and `Arrows +1 (3d10 arrows)` is `"arrow +1"`. The SRD compiler fills them for the built-in catalogs. A template you write that leaves them out gets its `name` and the regular English plural of the display name, so an adventure document from 2.7.0 still loads. -- [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] name every item whose id the view shows, keyed by that id: a mundane stack's catalog id, and a magic item's or a valuable's instance id, in a member's inventory or a known pile (#316). A stack a member carries is named from the template it embeds, and a stack in a pile from [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], so an item the adventure bundles is named. An unidentified magic item is named by its masked name without the article, like `"potion"` or `"shield with a faint aura"`, so a cursed item has the names of the item it passes for, and the view never includes its template id. An identified item is named by its template's display names, under both its instance id and its template id. A gem is `"gem"` and a piece of jewellery `"piece of jewellery"`. Before, a client with only the view and the events couldn't word "The party finds 2 vials of holy water". +- Every equipment and magic item template has a `display_name` and a `display_name_plural`, what to call one unit and two or more in a sentence, such as `"vial of holy water"` and `"vials of holy water"` for the gear printed as `Holy water (vial)` (#316). They're on [`WeaponTemplate`][osrlib.core.items.WeaponTemplate], [`ArmourTemplate`][osrlib.core.items.ArmourTemplate], [`GearTemplate`][osrlib.core.items.GearTemplate], [`AmmunitionTemplate`][osrlib.core.items.AmmunitionTemplate], and [`MagicItemTemplate`][osrlib.core.items.MagicItemTemplate]. Each name refers to the unit that an instance's `quantity` counts, not to a lot from the price list, so `Torches (6)` is `"torch"` and `Arrows +1 (3d10 arrows)` is `"arrow +1"`. The SRD compiler fills them for the built-in catalogs. A template you write that leaves them out gets its `name`, and a plural with the regular English ending on the word that names the item, the last word before the first `of`, `with`, or `vs`, a comma, a bonus such as `+1`, a closing Roman numeral, or an opening parenthesis, or the last word of a name with none of them. So `"Idol of the drowned saint"` becomes `"Idols of the drowned saint"`, and "staff" becomes "staves". Every compiled plural follows the same rule. An adventure document from 2.7.0 still loads. +- [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] name every item whose id the view shows, keyed by that id: a mundane stack's catalog id, and a magic item's or a valuable's instance id, in a member's inventory or a known pile (#316). A mundane stack, carried or in a pile, is named from the session's catalog, [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], so an item the adventure bundles is named, and a stack from a 2.7.0 save or party document, which embeds a template without display names, is named as a new stack is. A carried stack whose id the catalog lacks, such as an item another adventure bundled, is named from the template it embeds. An unidentified magic item is named by its masked name without the article, like `"potion"` or `"shield with a faint aura"`, so a cursed item has the names of the item it passes for, and the view never includes its template id. An identified item is named by its template's display names, under its instance id, and under its template id while a member carries it, because a pile shows a magic item by its instance id alone. A gem is `"gem"` and a piece of jewellery `"piece of jewellery"`. Before, a client with only the view and the events couldn't word "The party finds 2 vials of holy water". - [`PileView.contents`][osrlib.crawl.views.PileView.contents] gives each thing in a pile as a [`PileItemView`][osrlib.crawl.views.PileItemView], with the id that the events use for it and its count, in the order of `items` (#316). A client reads `"holy_water"` and 2 there where `items` has `"holy_water×2"`. `items` doesn't change. - [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] has two new fields, `display_name` and `display_name_plural`, the identified item's display names, like `"potion of healing"` (#316). A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, but the event does. An event recorded before this release has empty names. Every field this release adds has a default, so a 2.7.0 save, view, or event still parses, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. ### Fixed - [`EquipmentDestroyedEvent`][osrlib.core.events.EquipmentDestroyedEvent], which the players see, names an unidentified magic item by its masked name, like `"a sword with a faint aura"`, the `display` the inventory showed for it (#316). Before, it named the item by its true name, like `"Sword +1"`, so a breath weapon that killed a member told the players what the member's unidentified items were. -- The masked `display` of an unidentified enchanted arm in [`MemberView.inventory`][osrlib.crawl.views.MemberView.inventory] and [`PileView.items`][osrlib.crawl.views.PileView.items] is built from one unit of the mundane item underneath it, its display name with "a" or "an" (#316). Enchanted arrows read `"an arrow with a faint aura"`, where they read `"a arrows (quiver of 20) with a faint aura"`, enchanted crossbow bolts read `"a crossbow bolt with a faint aura"`, where they read `"a crossbow bolts (case of 30) with a faint aura"`, enchanted chainmail reads `"a suit of chainmail with a faint aura"`, where it read `"a chainmail with a faint aura"`, and enchanted armour with no mundane armour recorded reads `"a suit of armour with a faint aura"`, where it read `"a arm with a faint aura"`. Enchanted leather and plate mail read `"a suit of leather armour with a faint aura"` and `"a suit of plate mail with a faint aura"`, where they read `"a leather with a faint aura"` and `"a plate mail with a faint aura"`. The shield, sword, dagger, staff, and other weapon strings don't change. A front end that matches on the changed strings needs updating. +- The masked `display` of an unidentified enchanted arm in [`MemberView.inventory`][osrlib.crawl.views.MemberView.inventory] and [`PileView.items`][osrlib.crawl.views.PileView.items] is built from one unit of the mundane item underneath it, its display name with "a" or "an" (#316). Enchanted arrows read `"an arrow with a faint aura"`, where they read `"a arrows (quiver of 20) with a faint aura"`, enchanted crossbow bolts read `"a crossbow bolt with a faint aura"`, where they read `"a crossbow bolts (case of 30) with a faint aura"`, enchanted chainmail reads `"a suit of chainmail with a faint aura"`, where it read `"a chainmail with a faint aura"`, and enchanted armour with no mundane armour recorded reads `"a suit of armour with a faint aura"`, where it read `"a arm with a faint aura"`. Enchanted leather and plate mail read `"a suit of leather armour with a faint aura"` and `"a suit of plate mail with a faint aura"`, where they read `"a leather with a faint aura"` and `"a plate mail with a faint aura"`. Enchanted silver tipped arrows read `"a silver tipped arrow with a faint aura"`, where they read `"a silver tipped arrow (1) with a faint aura"`, and enchanted sling stones read `"a sling stone with a faint aura"`, where they read `"a sling stones with a faint aura"`. The shield, sword, dagger, staff, and other weapon strings don't change. A front end that matches on the changed strings needs updating. ## [2.7.0] - 2026-11-25 diff --git a/docs/adaptations.md b/docs/adaptations.md index b2830af2..1cd496eb 100644 --- a/docs/adaptations.md +++ b/docs/adaptations.md @@ -161,9 +161,9 @@ The SRD prints item names for a price list or a treasure table, like `Torches (6 - It names one of the units that the item's `quantity` counts, not a lot. The compiler drops the plural ending from ammunition, so `Arrows (quiver of 20)` is "arrow" and `Arrows +1` is "arrow +1". Gear sold in a lot or as a substance is named by the unit or the container the SRD's descriptions give, so `Torches (6)` is "torch", `Holy water (vial)` is "vial of holy water", and `Oil (1 flask)` is "flask of oil". Those names come from `overrides/equipment.json`, with a reason for each. - Body armour is a suit, "suit of chainmail" and "suit of armour +1", and the SRD's `Leather` is "suit of leather armour". Boots and gauntlets are a pair, "pair of boots of speed". The drums of panic and the elven cloak and boots are each a set. - A spell scroll keeps its spell count, "spell scroll with 3 spells". The compiler moves a label after a colon to the front, so `Elemental Summoning Device: Air` is "air elemental summoning device", except a treasure map's numeral, which stays at the end. -- The plural ending goes on the word that names the item, before any `of`, `with`, `vs`, comma, bonus, or numeral, so the plurals read "vials of holy water", "swords +1, +3 vs undead", and "treasure maps II". The ending is the regular English one, except that "staff" becomes "staves". +- The plural ending goes on the word that names the item, before any `of`, `with`, `vs`, comma, bonus, numeral, or opening parenthesis, so the plurals read "vials of holy water", "swords +1, +3 vs undead", and "treasure maps II". The ending is the regular English one, except that "staff" becomes "staves". -A template you write without the fields gets its `name` and the regular plural of the display name. Locked by `test_item_display_names.py`. +A template you write without the fields gets its `name`, and a plural by the same rule, so "Idol of the drowned saint" becomes "Idols of the drowned saint". `osrlib.core.items` has the one implementation of the rule, which the compiler imports, so every compiled plural is the one the rule gives. Locked by `test_item_display_names.py`. ### INT-granted languages come from the Other Languages table and may not duplicate natives diff --git a/docs/guides/authoring-custom-content.md b/docs/guides/authoring-custom-content.md index 294889b6..5d3647c1 100644 --- a/docs/guides/authoring-custom-content.md +++ b/docs/guides/authoring-custom-content.md @@ -657,7 +657,7 @@ Unlike spells, monsters, and items, custom classes are stored on each character Add custom [`WeaponTemplate`][osrlib.core.items.WeaponTemplate], [`ArmourTemplate`][osrlib.core.items.ArmourTemplate], [`GearTemplate`][osrlib.core.items.GearTemplate], and [`AmmunitionTemplate`][osrlib.core.items.AmmunitionTemplate] instances (discriminated by `item_type`) to `Adventure.items`. [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment] unions `load_equipment()` with `Adventure.items`, resolving bundled IDs in treasure caches (`FeatureSpec.item_ids`), [`GrantItem`][osrlib.crawl.commands.GrantItem], and dropped item piles. Once acquired, [`ItemInstance`][osrlib.core.items.ItemInstance] embeds its template for equipping, encumbrance, combat, item transfers, saves, and replay. -You can also set what the players call a bundled item in a sentence. Set [`display_name`][osrlib.core.items.GearTemplate.display_name] to what to call one, in lowercase with no article, like `"idol of the drowned saint"`, and [`display_name_plural`][osrlib.core.items.GearTemplate.display_name_plural] to what to call two or more. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] give them to the players' client. A template that leaves `display_name` out gets its `name`, and one that leaves `display_name_plural` out gets the display name with the regular English ending on its last word, so set the plural yourself when that ending is wrong, as for "idols of the drowned saint". +You can also set what the players call a bundled item in a sentence. Set [`display_name`][osrlib.core.items.GearTemplate.display_name] to what to call one, in lowercase with no article, like `"idol of the drowned saint"`, and [`display_name_plural`][osrlib.core.items.GearTemplate.display_name_plural] to what to call two or more. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] give them to the players' client. A template that leaves `display_name` out gets its `name`, and one that leaves `display_name_plural` out gets the display name with the regular English ending on the word that names the item, the last word before the first `of`, `with`, or `vs`, a comma, a bonus such as `+1`, a closing Roman numeral, or an opening parenthesis, or the last word of a name with none of them. So `"idol of the drowned saint"` gets `"idols of the drowned saint"`, and `"Staff of the Magi"` gets `"Staves of the Magi"`. Set the plural yourself when the name is already plural, such as `"Torches (6)"`, or when the plural is irregular. [`validate_adventure`][osrlib.crawl.adventure.validate_adventure] requires every bundled item ID to be unique across `Adventure.items`, the built-in equipment catalog ([the equipment id index][equipment-index]), and the built-in magic-item catalog (treasure encumbrance row IDs such as `coin`, `gem`, and `jewellery` do not count as item IDs): @@ -714,7 +714,8 @@ BLESSED_STONES = AmmunitionTemplate.model_validate( {"id": "blessed_stones", "name": "Blessed sling stones", "cost_gp": 0, "lot_size": 20} ) -# A template written without display names gets its name and the regular plural. +# A template written without display names gets its name, and the plural ending on the +# word that names the item. assert (DROWNED_BLADE.display_name, DROWNED_BLADE.display_name_plural) == ("Drowned blade", "Drowned blades") # Bundle them: the adventure document carries the templates, and a cache places diff --git a/docs/guides/views-and-visibility.md b/docs/guides/views-and-visibility.md index a5a42eef..28ac1e91 100644 --- a/docs/guides/views-and-visibility.md +++ b/docs/guides/views-and-visibility.md @@ -34,7 +34,7 @@ Each party member appears in `PlayerView.party` as a [`MemberView`][osrlib.crawl A member's spell book and memorized spells name each spell by id, and so does the `kind` of a spell's effect in `PlayerView.effects`. Show the names in [`PlayerView.spell_names`][osrlib.crawl.views.PlayerView.spell_names], keyed by those ids, and the names of reversed forms, like *darkness* for *light*, in [`PlayerView.reversed_spell_names`][osrlib.crawl.views.PlayerView.reversed_spell_names]. The view reads both from the session's catalog, so a spell the adventure bundles has its name there too. Neither includes a spell that is absent from the rest of the view, like one on a scroll. -Items work the same way. An inventory identifies a mundane stack by its template's catalog id, like `"holy_water"`, and a magic item or a gem or piece of jewellery by its instance id, like `"magic-item-0003"`, and the item events use the same ids. Show the names in [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names], a noun phrase for one with no article, like `"vial of holy water"`, and in [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] for a count, so you can word "The party finds 2 vials of holy water". Both have a key for each item id that the inventories and the known piles show, and only for those ids. A stack a member carries is named from the template it embeds, and a stack in a pile from the session's catalog, so an item the adventure bundles has its name there too. A valuable is named by its kind, `"gem"` or `"piece of jewellery"`, whereas the inventory's `valuables` contain the piece's name and value. A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, and the [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] contains its names instead. +Items work the same way. An inventory identifies a mundane stack by its template's catalog id, like `"holy_water"`, and a magic item or a gem or piece of jewellery by its instance id, like `"magic-item-0003"`, and the item events use the same ids. Show the names in [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names], a noun phrase for one with no article, like `"vial of holy water"`, and in [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] for a count, so you can word "The party finds 2 vials of holy water". Both have a key for each item id that the inventories and the known piles show, and only for those ids. A mundane stack, carried or in a pile, is named from the session's catalog, so an item the adventure bundles has its name there too, and a stack from a 2.7.0 save, which embeds a template without display names, is named as a new stack is. A carried stack whose id the catalog lacks, such as an item another adventure bundled, is named from the template it embeds. A valuable is named by its kind, `"gem"` or `"piece of jewellery"`, whereas the inventory's `valuables` contain the piece's name and value. A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, and the [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] contains its names instead. Derived combat and exploration stats include bonuses from worn equipment (such as armour, a shield, or a ring of protection), even before the party identifies a magic item: From 65b1bda3298ec0d7441a0875ae1104507bd0513b Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:44:13 -0800 Subject: [PATCH 08/14] Pin the default plural for title-case connectors and a doubled space 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 --- tests/test_item_display_names.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_item_display_names.py b/tests/test_item_display_names.py index 8dd09daf..b86779ae 100644 --- a/tests/test_item_display_names.py +++ b/tests/test_item_display_names.py @@ -306,6 +306,26 @@ def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): id="magic_item_of", marks=XFAIL, ), + # An author often writes a name in title case, so "Of" and "With" mark the head noun as "of" and "with" do. + pytest.param( + MagicItemTemplate.model_validate({"id": "power_staff", "name": "Staff Of Power", "category": "staff"}), + ("Staff Of Power", "Staves Of Power"), + id="title_case_of", + marks=XFAIL, + ), + pytest.param( + GearTemplate.model_validate({"id": "gem_lamp", "name": "Lamp With A Gem", "cost_gp": 0}), + ("Lamp With A Gem", "Lamps With A Gem"), + id="title_case_with", + marks=XFAIL, + ), + # A doubled space in a written name doesn't put a space before the ending. + pytest.param( + GearTemplate.model_validate({"id": "rock_box", "name": "Box of rocks", "cost_gp": 0}), + ("Box of rocks", "Boxes of rocks"), + id="doubled_space", + marks=XFAIL, + ), ], ) def test_a_template_you_write_without_the_fields_gets_them(template, names: tuple[str, str]): From 0bbabb648bd240e04f05303d7892c44d41cd3c8e Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:46:58 -0800 Subject: [PATCH 09/14] Find the head noun in title-case names and keep doubled spaces 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 --- CHANGELOG.md | 2 +- docs/adaptations.md | 2 +- docs/guides/authoring-custom-content.md | 2 +- src/osrlib/core/items.py | 121 +++++++++++++----------- 4 files changed, 69 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a52f6883..9f498d30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Added -- Every equipment and magic item template has a `display_name` and a `display_name_plural`, what to call one unit and two or more in a sentence, such as `"vial of holy water"` and `"vials of holy water"` for the gear printed as `Holy water (vial)` (#316). They're on [`WeaponTemplate`][osrlib.core.items.WeaponTemplate], [`ArmourTemplate`][osrlib.core.items.ArmourTemplate], [`GearTemplate`][osrlib.core.items.GearTemplate], [`AmmunitionTemplate`][osrlib.core.items.AmmunitionTemplate], and [`MagicItemTemplate`][osrlib.core.items.MagicItemTemplate]. Each name refers to the unit that an instance's `quantity` counts, not to a lot from the price list, so `Torches (6)` is `"torch"` and `Arrows +1 (3d10 arrows)` is `"arrow +1"`. The SRD compiler fills them for the built-in catalogs. A template you write that leaves them out gets its `name`, and a plural with the regular English ending on the word that names the item, the last word before the first `of`, `with`, or `vs`, a comma, a bonus such as `+1`, a closing Roman numeral, or an opening parenthesis, or the last word of a name with none of them. So `"Idol of the drowned saint"` becomes `"Idols of the drowned saint"`, and "staff" becomes "staves". Every compiled plural follows the same rule. An adventure document from 2.7.0 still loads. +- Every equipment and magic item template has a `display_name` and a `display_name_plural`, what to call one unit and two or more in a sentence, such as `"vial of holy water"` and `"vials of holy water"` for the gear printed as `Holy water (vial)` (#316). They're on [`WeaponTemplate`][osrlib.core.items.WeaponTemplate], [`ArmourTemplate`][osrlib.core.items.ArmourTemplate], [`GearTemplate`][osrlib.core.items.GearTemplate], [`AmmunitionTemplate`][osrlib.core.items.AmmunitionTemplate], and [`MagicItemTemplate`][osrlib.core.items.MagicItemTemplate]. Each name refers to the unit that an instance's `quantity` counts, not to a lot from the price list, so `Torches (6)` is `"torch"` and `Arrows +1 (3d10 arrows)` is `"arrow +1"`. The SRD compiler fills them for the built-in catalogs. A template you write that leaves them out gets its `name`, and a plural with the regular English ending on the word that names the item, the last word before the first `of`, `with`, or `vs` in any case, a comma, a bonus such as `+1`, a closing Roman numeral, or an opening parenthesis, or the last word of a name with none of them. So `"Idol of the drowned saint"` becomes `"Idols of the drowned saint"`, `"Staff Of Power"` becomes `"Staves Of Power"`, and spaces after the word stay after the ending. Every compiled plural follows the same rule. An adventure document from 2.7.0 still loads. - [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] name every item whose id the view shows, keyed by that id: a mundane stack's catalog id, and a magic item's or a valuable's instance id, in a member's inventory or a known pile (#316). A mundane stack, carried or in a pile, is named from the session's catalog, [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], so an item the adventure bundles is named, and a stack from a 2.7.0 save or party document, which embeds a template without display names, is named as a new stack is. A carried stack whose id the catalog lacks, such as an item another adventure bundled, is named from the template it embeds. An unidentified magic item is named by its masked name without the article, like `"potion"` or `"shield with a faint aura"`, so a cursed item has the names of the item it passes for, and the view never includes its template id. An identified item is named by its template's display names, under its instance id, and under its template id while a member carries it, because a pile shows a magic item by its instance id alone. A gem is `"gem"` and a piece of jewellery `"piece of jewellery"`. Before, a client with only the view and the events couldn't word "The party finds 2 vials of holy water". - [`PileView.contents`][osrlib.crawl.views.PileView.contents] gives each thing in a pile as a [`PileItemView`][osrlib.crawl.views.PileItemView], with the id that the events use for it and its count, in the order of `items` (#316). A client reads `"holy_water"` and 2 there where `items` has `"holy_water×2"`. `items` doesn't change. - [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] has two new fields, `display_name` and `display_name_plural`, the identified item's display names, like `"potion of healing"` (#316). A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, but the event does. An event recorded before this release has empty names. Every field this release adds has a default, so a 2.7.0 save, view, or event still parses, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. diff --git a/docs/adaptations.md b/docs/adaptations.md index 1cd496eb..eb7eec3b 100644 --- a/docs/adaptations.md +++ b/docs/adaptations.md @@ -163,7 +163,7 @@ The SRD prints item names for a price list or a treasure table, like `Torches (6 - A spell scroll keeps its spell count, "spell scroll with 3 spells". The compiler moves a label after a colon to the front, so `Elemental Summoning Device: Air` is "air elemental summoning device", except a treasure map's numeral, which stays at the end. - The plural ending goes on the word that names the item, before any `of`, `with`, `vs`, comma, bonus, numeral, or opening parenthesis, so the plurals read "vials of holy water", "swords +1, +3 vs undead", and "treasure maps II". The ending is the regular English one, except that "staff" becomes "staves". -A template you write without the fields gets its `name`, and a plural by the same rule, so "Idol of the drowned saint" becomes "Idols of the drowned saint". `osrlib.core.items` has the one implementation of the rule, which the compiler imports, so every compiled plural is the one the rule gives. Locked by `test_item_display_names.py`. +A template you write without the fields gets its `name`, and a plural by the same rule, which counts `of`, `with`, and `vs` in any case, because an author often writes a name in title case. So "Idol of the drowned saint" becomes "Idols of the drowned saint", and "Staff Of Power" becomes "Staves Of Power". `osrlib.core.items` has the one implementation of the rule, which the compiler imports, so every compiled plural is the one the rule gives. Locked by `test_item_display_names.py`. ### INT-granted languages come from the Other Languages table and may not duplicate natives diff --git a/docs/guides/authoring-custom-content.md b/docs/guides/authoring-custom-content.md index 5d3647c1..105bed7b 100644 --- a/docs/guides/authoring-custom-content.md +++ b/docs/guides/authoring-custom-content.md @@ -657,7 +657,7 @@ Unlike spells, monsters, and items, custom classes are stored on each character Add custom [`WeaponTemplate`][osrlib.core.items.WeaponTemplate], [`ArmourTemplate`][osrlib.core.items.ArmourTemplate], [`GearTemplate`][osrlib.core.items.GearTemplate], and [`AmmunitionTemplate`][osrlib.core.items.AmmunitionTemplate] instances (discriminated by `item_type`) to `Adventure.items`. [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment] unions `load_equipment()` with `Adventure.items`, resolving bundled IDs in treasure caches (`FeatureSpec.item_ids`), [`GrantItem`][osrlib.crawl.commands.GrantItem], and dropped item piles. Once acquired, [`ItemInstance`][osrlib.core.items.ItemInstance] embeds its template for equipping, encumbrance, combat, item transfers, saves, and replay. -You can also set what the players call a bundled item in a sentence. Set [`display_name`][osrlib.core.items.GearTemplate.display_name] to what to call one, in lowercase with no article, like `"idol of the drowned saint"`, and [`display_name_plural`][osrlib.core.items.GearTemplate.display_name_plural] to what to call two or more. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] give them to the players' client. A template that leaves `display_name` out gets its `name`, and one that leaves `display_name_plural` out gets the display name with the regular English ending on the word that names the item, the last word before the first `of`, `with`, or `vs`, a comma, a bonus such as `+1`, a closing Roman numeral, or an opening parenthesis, or the last word of a name with none of them. So `"idol of the drowned saint"` gets `"idols of the drowned saint"`, and `"Staff of the Magi"` gets `"Staves of the Magi"`. Set the plural yourself when the name is already plural, such as `"Torches (6)"`, or when the plural is irregular. +You can also set what the players call a bundled item in a sentence. Set [`display_name`][osrlib.core.items.GearTemplate.display_name] to what to call one, in lowercase with no article, like `"idol of the drowned saint"`, and [`display_name_plural`][osrlib.core.items.GearTemplate.display_name_plural] to what to call two or more. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] give them to the players' client. A template that leaves `display_name` out gets its `name`, and one that leaves `display_name_plural` out gets the display name with the regular English ending on the word that names the item, the last word before the first `of`, `with`, or `vs` in any case, a comma, a bonus such as `+1`, a closing Roman numeral, or an opening parenthesis, or the last word of a name with none of them. So `"idol of the drowned saint"` gets `"idols of the drowned saint"`, and `"Staff Of Power"` gets `"Staves Of Power"`. Set the plural yourself when the name is already plural, such as `"Torches (6)"`, or when the plural is irregular. [`validate_adventure`][osrlib.crawl.adventure.validate_adventure] requires every bundled item ID to be unique across `Adventure.items`, the built-in equipment catalog ([the equipment id index][equipment-index]), and the built-in magic-item catalog (treasure encumbrance row IDs such as `coin`, `gem`, and `jewellery` do not count as item IDs): diff --git a/src/osrlib/core/items.py b/src/osrlib/core/items.py index add3593f..a5524c95 100644 --- a/src/osrlib/core/items.py +++ b/src/osrlib/core/items.py @@ -366,31 +366,37 @@ def _check_missile_ranges(qualities: tuple[WeaponQuality, ...], missile_ranges: _IRREGULAR_PLURALS = {"staff": "staves"} """The plural of every word that names an item and doesn't take the regular English ending.""" -_HEAD_NOUN_END = re.compile(r" (?:of|with|vs) |, | [+-]\d| (?=[IVX]+$)| \(") -"""Where the words that name an item end and the words that qualify it begin: `of`, `with`, or `vs`, a comma, a -bonus like `+1`, a closing Roman numeral, or an opening parenthesis.""" +_HEAD_NOUN_END = re.compile(r" (?i:of|with|vs) |, | [+-]\d| (?=[IVX]+$)| \(") +"""Where the words that name an item end and the words that qualify it begin: `of`, `with`, or `vs` in any case, a +comma, a bonus like `+1`, a closing Roman numeral, or an opening parenthesis.""" + +_LAST_WORD = re.compile(r"(?P.*?)(?P\S+)(?P\s*)") +"""The words before the last word, the last word, and any whitespace after it.""" def _item_plural(name: str) -> str: """Return the plural of an item's display name, with the ending on the word that names the item. That word is the last one before the first match of `_HEAD_NOUN_END`, or the last word of a name with no match, so - `"vial of holy water"` becomes `"vials of holy water"` and `"Lantern (hooded)"` becomes `"Lanterns (hooded)"`. - It takes the ending of `_regular_plural`, unless `_IRREGULAR_PLURALS` lists it, and keeps its capital, so - `"Staff of the Magi"` becomes `"Staves of the Magi"`. The SRD compiler writes the plural of every built-in + `"vial of holy water"` becomes `"vials of holy water"`, `"Staff Of Power"` becomes `"Staves Of Power"`, and + `"Lantern (hooded)"` becomes `"Lanterns (hooded)"`. It takes the ending of `_regular_plural`, unless + `_IRREGULAR_PLURALS` lists it, and keeps its capital, so `"Staff of the Magi"` becomes `"Staves of the Magi"`. + The ending goes straight on the word, and any whitespace after the word stays after the ending, so a name with + two spaces before its `of` keeps them after the ending. The SRD compiler writes the plural of every built-in template with this function, and a template written without a plural gets it from this function too. """ - if not name: - return "" end = _HEAD_NOUN_END.search(name) head, tail = (name[: end.start()], name[end.start() :]) if end else (name, "") - *words, noun = head.split(" ") + match = _LAST_WORD.fullmatch(head) + if match is None: + return name + noun = match["noun"] irregular = _IRREGULAR_PLURALS.get(noun.lower()) if irregular is None: noun = _regular_plural(noun) else: noun = irregular.capitalize() if noun[:1].isupper() else irregular - return " ".join([*words, noun]) + tail + return match["words"] + noun + match["space"] + tail class WeaponTemplate(_Model): @@ -427,15 +433,16 @@ class WeaponTemplate(_Model): display_name_plural: str = Field(default="", validate_default=True) """What to call two or more of these weapons, like `"swords"` or `"staves"`. - [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you write that leaves it out gets `display_name` with the regular English ending on the word - that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a - closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of - the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns - (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that - follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes - `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself - when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' client. A + template you write that leaves it out gets `display_name` with the regular English ending on the word that names the + item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a closing Roman numeral, or + an opening parenthesis, or the last word when the name has none of them. So `"Idol of the drowned saint"` becomes + `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns (hooded)"`. The ending is `s`, or `es` + after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant, and `staff` becomes + `staves` with its capital kept, so `"Staff of the Magi"` becomes `"Staves of the Magi"`. The connecting words count + in any case, so `"Staff Of Power"` becomes `"Staves Of Power"`, and any spaces after the word stay after the ending. + The compiled plural of every built-in template follows the same rule. Set it yourself when the name is already + plural, like `"Torches (6)"`, or when the plural is irregular. """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one weapon.""" @@ -521,15 +528,16 @@ class ArmourTemplate(_Model): display_name_plural: str = Field(default="", validate_default=True) """What to call two or more of these, like `"shields"` or `"suits of chainmail"`. - [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you write that leaves it out gets `display_name` with the regular English ending on the word - that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a - closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of - the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns - (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that - follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes - `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself - when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' client. A + template you write that leaves it out gets `display_name` with the regular English ending on the word that names the + item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a closing Roman numeral, or + an opening parenthesis, or the last word when the name has none of them. So `"Idol of the drowned saint"` becomes + `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns (hooded)"`. The ending is `s`, or `es` + after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant, and `staff` becomes + `staves` with its capital kept, so `"Staff of the Magi"` becomes `"Staves of the Magi"`. The connecting words count + in any case, so `"Staff Of Power"` becomes `"Staves Of Power"`, and any spaces after the word stay after the ending. + The compiled plural of every built-in template follows the same rule. Set it yourself when the name is already + plural, like `"Torches (6)"`, or when the plural is irregular. """ cost_gp: int = Field(ge=0) """The listed price in gold pieces.""" @@ -664,15 +672,16 @@ class GearTemplate(_Model): display_name_plural: str = Field(default="", validate_default=True) """What to call two or more units, like `"torches"` or `"vials of holy water"`. - [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you write that leaves it out gets `display_name` with the regular English ending on the word - that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a - closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of - the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns - (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that - follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes - `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself - when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' client. A + template you write that leaves it out gets `display_name` with the regular English ending on the word that names the + item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a closing Roman numeral, or + an opening parenthesis, or the last word when the name has none of them. So `"Idol of the drowned saint"` becomes + `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns (hooded)"`. The ending is `s`, or `es` + after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant, and `staff` becomes + `staves` with its capital kept, so `"Staff of the Magi"` becomes `"Staves of the Magi"`. The connecting words count + in any case, so `"Staff Of Power"` becomes `"Staves Of Power"`, and any spaces after the word stay after the ending. + The compiled plural of every built-in template follows the same rule. Set it yourself when the name is already + plural, like `"Torches (6)"`, or when the plural is irregular. """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one lot.""" @@ -740,15 +749,16 @@ class AmmunitionTemplate(_Model): display_name_plural: str = Field(default="", validate_default=True) """What to call two or more units, like `"arrows"` or `"crossbow bolts"`. - [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you write that leaves it out gets `display_name` with the regular English ending on the word - that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a - closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of - the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns - (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that - follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes - `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself - when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' client. A + template you write that leaves it out gets `display_name` with the regular English ending on the word that names the + item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a closing Roman numeral, or + an opening parenthesis, or the last word when the name has none of them. So `"Idol of the drowned saint"` becomes + `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns (hooded)"`. The ending is `s`, or `es` + after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant, and `staff` becomes + `staves` with its capital kept, so `"Staff of the Magi"` becomes `"Staves of the Magi"`. The connecting words count + in any case, so `"Staff Of Power"` becomes `"Staves Of Power"`, and any spaces after the word stay after the ending. + The compiled plural of every built-in template follows the same rule. Set it yourself when the name is already + plural, like `"Torches (6)"`, or when the plural is irregular. """ cost_gp: int = Field(ge=0) """The listed price in gold pieces, for one lot. 0 for sling stones.""" @@ -1140,15 +1150,16 @@ class MagicItemTemplate(_Model): display_name_plural: str = Field(default="", validate_default=True) """What to call two or more of these items, like `"potions of healing"` or `"swords +1"`. - [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' - client. A template you construct yourself that leaves it out gets `display_name` with the regular English ending - on the word that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus - like `+1`, a closing Roman numeral, or an opening parenthesis, or the last word when the name has none of them. - So `"Idol of the drowned saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes - `"Lanterns (hooded)"`. The ending is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` - that follows a consonant, and `staff` becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes - `"Staves of the Magi"`. The compiled plural of every built-in template follows the same rule. Set it yourself - when the name is already plural, like `"Torches (6)"`, or when the plural is irregular. + [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] gives it to the players' client. A + template you construct yourself that leaves it out gets `display_name` with the regular English ending on the word + that names the item: the last word before the first `of`, `with`, or `vs`, a comma, a bonus like `+1`, a closing + Roman numeral, or an opening parenthesis, or the last word when the name has none of them. So `"Idol of the drowned + saint"` becomes `"Idols of the drowned saint"`, and `"Lantern (hooded)"` becomes `"Lanterns (hooded)"`. The ending + is `s`, or `es` after `s`, `x`, `z`, `ch`, or `sh`, or `ies` in place of a `y` that follows a consonant, and `staff` + becomes `staves` with its capital kept, so `"Staff of the Magi"` becomes `"Staves of the Magi"`. The connecting + words count in any case, so `"Staff Of Power"` becomes `"Staves Of Power"`, and any spaces after the word stay after + the ending. The compiled plural of every built-in template follows the same rule. Set it yourself when the name is + already plural, like `"Torches (6)"`, or when the plural is irregular. """ category: MagicItemCategory """What kind of item it is. See [`MagicItemCategory`][osrlib.core.items.MagicItemCategory].""" From cfc299e744d17bd5938c079f4917fa7fa7da2550 Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:47:27 -0800 Subject: [PATCH 10/14] Remove the expected-to-fail markers from the item name tests The implementation is in, so the tests run as ordinary tests. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3 --- tests/test_item_display_names.py | 28 ---------------------------- tests/test_view_item_names.py | 23 ----------------------- 2 files changed, 51 deletions(-) diff --git a/tests/test_item_display_names.py b/tests/test_item_display_names.py index b86779ae..e63e9103 100644 --- a/tests/test_item_display_names.py +++ b/tests/test_item_display_names.py @@ -20,8 +20,6 @@ from osrlib.crawl.dungeon import DungeonSpec, LevelSpec from osrlib.data import load_equipment, load_magic_items -XFAIL = pytest.mark.xfail(reason="chunk: view-item-names") - MUNDANE = { # Gear. A lot from the price list becomes one unit, and a substance becomes its container or measure. "backpack": ("backpack", "backpacks"), @@ -122,7 +120,6 @@ def test_the_table_covers_every_compiled_equipment_template(): assert set(_equipment()) == set(MUNDANE) -@XFAIL @pytest.mark.parametrize(("item_id", "names"), sorted(MUNDANE.items())) def test_each_compiled_equipment_template_has_its_display_names(item_id: str, names: tuple[str, str]): template = _equipment()[item_id] @@ -130,7 +127,6 @@ def test_each_compiled_equipment_template_has_its_display_names(item_id: str, na assert (template.display_name, template.display_name_plural) == names -@XFAIL @pytest.mark.parametrize(("item_id", "names"), sorted(MAGIC.items())) def test_a_compiled_magic_item_template_has_its_display_names(item_id: str, names: tuple[str, str]): template = load_magic_items().get(item_id) @@ -138,7 +134,6 @@ def test_a_compiled_magic_item_template_has_its_display_names(item_id: str, name assert (template.display_name, template.display_name_plural) == names -@XFAIL def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): """Each one is filled, starts in lowercase, drops the printed parenthesis, and has a distinct plural.""" for template in load_magic_items().items: @@ -170,19 +165,16 @@ def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): GearTemplate.model_validate({"id": "crypt_key", "name": "Crypt key", "cost_gp": 0}), ("Crypt key", "Crypt keys"), id="gear", - marks=XFAIL, ), pytest.param( GearTemplate.model_validate({"id": "compass", "name": "Brass compass", "cost_gp": 0}), ("Brass compass", "Brass compasses"), id="gear_es", - marks=XFAIL, ), pytest.param( AmmunitionTemplate.model_validate({"id": "dart", "name": "Barbed dart", "cost_gp": 0}), ("Barbed dart", "Barbed darts"), id="ammunition", - marks=XFAIL, ), pytest.param( WeaponTemplate.model_validate( @@ -197,7 +189,6 @@ def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): ), ("Drowned blade", "Drowned blades"), id="weapon", - marks=XFAIL, ), pytest.param( ArmourTemplate.model_validate( @@ -213,20 +204,17 @@ def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): ), ("Saint's scale", "Saint's scales"), id="armour", - marks=XFAIL, ), pytest.param( MagicItemTemplate.model_validate({"id": "orb", "name": "Gleaming orb", "category": "misc"}), ("Gleaming orb", "Gleaming orbs"), id="magic_item", - marks=XFAIL, ), # A consonant before the y: "ies". pytest.param( GearTemplate.model_validate({"id": "reliquary", "name": "Reliquary", "cost_gp": 0}), ("Reliquary", "Reliquaries"), id="gear_ies", - marks=XFAIL, ), # A name written for one keeps a plural written for two or more. This holds before the chunk too. pytest.param( @@ -249,82 +237,69 @@ def test_every_compiled_magic_item_has_display_names_a_sentence_can_use(): ), ("jade idol", "jade idols"), id="written_singular", - marks=XFAIL, ), pytest.param( GearTemplate.model_validate({"id": "idol", "name": "Idol of the drowned saint", "cost_gp": 0}), ("Idol of the drowned saint", "Idols of the drowned saint"), id="of", - marks=XFAIL, ), # "staff" becomes "staves", as the compiler makes it, and keeps its capital. pytest.param( WeaponTemplate.model_validate({**BLADE, "id": "magi_staff", "name": "Staff of the Magi"}), ("Staff of the Magi", "Staves of the Magi"), id="staff_of", - marks=XFAIL, ), pytest.param( WeaponTemplate.model_validate({**BLADE, "id": "oaken_staff", "name": "Oaken staff"}), ("Oaken staff", "Oaken staves"), id="staff_last", - marks=XFAIL, ), pytest.param( GearTemplate.model_validate({"id": "hooded_lantern", "name": "Lantern (hooded)", "cost_gp": 0}), ("Lantern (hooded)", "Lanterns (hooded)"), id="parenthesis", - marks=XFAIL, ), pytest.param( GearTemplate.model_validate({"id": "blue_lamp", "name": "Lamp with a blue flame", "cost_gp": 0}), ("Lamp with a blue flame", "Lamps with a blue flame"), id="with", - marks=XFAIL, ), pytest.param( GearTemplate.model_validate({"id": "silver_ring", "name": "Ring, silver", "cost_gp": 0}), ("Ring, silver", "Rings, silver"), id="comma", - marks=XFAIL, ), pytest.param( GearTemplate.model_validate({"id": "ward", "name": "Charm vs evil", "cost_gp": 0}), ("Charm vs evil", "Charms vs evil"), id="vs", - marks=XFAIL, ), pytest.param( GearTemplate.model_validate({"id": "map_iv", "name": "Map fragment IV", "cost_gp": 0}), ("Map fragment IV", "Map fragments IV"), id="numeral", - marks=XFAIL, ), pytest.param( MagicItemTemplate.model_validate({"id": "seeing_orb", "name": "Orb of Seeing", "category": "misc"}), ("Orb of Seeing", "Orbs of Seeing"), id="magic_item_of", - marks=XFAIL, ), # An author often writes a name in title case, so "Of" and "With" mark the head noun as "of" and "with" do. pytest.param( MagicItemTemplate.model_validate({"id": "power_staff", "name": "Staff Of Power", "category": "staff"}), ("Staff Of Power", "Staves Of Power"), id="title_case_of", - marks=XFAIL, ), pytest.param( GearTemplate.model_validate({"id": "gem_lamp", "name": "Lamp With A Gem", "cost_gp": 0}), ("Lamp With A Gem", "Lamps With A Gem"), id="title_case_with", - marks=XFAIL, ), # A doubled space in a written name doesn't put a space before the ending. pytest.param( GearTemplate.model_validate({"id": "rock_box", "name": "Box of rocks", "cost_gp": 0}), ("Box of rocks", "Boxes of rocks"), id="doubled_space", - marks=XFAIL, ), ], ) @@ -332,7 +307,6 @@ def test_a_template_you_write_without_the_fields_gets_them(template, names: tupl assert (template.display_name, template.display_name_plural) == names -@XFAIL def test_a_bundled_items_display_names_survive_the_adventure_document(): """An adventure document round-trips the names its author wrote, and one written without them still loads.""" idol = GearTemplate.model_validate( @@ -366,7 +340,6 @@ def test_a_bundled_items_display_names_survive_the_adventure_document(): } -@XFAIL def test_a_written_name_that_is_already_plural_keeps_its_parenthesis_last(): """An author's `"Torches (6)"` takes the ending on `"Torches"`, before the parenthesis, never after it. @@ -381,7 +354,6 @@ def test_a_written_name_that_is_already_plural_keeps_its_parenthesis_last(): assert not template.display_name_plural.endswith(")s") -@XFAIL def test_every_compiled_plural_is_the_default_plural_of_its_display_name(): """The compiler and a template written without a plural follow one rule. diff --git a/tests/test_view_item_names.py b/tests/test_view_item_names.py index cc2d8678..97792357 100644 --- a/tests/test_view_item_names.py +++ b/tests/test_view_item_names.py @@ -33,8 +33,6 @@ from osrlib.persistence import load_game from test_loot_and_traps import breath_kill -XFAIL = pytest.mark.xfail(reason="chunk: view-item-names") - FIGHTER = "character-0001" TEMPLE_IDOL = GearTemplate.model_validate( @@ -154,7 +152,6 @@ def _shown_ids(view: PlayerView) -> set[str]: # ---------------------------------------------------------------------- what the party carries -@XFAIL def test_every_item_a_member_carries_is_named_singular_and_plural(): """The reliquary's contents, spread across the party's packs. @@ -182,7 +179,6 @@ def test_every_item_a_member_carries_is_named_singular_and_plural(): } -@XFAIL def test_every_id_an_acquisition_names_is_a_key_in_the_view_after_it(): """`ItemAcquiredEvent.item_ids` repeats a catalog id once per unit, and each id is named after the command.""" game, acquired = _looted() @@ -194,7 +190,6 @@ def test_every_id_an_acquisition_names_is_a_key_in_the_view_after_it(): assert sum(event.item_ids.count("holy_water") for event in acquired) == 2 -@XFAIL def test_the_view_names_exactly_the_ids_it_shows(): """Every key is an id the inventories or the piles' contents show, and every such id is a key. @@ -218,7 +213,6 @@ def test_the_view_names_exactly_the_ids_it_shows(): assert set(view.item_names_plural) == set(view.item_names) -@XFAIL def test_an_identified_item_in_a_pile_is_named_by_its_instance_id_alone(): """A wand of cold, identified and then dropped in the dungeon. @@ -252,7 +246,6 @@ def test_a_party_that_carries_nothing_has_no_item_names(): # ---------------------------------------------------------------------- what lies in a pile -@XFAIL def test_a_piles_contents_give_each_entrys_id_and_count_beside_the_strings(): """The whole haul dropped on the party's cell. The strings stay as they were, and `contents` follows their order. @@ -278,7 +271,6 @@ def test_a_piles_contents_give_each_entrys_id_and_count_beside_the_strings(): assert item_id in view.item_names, item_id -@XFAIL def test_a_bundled_item_in_a_pile_is_named_from_the_sessions_catalog(): """Nobody carries the idol once it's dropped, so its name comes from `effective_equipment`, not a pack.""" game, acquired = _looted() @@ -317,7 +309,6 @@ def _entry(view: PlayerView, instance_id: str, member_id: str = FIGHTER) -> dict return next(entry for entry in member.inventory["items"] if entry.get("instance_id") == instance_id) -@XFAIL @pytest.mark.parametrize( ("template_id", "names"), [ @@ -342,7 +333,6 @@ def test_an_unidentified_item_is_named_by_its_category_mask(template_id: str, na assert template_id not in view.model_dump_json() -@XFAIL def test_an_unidentified_items_true_name_never_reaches_the_view(): """Neither the potion's catalog id nor its true name, in either case, appears anywhere in the view.""" game = _town() @@ -355,7 +345,6 @@ def test_an_unidentified_items_true_name_never_reaches_the_view(): assert '"potion"' in blob -@XFAIL @pytest.mark.parametrize( ("cursed", "lookalike", "base", "names"), [ @@ -418,7 +407,6 @@ def test_a_cursed_item_and_its_lookalike_have_the_same_names(cursed, lookalike, "an arrow with a faint aura", ("arrow with a faint aura", "arrows with a faint aura"), id="arrows", - marks=XFAIL, ), pytest.param( "crossbow_bolts_plus_2", @@ -426,7 +414,6 @@ def test_a_cursed_item_and_its_lookalike_have_the_same_names(cursed, lookalike, "a crossbow bolt with a faint aura", ("crossbow bolt with a faint aura", "crossbow bolts with a faint aura"), id="crossbow_bolts", - marks=XFAIL, ), # Body armour is a suit. Today it reads "a chainmail with a faint aura". pytest.param( @@ -435,7 +422,6 @@ def test_a_cursed_item_and_its_lookalike_have_the_same_names(cursed, lookalike, "a suit of chainmail with a faint aura", ("suit of chainmail with a faint aura", "suits of chainmail with a faint aura"), id="chainmail", - marks=XFAIL, ), # A suit with no mundane item recorded. Today it reads "a arm with a faint aura". pytest.param( @@ -444,7 +430,6 @@ def test_a_cursed_item_and_its_lookalike_have_the_same_names(cursed, lookalike, "a suit of armour with a faint aura", ("suit of armour with a faint aura", "suits of armour with a faint aura"), id="no_base", - marks=XFAIL, ), # The names a single word gives are unchanged in `display`, and these two already hold. pytest.param("shield_plus_1", "shield", "a shield with a faint aura", None, id="shield"), @@ -467,7 +452,6 @@ def test_an_enchanted_arm_is_named_after_one_unit_of_its_base(template_id, base, assert (view.item_names["magic-item-9001"], view.item_names_plural["magic-item-9001"]) == names -@XFAIL def test_an_identified_item_is_named_by_its_template_under_both_ids(): """Once identified, the inventory shows the template id, and it and the instance id have the true names.""" game = _town() @@ -482,7 +466,6 @@ def test_an_identified_item_is_named_by_its_template_under_both_ids(): assert view.item_names_plural == {instance_id: "potions of healing", "potion_of_healing": "potions of healing"} -@XFAIL def test_the_identification_event_names_the_item(): """`IdentifyItem` leaves the potion in the pack, and the event and the view give the same names.""" game = _town() @@ -495,7 +478,6 @@ def test_the_identification_event_names_the_item(): assert _player_view(game).item_names[instance_id] == event.display_name -@XFAIL def test_a_potion_identified_by_drinking_it_is_named_only_by_its_event(): """Drinking an unidentified potion identifies it and uses it up in one command. @@ -522,7 +504,6 @@ def test_a_potion_identified_by_drinking_it_is_named_only_by_its_event(): # ---------------------------------------------------------------------- valuables -@XFAIL def test_a_valuable_is_named_by_its_kind_whatever_its_own_name(): """A gem the treasure tables roll is named `"Gem"`, and a piece of jewellery can have any name an author gives it. @@ -560,7 +541,6 @@ def test_a_valuable_is_named_by_its_kind_whatever_its_own_name(): # ---------------------------------------------------------------------- destroyed equipment -@XFAIL def test_a_destroyed_unidentified_item_is_named_by_its_mask(): """A hellhound's breath kills a member whose pack holds one unidentified Sword +1, which fails its save. @@ -633,7 +613,6 @@ def test_the_2_7_0_fixtures_embed_templates_without_display_names(): assert all("display_name" not in template for template in templates) -@XFAIL def test_a_2_7_0_save_names_built_in_items_from_the_catalog(): """Each carried stack is named by the session's catalog, never by the template the save embedded. @@ -653,7 +632,6 @@ def test_a_2_7_0_save_names_built_in_items_from_the_catalog(): assert _names(view) == {**CATALOG_NAMES, "temple_idol": UNNAMED_IDOL, "magic-item-0001": ("potion", "potions")} -@XFAIL def test_a_2_7_0_party_document_starts_a_session_with_catalog_names(): """The party document goes into a new session of an adventure whose idol has names its author wrote. @@ -671,7 +649,6 @@ def test_a_2_7_0_party_document_starts_a_session_with_catalog_names(): } -@XFAIL def test_a_carried_item_the_catalog_lacks_is_named_from_its_embedded_template(): """The same party in an adventure that bundles no idol: the catalog has no `temple_idol`. From 7707a6d89c436b97d4ede73b0a74b799fdfa5438 Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 20:58:24 -0800 Subject: [PATCH 11/14] Add the contract for catalog names on embedded item templates 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 --- src/osrlib/core/items.py | 10 + src/osrlib/crawl/commands.py | 5 +- src/osrlib/crawl/views.py | 22 +- src/osrlib/persistence.py | 6 +- tests/saves/view_item_names_npcs_2.7.0.json | 1150 +++++++++++++++++++ tests/test_embedded_item_names.py | 278 +++++ 6 files changed, 1458 insertions(+), 13 deletions(-) create mode 100644 tests/saves/view_item_names_npcs_2.7.0.json create mode 100644 tests/test_embedded_item_names.py diff --git a/src/osrlib/core/items.py b/src/osrlib/core/items.py index a5524c95..9675dd6c 100644 --- a/src/osrlib/core/items.py +++ b/src/osrlib/core/items.py @@ -1997,6 +1997,16 @@ class ItemInstance(_Model): """The item itself, one of the four equipment templates. See [`ItemTemplate`][osrlib.core.items.ItemTemplate]. The whole template is embedded rather than referenced by id, so an instance of an item an adventure bundled stays readable without that adventure. + + A session gives an embedded template the display names of the template its catalog, + [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], has under the same id. + It does this to every stack a party member or an NPC adventurer carries when the session starts, when + [`load_game`][osrlib.persistence.load_game] restores it, and when [`AddMember`][osrlib.crawl.commands.AddMember] + adds a member. Only `display_name` and `display_name_plural` change, with the entries of `overrides_applied` that + name those two fields, which record where the names came from. The rest of the template is rules data that travels + with the character. So a stack from a save or a party document that osrlib 2.7.0 wrote, whose + template has no display names, is named as the catalog names it, in the views and in the next save. A template + whose id the catalog doesn't have, like an item another adventure bundled, keeps the names it has. """ quantity: int = Field(default=1, ge=1) """How many units the stack contains, counting individual items rather than lots: buying one lot of torches gives diff --git a/src/osrlib/crawl/commands.py b/src/osrlib/crawl/commands.py index d5040c30..8e7d59d1 100644 --- a/src/osrlib/crawl/commands.py +++ b/src/osrlib/crawl/commands.py @@ -3751,7 +3751,10 @@ class AddMember(Command): needs `id` set to `None`, no conditions or stat modifiers, and no magic items or valuables. Constructing the command copies the character. A change you make to your object afterwards doesn't reach the command, and the command log records the - character as you sent it.""" + character as you sent it. The member who joins gets the display names of the session's catalog + on each item template the character's stacks embed, as + [`ItemInstance.template`][osrlib.core.items.ItemInstance.template] describes, while the + command keeps the templates it arrived with.""" @field_validator("character", mode="after") @classmethod diff --git a/src/osrlib/crawl/views.py b/src/osrlib/crawl/views.py index e765a58d..f854acd3 100644 --- a/src/osrlib/crawl/views.py +++ b/src/osrlib/crawl/views.py @@ -1157,17 +1157,17 @@ class PlayerView(_Model): - The catalog id of a mundane stack, like `"holy_water"`, in a member's [`inventory`][osrlib.crawl.views.MemberView.inventory] and in a pile's - [`contents`][osrlib.crawl.views.PileView.contents]. Its name is the - [`display_name`][osrlib.core.items.GearTemplate.display_name] of the template the session's - catalog, [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], - has under that id, so an item the adventure bundles is named. The catalog's template is used - even for a stack a member carries, which embeds a template of its own, because a stack from a - save or a party document that osrlib 2.7.0 wrote embeds a template without display names. A - bundled id can't shadow a built-in one, because a session refuses an adventure whose bundled - id collides with a built-in id. A - carried stack whose id the catalog doesn't have, like an item another adventure bundled, is - named from the template the stack embeds. A pile's catalog id that the catalog doesn't have has - no entry. + [`contents`][osrlib.crawl.views.PileView.contents]. For a stack a member carries, its name is + the [`display_name`][osrlib.core.items.GearTemplate.display_name] of the template the stack + embeds, which the session gives the display names of the template its catalog, + [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], has + under that id, as [`ItemInstance.template`][osrlib.core.items.ItemInstance.template] says. So a + stack from a save or a party document that osrlib 2.7.0 wrote is named as the catalog names it, + and the name here matches the stack's template in `inventory`. A bundled id can't shadow a + built-in one, because a session refuses an adventure whose bundled id collides with a built-in + id. A carried stack whose id the catalog doesn't have, like an item another adventure bundled, + keeps the names its template has. For a pile, the name comes from the catalog, and a pile's + catalog id that the catalog doesn't have has no entry. - The instance id of a magic item, like `"magic-item-0003"`, in an inventory and in a pile. Until the party identifies the item, its name is the masked name the inventory shows, without the article: `"potion"`, `"curious device"`, or `"shield with a faint aura"`. So a cursed item diff --git a/src/osrlib/persistence.py b/src/osrlib/persistence.py index 75fff3a4..0dad1023 100644 --- a/src/osrlib/persistence.py +++ b/src/osrlib/persistence.py @@ -470,7 +470,11 @@ def load_game(document: Mapping[str, object]) -> GameSession: You don't need to do anything for an older save. The call checks the document, then upgrades a copy of the payload through [`MIGRATIONS`][osrlib.persistence.MIGRATIONS], one schema version at a time, before it rebuilds anything. The call doesn't change `document`, - and the restored session shares nothing with it. + and the restored session shares nothing with it. Each item template that a party member's or + an NPC adventurer's stack embeds takes the display names of the session's catalog, as + [`ItemInstance.template`][osrlib.core.items.ItemInstance.template] describes, so the gear in a + save that osrlib 2.7.0 wrote is named as a new session names it, and the next save writes those + names. A save that this osrlib wrote loads to a session that saves the same document again. A newer osrlib can add event types and message codes within the same schema version. The call keeps an event as a dict when this osrlib doesn't define its type, or defines the type diff --git a/tests/saves/view_item_names_npcs_2.7.0.json b/tests/saves/view_item_names_npcs_2.7.0.json new file mode 100644 index 00000000..7e403fdd --- /dev/null +++ b/tests/saves/view_item_names_npcs_2.7.0.json @@ -0,0 +1,1150 @@ +{ + "engine_version": "2.7.0", + "kind": "save", + "payload": { + "adventure": { + "description": "", + "dungeons": [ + { + "id": "crypt", + "levels": [ + { + "areas": [], + "edges": {}, + "entrance": [ + 0, + 0 + ], + "features": [], + "guidance": "", + "height": 1, + "number": 1, + "transitions": [], + "wandering": { + "chance_in_six": 0, + "interval_turns": 2, + "table": null + }, + "width": 1 + } + ], + "name": "Crypt" + } + ], + "hooks": [], + "items": [], + "monsters": [], + "name": "The Rival Band", + "party": null, + "quests": [], + "spells": [], + "town": { + "description": "", + "healing_prices": {}, + "name": "Threshold", + "services": [], + "travel_turns": { + "crypt": 1 + } + }, + "triggers": [] + }, + "allocator": { + "counters": { + "character": 4, + "group": 1, + "npc": 4 + } + }, + "battle": { + "advance_feet": {}, + "arrived_round": {}, + "concentration": {}, + "fired_last_round": [], + "hiding": {}, + "melee_engagements": {}, + "monsters_hold_rounds": 0, + "morale": { + "passed": {} + }, + "morale_acted": {}, + "round": 1, + "started_round": 60 + }, + "clock_rounds": 61, + "command_log": [ + { + "command_type": "enter_dungeon", + "dungeon_id": "crypt", + "source": null + }, + { + "command_type": "spawn_npc_party", + "count_dice": null, + "count_fixed": 4, + "distance_feet": 60, + "party_kind": "basic", + "source": null + } + ], + "death_records": {}, + "defeated_monsters": [], + "deprivation": {}, + "dungeon_state": { + "doors": {}, + "emptied_caches": [], + "explored": { + "crypt:1": [ + [ + 0, + 0 + ] + ] + }, + "found_traps": [], + "found_tricks": [], + "generated_caches": {}, + "generated_lair_hoards": [], + "generated_treasure_areas": [], + "inspect_attempts": {}, + "listen_attempts": {}, + "location": { + "dungeon_id": "crypt", + "facing": "north", + "kind": "dungeon", + "level_number": 1, + "position": [ + 0, + 0 + ] + }, + "lock_failures": {}, + "piles": {}, + "removal_attempts": {}, + "removed_traps": [], + "resolved_encounters": [], + "search_attempts": {}, + "seen": {}, + "sprung_traps": [] + }, + "encounter": { + "area_ref": null, + "evading": false, + "groups": [ + { + "distance_feet": 40, + "fled": false, + "fleeing": false, + "group_treasure": { + "coins": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 49 + }, + "magic_items": [], + "valuables": [] + }, + "id": "group-0001", + "label": "adventurer", + "label_plural": "adventurers", + "member_treasure": {}, + "monster_ids": [ + "npc-0001", + "npc-0002", + "npc-0003", + "npc-0004" + ] + } + ], + "hostile_deadline": null, + "kind": "spawned", + "monsters_skip_rounds": 0, + "monsters_surprised": false, + "party_surprised": true, + "pursuit": null, + "round": 0, + "stance": "attacks", + "started_round": 60 + }, + "event_log": [ + { + "code": "exploration.location.entered", + "dungeon_id": null, + "event_type": "location_entered", + "level_number": 1, + "location_id": "crypt", + "location_kind": "dungeon", + "narrative": null, + "transition_ref": null, + "via": "entrance", + "visibility": "player" + }, + { + "alignment": "chaotic", + "class_ids": [ + "magic_user", + "cleric", + "fighter", + "fighter" + ], + "code": "encounter.npc_party.spawned", + "event_type": "npc_party_spawned", + "levels": [ + 1, + 1, + 1, + 2 + ], + "npc_ids": [ + "npc-0001", + "npc-0002", + "npc-0003", + "npc-0004" + ], + "party_kind": "basic", + "visibility": "referee" + }, + { + "code": "encounter.surprise.rolled", + "event_type": "surprise_rolled", + "roll": 5, + "side": "monsters", + "surprised": false, + "threshold": 2, + "visibility": "referee" + }, + { + "code": "encounter.surprise.rolled", + "event_type": "surprise_rolled", + "roll": 3, + "side": "party", + "surprised": true, + "threshold": 3, + "visibility": "referee" + }, + { + "code": "encounter.started", + "count": 4, + "distance_feet": 60, + "event_type": "encounter_started", + "group_counts": [ + 4 + ], + "group_labels": [ + "adventurer" + ], + "group_labels_plural": [ + "adventurers" + ], + "monster_name": "adventurer", + "monster_name_plural": "adventurers", + "monsters_surprised": false, + "party_surprised": true, + "visibility": "player" + }, + { + "code": "encounter.reaction.rolled", + "event_type": "reaction_rolled", + "modifier": 0, + "result": "attacks", + "roll": 2, + "total": 2, + "visibility": "referee" + }, + { + "code": "encounter.stance.changed", + "event_type": "stance_changed", + "stance": "attacks", + "visibility": "player" + }, + { + "code": "battle.started", + "event_type": "battle_started", + "visibility": "player" + }, + { + "attack_name": "Dagger", + "attacker_id": "npc-0001", + "back_stab": false, + "code": "combat.attack.hit", + "defender_ac": 9, + "defender_id": "character-0002", + "event_type": "attack_rolled", + "modifier": 0, + "natural": null, + "required": 10, + "roll": 17, + "total": 17, + "visibility": "player" + }, + { + "amount": 3, + "attacker_id": "npc-0001", + "code": "combat.damage.dealt", + "event_type": "damage_dealt", + "keys": [], + "non_regenerable": false, + "rolls": [ + 3 + ], + "target_id": "character-0002", + "visibility": "player" + }, + { + "code": "combat.state.hit_points", + "current_hp": 3, + "event_type": "hit_points_reported", + "max_hp": 6, + "target_id": "character-0002", + "visibility": "referee" + }, + { + "code": "battle.group.moved", + "distance_feet": 40, + "event_type": "group_moved", + "group_id": "group-0001", + "visibility": "player" + } + ], + "exploration": { + "alerted_areas": [], + "heard_areas": [], + "last_prepared_sleep": {}, + "noise_since_check": false, + "odometer_thirds": 0, + "provisions_day": 0, + "sleep_count": 0, + "turns_since_rest": 0, + "wandering_counter": 0 + }, + "fired_triggers": [], + "flags": {}, + "journal": [], + "ledger": { + "effects": [] + }, + "listener_state": {}, + "master_seed": 1, + "mode": "battle", + "monsters": [], + "npcs": [ + { + "alignment": "chaotic", + "carrying_treasure": false, + "class_id": "magic_user", + "conditions": [], + "current_hp": 3, + "custom_class": null, + "extra_languages": [], + "id": "npc-0001", + "inventory": { + "items": [ + { + "instance_type": "item", + "quantity": 7, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 5, + "id": "rations_standard", + "item_type": "gear", + "lot_size": 7, + "name": "Rations (standard, 7 days)", + "overrides_applied": [], + "params": { + "ration": true + } + } + }, + { + "instance_type": "item", + "quantity": 1, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 1, + "id": "waterskin", + "item_type": "gear", + "lot_size": 1, + "name": "Waterskin", + "overrides_applied": [], + "params": { + "water_container": true + } + } + }, + { + "instance_type": "item", + "quantity": 6, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d4", + "missile_ranges": null, + "qualities": [ + "melee" + ] + }, + "cost_gp": 1, + "id": "torch", + "item_type": "gear", + "lot_size": 6, + "name": "Torches (6)", + "overrides_applied": [], + "params": { + "brightness": "flame", + "burn_turns": 6, + "light_radius_feet": 30 + } + } + } + ], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [ + { + "instance_type": "item", + "quantity": 1, + "template": { + "cost_gp": 3, + "damage": "1d4", + "id": "dagger", + "item_type": "weapon", + "material": "standard", + "missile_ranges": { + "long": { + "max_feet": 30, + "min_feet": 21 + }, + "medium": { + "max_feet": 20, + "min_feet": 11 + }, + "short": { + "max_feet": 10, + "min_feet": 5 + } + }, + "name": "Dagger", + "overrides_applied": [], + "qualities": [ + "melee", + "missile" + ], + "weight_coins": 10 + } + } + ], + "worn_armour": null + }, + "level": 1, + "max_hp": 3, + "memorized_spells": [ + { + "reversed": false, + "spell_id": "floating_disc" + } + ], + "name": "Magic-User adventurer 1", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 9, + "con": 9, + "dex": 11, + "int": 12, + "str": 15, + "wis": 12 + }, + "spell_book": [ + "floating_disc" + ], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "chaotic", + "carrying_treasure": false, + "class_id": "cleric", + "conditions": [], + "current_hp": 5, + "custom_class": null, + "extra_languages": [], + "id": "npc-0002", + "inventory": { + "items": [ + { + "instance_type": "item", + "quantity": 7, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 5, + "id": "rations_standard", + "item_type": "gear", + "lot_size": 7, + "name": "Rations (standard, 7 days)", + "overrides_applied": [], + "params": { + "ration": true + } + } + }, + { + "instance_type": "item", + "quantity": 1, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 1, + "id": "waterskin", + "item_type": "gear", + "lot_size": 1, + "name": "Waterskin", + "overrides_applied": [], + "params": { + "water_container": true + } + } + }, + { + "instance_type": "item", + "quantity": 6, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d4", + "missile_ranges": null, + "qualities": [ + "melee" + ] + }, + "cost_gp": 1, + "id": "torch", + "item_type": "gear", + "lot_size": 6, + "name": "Torches (6)", + "overrides_applied": [], + "params": { + "brightness": "flame", + "burn_turns": 6, + "light_radius_feet": 30 + } + } + } + ], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": { + "instance_type": "item", + "quantity": 1, + "template": { + "ac": null, + "ac_ascending": null, + "ac_bonus": 1, + "category": null, + "cost_gp": 10, + "id": "shield", + "item_type": "armour", + "name": "Shield", + "overrides_applied": [], + "weight_coins": 100 + } + }, + "valuables": [], + "wielded": [ + { + "instance_type": "item", + "quantity": 1, + "template": { + "cost_gp": 5, + "damage": "1d6", + "id": "mace", + "item_type": "weapon", + "material": "standard", + "missile_ranges": null, + "name": "Mace", + "overrides_applied": [], + "qualities": [ + "blunt", + "melee" + ], + "weight_coins": 30 + } + } + ], + "worn_armour": { + "instance_type": "item", + "quantity": 1, + "template": { + "ac": 5, + "ac_ascending": 14, + "ac_bonus": null, + "category": "heavy", + "cost_gp": 40, + "id": "chainmail", + "item_type": "armour", + "name": "Chainmail", + "overrides_applied": [], + "weight_coins": 400 + } + } + }, + "level": 1, + "max_hp": 5, + "memorized_spells": [], + "name": "Cleric adventurer 2", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 14, + "con": 11, + "dex": 12, + "int": 13, + "str": 11, + "wis": 8 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "chaotic", + "carrying_treasure": false, + "class_id": "fighter", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "npc-0003", + "inventory": { + "items": [ + { + "instance_type": "item", + "quantity": 7, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 5, + "id": "rations_standard", + "item_type": "gear", + "lot_size": 7, + "name": "Rations (standard, 7 days)", + "overrides_applied": [], + "params": { + "ration": true + } + } + }, + { + "instance_type": "item", + "quantity": 1, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 1, + "id": "waterskin", + "item_type": "gear", + "lot_size": 1, + "name": "Waterskin", + "overrides_applied": [], + "params": { + "water_container": true + } + } + }, + { + "instance_type": "item", + "quantity": 6, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d4", + "missile_ranges": null, + "qualities": [ + "melee" + ] + }, + "cost_gp": 1, + "id": "torch", + "item_type": "gear", + "lot_size": 6, + "name": "Torches (6)", + "overrides_applied": [], + "params": { + "brightness": "flame", + "burn_turns": 6, + "light_radius_feet": 30 + } + } + } + ], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": { + "instance_type": "item", + "quantity": 1, + "template": { + "ac": null, + "ac_ascending": null, + "ac_bonus": 1, + "category": null, + "cost_gp": 10, + "id": "shield", + "item_type": "armour", + "name": "Shield", + "overrides_applied": [], + "weight_coins": 100 + } + }, + "valuables": [], + "wielded": [ + { + "instance_type": "item", + "quantity": 1, + "template": { + "cost_gp": 10, + "damage": "1d8", + "id": "sword", + "item_type": "weapon", + "material": "standard", + "missile_ranges": null, + "name": "Sword", + "overrides_applied": [], + "qualities": [ + "melee" + ], + "weight_coins": 60 + } + } + ], + "worn_armour": { + "instance_type": "item", + "quantity": 1, + "template": { + "ac": 5, + "ac_ascending": 14, + "ac_bonus": null, + "category": "heavy", + "cost_gp": 40, + "id": "chainmail", + "item_type": "armour", + "name": "Chainmail", + "overrides_applied": [], + "weight_coins": 400 + } + } + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Fighter adventurer 3", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 6, + "con": 15, + "dex": 12, + "int": 9, + "str": 8, + "wis": 5 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "chaotic", + "carrying_treasure": false, + "class_id": "fighter", + "conditions": [], + "current_hp": 8, + "custom_class": null, + "extra_languages": [], + "id": "npc-0004", + "inventory": { + "items": [ + { + "instance_type": "item", + "quantity": 7, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 5, + "id": "rations_standard", + "item_type": "gear", + "lot_size": 7, + "name": "Rations (standard, 7 days)", + "overrides_applied": [], + "params": { + "ration": true + } + } + }, + { + "instance_type": "item", + "quantity": 1, + "template": { + "capacity_coins": null, + "combat": null, + "cost_gp": 1, + "id": "waterskin", + "item_type": "gear", + "lot_size": 1, + "name": "Waterskin", + "overrides_applied": [], + "params": { + "water_container": true + } + } + }, + { + "instance_type": "item", + "quantity": 6, + "template": { + "capacity_coins": null, + "combat": { + "damage": "1d4", + "missile_ranges": null, + "qualities": [ + "melee" + ] + }, + "cost_gp": 1, + "id": "torch", + "item_type": "gear", + "lot_size": 6, + "name": "Torches (6)", + "overrides_applied": [], + "params": { + "brightness": "flame", + "burn_turns": 6, + "light_radius_feet": 30 + } + } + } + ], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": { + "instance_type": "item", + "quantity": 1, + "template": { + "ac": null, + "ac_ascending": null, + "ac_bonus": 1, + "category": null, + "cost_gp": 10, + "id": "shield", + "item_type": "armour", + "name": "Shield", + "overrides_applied": [], + "weight_coins": 100 + } + }, + "valuables": [], + "wielded": [ + { + "instance_type": "item", + "quantity": 1, + "template": { + "cost_gp": 10, + "damage": "1d8", + "id": "sword", + "item_type": "weapon", + "material": "standard", + "missile_ranges": null, + "name": "Sword", + "overrides_applied": [], + "qualities": [ + "melee" + ], + "weight_coins": 60 + } + } + ], + "worn_armour": { + "instance_type": "item", + "quantity": 1, + "template": { + "ac": 5, + "ac_ascending": 14, + "ac_bonus": null, + "category": "heavy", + "cost_gp": 40, + "id": "chainmail", + "item_type": "armour", + "name": "Chainmail", + "overrides_applied": [], + "weight_coins": 400 + } + } + }, + "level": 2, + "max_hp": 8, + "memorized_spells": [], + "name": "Fighter adventurer 4", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 12, + "con": 7, + "dex": 11, + "int": 8, + "str": 16, + "wis": 9 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 2000 + } + ], + "party": { + "members": [ + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "fighter", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0001", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Brakk", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "thief", + "conditions": [], + "current_hp": 3, + "custom_class": null, + "extra_languages": [], + "id": "character-0002", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Sable", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "cleric", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0003", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Wynn", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 13 + }, + "spell_book": [], + "stat_modifiers": [], + "xp": 0 + }, + { + "alignment": "lawful", + "carrying_treasure": false, + "class_id": "magic_user", + "conditions": [], + "current_hp": 6, + "custom_class": null, + "extra_languages": [], + "id": "character-0004", + "inventory": { + "items": [], + "purse": { + "cp": 0, + "ep": 0, + "gp": 0, + "pp": 0, + "sp": 0 + }, + "rings": [], + "shield": null, + "valuables": [], + "wielded": [], + "worn_armour": null + }, + "level": 1, + "max_hp": 6, + "memorized_spells": [], + "name": "Elara", + "nonregen_damage": 0, + "race": "human", + "scores": { + "cha": 11, + "con": 11, + "dex": 11, + "int": 11, + "str": 11, + "wis": 11 + }, + "spell_book": [ + "sleep" + ], + "stat_modifiers": [], + "xp": 0 + } + ] + }, + "quests": {}, + "rng_streams": { + "combat": { + "inc": 51974326853383236054174564158459888819, + "state": 180795397024793254201627794445874276412 + }, + "effects": { + "inc": 283453162651363138174751306997233822321, + "state": 82950419690610286897458899398562272993 + }, + "encounter": { + "inc": 89959186405662357923881332541411655931, + "state": 245600835435001370040161073915762547766 + }, + "monster_action": { + "inc": 216485260068944084833976769572152741595, + "state": 316252631387065876105645382272260252652 + }, + "npc_party": { + "inc": 6905548725317423460208538633085511011, + "state": 167557780833365036580802211511327935853 + }, + "treasure": { + "inc": 55149374389624700722747444595030452821, + "state": 119070280199547008720396439384068395895 + } + }, + "ruleset": { + "aoe_friendly_fire": true, + "back_stab_needs_both_skills": true, + "deprivation_penalties": false, + "encumbrance": "basic", + "failed_trap_removal_springs": true, + "formation_width_limit": true, + "hd5_counts_as_magical": false, + "hp_reroll_at_first_level": false, + "individual_initiative": false, + "magic_item_death_save": true, + "thac0_arithmetic": false, + "variable_weapon_damage": true, + "weapon_reload": false, + "xp_award_timing": "on_return" + }, + "treasure_snapshot_cp": 0 + }, + "schema_version": 4 +} diff --git a/tests/test_embedded_item_names.py b/tests/test_embedded_item_names.py new file mode 100644 index 00000000..6c5534dd --- /dev/null +++ b/tests/test_embedded_item_names.py @@ -0,0 +1,278 @@ +"""An embedded item template takes its display names from the session's catalog (issue #316, part 3). + +An `ItemInstance` embeds its whole template, and `MemberView.inventory`, the referee view, and a save dump it whole. +A save or a party document that osrlib 2.7.0 wrote embeds templates without `display_name` and +`display_name_plural`, so validation gives them the defaults from the price-list `name`: "Holy water (vial)" where a +new session has "vial of holy water". The session gives every embedded template whose id its catalog has the +catalog template's two names, when it starts, when a save loads, and when `AddMember` adds a member. Nothing else in +the template changes, because the rest is rules data that travels with the character. A template whose id the +catalog lacks keeps the names it has. + +`tests/test_view_features.py::test_a_save_written_by_2_7_0_loads_with_the_new_fields` is the guard from another +chunk: the player view of a loaded 2.7.0 save equals the view of the same state built fresh. +""" + +import json +from pathlib import Path + +import pytest +from pydantic import TypeAdapter + +from crawl_fixtures import build_party +from osrlib.core.character import Character, party_from_document +from osrlib.core.events import Visibility +from osrlib.core.items import GearTemplate, ItemInstance, ItemTemplate +from osrlib.crawl.adventure import Adventure, TownSpec +from osrlib.crawl.commands import AddMember, GrantItem +from osrlib.crawl.dungeon import DungeonSpec, LevelSpec +from osrlib.crawl.party import Party +from osrlib.crawl.session import GameSession +from osrlib.crawl.views import PlayerView, RefereeView +from osrlib.data import load_equipment +from osrlib.persistence import load_game, save_game +from test_view_item_names import CATALOG_NAMES, PARTY_2_7_0, SAVE_2_7_0, UNNAMED_IDOL, _adventure, _embedded_templates + +XFAIL = pytest.mark.xfail(reason="chunk: view-item-names") + +NPCS_2_7_0 = Path(__file__).parent / "saves" / "view_item_names_npcs_2.7.0.json" +"""A save that osrlib 2.7.0 wrote, kept as it wrote it, in which a basic NPC party of four has attacked the party. + +The NPCs carry chainmail, a dagger, a mace, standard rations, a shield, a sword, torches, and a waterskin, each +embedding a template with no display names. +""" + +WRITTEN_IDOL = ("idol of the drowned saint", "idols of the drowned saint") +"""The names `_adventure()`'s bundled idol has, which its author wrote.""" + +CARRIED_IN_SAVE = ("holy_water", "torch", "arrows", "short_bow", "chainmail", "sword", "temple_idol") +"""The stacks the fighter carries in the 2.7.0 save. The two flasks of oil lie in the pile.""" + +TEMPLATE = TypeAdapter(ItemTemplate) +NAME_FIELDS = ("display_name", "display_name_plural") + + +def _load(path: Path) -> GameSession: + return load_game(json.loads(path.read_text(encoding="utf-8"))) + + +def _party_from_2_7_0() -> Party: + return Party(members=party_from_document(json.loads(PARTY_2_7_0.read_text(encoding="utf-8")))) + + +def _empty_crypt() -> Adventure: + """An adventure that bundles nothing, so its catalog has no `temple_idol`.""" + level = LevelSpec(number=1, width=1, height=1, entrance=(0, 0)) + return Adventure( + name="An Empty Crypt", + town=TownSpec(name="Threshold"), + dungeons=(DungeonSpec(id="crypt", name="Crypt", levels=(level,)),), + ) + + +def _names(templates) -> dict[str, tuple[str, str]]: + """Each template's id with its two names, from dumped templates. A repeated id must have the same names.""" + names: dict[str, tuple[str, str]] = {} + for template in templates: + pair = (template["display_name"], template["display_name_plural"]) + assert names.setdefault(template["id"], pair) == pair, template["id"] + return names + + +def _player_templates(view: PlayerView) -> list[dict]: + return [template for member in view.party for template in _embedded_templates(member.inventory)] + + +def _referee_templates(view: RefereeView) -> list[dict]: + members = [*view.party.members, *view.npcs] + return [ + template for member in members for template in _embedded_templates(member.inventory.model_dump(mode="json")) + ] + + +def _without_names(templates: list[dict]) -> list[str]: + """The templates without their names, as sorted JSON, so the order a document walks them in doesn't matter. + + The names are the two fields and the entries of `overrides_applied` that name them, which record that the + compiler took a name from `tools/srd_compile/overrides/`. Those entries describe the names, so they travel with + them: a fresh session's torch has them, and a torch loaded from 2.7.0 must have the same view. + """ + stripped = [] + for template in templates: + kept = {key: value for key, value in template.items() if key not in NAME_FIELDS} + kept["overrides_applied"] = [entry for entry in template["overrides_applied"] if entry not in NAME_FIELDS] + stripped.append(kept) + return sorted(json.dumps(template, sort_keys=True) for template in stripped) + + +# ---------------------------------------------------------------------- a 2.7.0 save + + +@XFAIL +def test_a_2_7_0_save_embeds_the_catalogs_names_in_every_carried_stack(): + """The inventory dump, the referee view, and the next save all carry the catalog's names. + + The save's adventure bundles the idol with no names, so the catalog's idol has the defaults, and the carried idol + takes those. + """ + game = _load(SAVE_2_7_0) + expected = {item_id: CATALOG_NAMES.get(item_id, UNNAMED_IDOL) for item_id in CARRIED_IN_SAVE} + + player = game.view(Visibility.PLAYER) + referee = game.view(Visibility.REFEREE) + assert isinstance(player, PlayerView) and isinstance(referee, RefereeView) + + assert _names(_player_templates(player)) == expected + assert _names(_referee_templates(referee)) == expected + assert _names(_embedded_templates(save_game(game))) == expected + + +@XFAIL +def test_a_2_7_0_save_gives_npc_adventurers_the_catalogs_names(): + """An NPC's gear is in the referee view and the save, and it takes the catalog's names too.""" + game = _load(NPCS_2_7_0) + catalog = load_equipment() + + referee = game.view(Visibility.REFEREE) + assert isinstance(referee, RefereeView) + + npc_templates = [ + template for npc in referee.npcs for template in _embedded_templates(npc.inventory.model_dump(mode="json")) + ] + names = _names(npc_templates) + assert set(names) == {"chainmail", "dagger", "mace", "rations_standard", "shield", "sword", "torch", "waterskin"} + assert names == { + item_id: (catalog.get(item_id).display_name, catalog.get(item_id).display_name_plural) for item_id in names + } + assert names["torch"] == ("torch", "torches") + assert names["rations_standard"] == ("standard ration", "standard rations") + assert _names(_embedded_templates(save_game(game)["payload"]["npcs"])) == names + + +@pytest.mark.parametrize( + "path", + [pytest.param(SAVE_2_7_0, id="party", marks=XFAIL), pytest.param(NPCS_2_7_0, id="npcs", marks=XFAIL)], +) +def test_loading_a_2_7_0_save_changes_only_the_two_names_of_an_embedded_template(path: Path): + """Every embedded template, read as this osrlib reads it, is the same before and after but for its names.""" + document = json.loads(path.read_text(encoding="utf-8")) + before = [TEMPLATE.validate_python(template).model_dump(mode="json") for template in _embedded_templates(document)] + + after = _embedded_templates(save_game(load_game(document))) + + assert len(after) == len(before) + assert _without_names(after) == _without_names(before) + assert _names(after) != _names(before) + + +def test_loading_a_2_7_0_save_draws_nothing_and_keeps_the_logs(): + """The names are no rule and no draw: the streams, the command log, and the event log come back as they were.""" + document = json.loads(SAVE_2_7_0.read_text(encoding="utf-8")) + + again = save_game(load_game(document))["payload"] + + for key in ("rng_streams", "command_log", "event_log", "clock_rounds", "allocator"): + assert again[key] == document["payload"][key], key + + +# ---------------------------------------------------------------------- a 2.7.0 party document + + +@XFAIL +def test_a_2_7_0_party_document_takes_the_adventures_names_for_its_bundled_item(): + """A new session of an adventure whose idol has written names: the carried idol takes them.""" + game = GameSession.new(_party_from_2_7_0(), _adventure(), seed=5) + expected = {**CATALOG_NAMES, "temple_idol": WRITTEN_IDOL} + + player = game.view(Visibility.PLAYER) + assert isinstance(player, PlayerView) + + assert _names(_player_templates(player)) == expected + assert _names(_embedded_templates(save_game(game)["payload"]["party"])) == expected + + +@XFAIL +def test_a_2_7_0_party_documents_bundled_item_keeps_its_names_without_the_adventure(): + """The same party in an adventure that bundles no idol: the idol keeps the defaults its template has.""" + game = GameSession.new(_party_from_2_7_0(), _empty_crypt(), seed=5) + + player = game.view(Visibility.PLAYER) + assert isinstance(player, PlayerView) + + assert _names(_player_templates(player)) == {**CATALOG_NAMES, "temple_idol": UNNAMED_IDOL} + + +@XFAIL +def test_a_new_session_changes_only_the_names_of_a_template_the_catalog_has(): + """A torch of the fighter's own, with the catalog's id but its own rules data, keeps all but its names.""" + party = build_party() + old_torch = GearTemplate.model_validate( + { + "id": "torch", + "name": "Old torch", + "cost_gp": 3, + "params": {"burn_turns": 2, "light_radius_feet": 10}, + "display_name": "old torch", + "display_name_plural": "old torches", + } + ) + party.members[0].inventory.items.append(ItemInstance(template=old_torch, quantity=2)) + + game = GameSession.new(party, _empty_crypt(), seed=5) + + (stack,) = game.party.members[0].inventory.items + assert isinstance(stack, ItemInstance) + assert (stack.template.display_name, stack.template.display_name_plural) == ("torch", "torches") + assert _without_names([stack.template.model_dump(mode="json")]) == _without_names( + [old_torch.model_dump(mode="json")] + ) + catalog_torch = load_equipment().get("torch") + assert stack.template.overrides_applied == tuple( + entry for entry in catalog_torch.overrides_applied if entry in NAME_FIELDS + ) + assert stack.quantity == 2 + + +@XFAIL +def test_a_member_added_from_a_2_7_0_document_takes_the_catalogs_names(): + """`AddMember` with the 2.7.0 fighter, given no id and none of the magic items a joining member can't carry. + + The member who joins has the catalog's names, and the command log keeps the character as it arrived. + """ + document = json.loads(PARTY_2_7_0.read_text(encoding="utf-8")) + fighter = next(member for member in document["payload"]["characters"] if member["id"] == "character-0001") + fighter = {**fighter, "id": None} + fighter["inventory"]["items"] = [ + entry for entry in fighter["inventory"]["items"] if entry["instance_type"] != "magic_item" + ] + game = GameSession.new(build_party(), _adventure(), seed=5) + + added = game.execute(AddMember(character=Character.model_validate(fighter))) + assert added.accepted, [rejection.code for rejection in added.rejections] + + joined = game.party.members[-1] + templates = _embedded_templates(joined.inventory.model_dump(mode="json")) + assert _names(templates) == {**CATALOG_NAMES, "temple_idol": WRITTEN_IDOL} + logged = _embedded_templates(game.command_log[-1].character.inventory.model_dump(mode="json")) + assert _names(logged)["holy_water"][0] == "Holy water (vial)" + + +# ---------------------------------------------------------------------- a save this osrlib writes + + +def test_a_save_written_now_loads_to_the_same_save(): + """A session of current documents, a bundled item and a torch of the fighter's own included, re-saves unchanged. + + This holds before the chunk's change too, and it must keep holding after it. + """ + party = build_party() + party.members[0].inventory.items.append( + ItemInstance( + template=GearTemplate.model_validate({"id": "torch", "name": "Old torch", "cost_gp": 3}), quantity=2 + ) + ) + game = GameSession.new(party, _adventure(), seed=5) + for item_id in ("holy_water", "chainmail", "arrows", "temple_idol", "potion_of_healing"): + assert game.execute(GrantItem(character_id="character-0001", item_id=item_id)).accepted + document = json.loads(json.dumps(save_game(game))) + + assert json.loads(json.dumps(save_game(load_game(document)))) == document From 18a05eece5d4251f4ec5cbafdec8a520be41350f Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 21:04:16 -0800 Subject: [PATCH 12/14] Give embedded item templates the catalog's display names 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 --- src/osrlib/crawl/session.py | 42 +++++++++++++++++++++++++++++++++++++ src/osrlib/crawl/views.py | 12 +++++------ src/osrlib/persistence.py | 3 +++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/osrlib/crawl/session.py b/src/osrlib/crawl/session.py index 754f7beb..0403ebd9 100644 --- a/src/osrlib/crawl/session.py +++ b/src/osrlib/crawl/session.py @@ -444,6 +444,45 @@ def worst(self) -> int: return max(self.food_days, self.water_days) +_ITEM_NAME_FIELDS = ("display_name", "display_name_plural") + + +def _take_catalog_item_names(catalog: EquipmentCatalog, character: Character) -> None: + """Give each item template the character's stacks embed the display names of the catalog's template with its id. + + A save or a party document from osrlib 2.7.0 embeds templates without display names, so each one validated with + the defaults from its price-list `name`. The two names come from the catalog, with the entries of + `overrides_applied` that name them, which record where the names came from. The rest of the template is rules data + that travels with the character and doesn't change, and a template whose id the catalog lacks keeps its names. + The call draws nothing, and calling it again changes nothing. + """ + templates = { + template.id: template for template in (*catalog.weapons, *catalog.armour, *catalog.gear, *catalog.ammunition) + } + for instance in character.inventory.all_instances(): + if not isinstance(instance, ItemInstance): + continue + source = templates.get(instance.template.id) + if source is None: + continue + embedded = instance.template + kept = tuple(entry for entry in embedded.overrides_applied if entry not in _ITEM_NAME_FIELDS) + overrides = (*kept, *(entry for entry in source.overrides_applied if entry in _ITEM_NAME_FIELDS)) + unchanged = ( + embedded.display_name == source.display_name + and embedded.display_name_plural == source.display_name_plural + and set(embedded.overrides_applied) == set(overrides) + ) + if not unchanged: + instance.template = embedded.model_copy( + update={ + "display_name": source.display_name, + "display_name_plural": source.display_name_plural, + "overrides_applied": overrides, + } + ) + + def _member_id(member: Character) -> str: """Return a member's session id, which every member in a session has.""" if member.id is None: @@ -680,6 +719,8 @@ def __init__( if lines := item_conflicts.lines("item"): raise ContentValidationError("adventure bundles colliding item ids:\n" + "\n".join(lines)) self._equipment_catalog = equipment + for member in party.members: + _take_catalog_item_names(equipment, member) spells, spell_conflicts = _effective_spells(adventure, load_spells()) if lines := spell_conflicts.lines("spell"): raise ContentValidationError("adventure bundles colliding spell ids:\n" + "\n".join(lines)) @@ -2461,6 +2502,7 @@ def _handle_add_member(session: GameSession, command: AddMember) -> tuple[list[R return [Rejection(code="party.add.carries_instances", params={"name": character.name, "item": carried[0]})], [] # The command keeps the character as it arrived, so the log replays the same addition. member = character.model_copy(deep=True) + _take_catalog_item_names(session.effective_equipment, member) taken = {existing.id for existing in session.party.members} member.id = session.allocator.allocate("character") while member.id in taken: diff --git a/src/osrlib/crawl/views.py b/src/osrlib/crawl/views.py index f854acd3..b69d44a1 100644 --- a/src/osrlib/crawl/views.py +++ b/src/osrlib/crawl/views.py @@ -1665,11 +1665,10 @@ def _pile_view(pile: DropPile) -> PileView: def _item_names(session, piles: Iterable[DropPile]) -> tuple[dict[str, str], dict[str, str]]: # Each id the inventories and the known piles show gets one entry, from the first place it appears. A - # mundane stack is named from the session's catalog, which has the items the adventure bundles, because a - # stack from a 2.7.0 save or party document embeds a template without display names. Only a carried stack - # whose id the catalog lacks is named from the template it embeds. An unidentified magic item keeps its - # mask, and a template id is a key only for an identified item a member carries, because a pile shows a - # magic item by its instance id alone. + # carried stack is named from the template it embeds, which the session gave the catalog's names, and a + # pile's stack from the session's catalog, which has the items the adventure bundles. An unidentified magic + # item keeps its mask, and a template id is a key only for an identified item a member carries, because a + # pile shows a magic item by its instance id alone. names: dict[str, str] = {} plurals: dict[str, str] = {} equipment = session.effective_equipment @@ -1697,8 +1696,7 @@ def add_magic_item(instance: MagicItemInstance, *, carried: bool) -> None: if isinstance(instance, MagicItemInstance): add_magic_item(instance, carried=True) else: - template = catalog.get(instance.template.id, instance.template) - add(template.id, template.display_name, template.display_name_plural) + add(instance.template.id, instance.template.display_name, instance.template.display_name_plural) for valuable in member.inventory.valuables: add(valuable.instance_id, *_VALUABLE_NAMES[valuable.kind]) for pile in piles: diff --git a/src/osrlib/persistence.py b/src/osrlib/persistence.py index 0dad1023..19a3c383 100644 --- a/src/osrlib/persistence.py +++ b/src/osrlib/persistence.py @@ -128,6 +128,7 @@ GameSession, JournalEntry, QuestState, + _take_catalog_item_names, ) from osrlib.errors import ContentValidationError, ReplayVersionError from osrlib.versioning import SCHEMA_VERSION, check_document, engine_version, stamp_document @@ -556,6 +557,8 @@ def load_game(document: Mapping[str, object]) -> GameSession: if npc.id is None: raise ContentValidationError("an NPC in the save carries no id") session.npcs[npc.id] = npc + for npc in session.npcs.values(): + _take_catalog_item_names(session.effective_equipment, npc) session.flags = dict(payload["flags"]) # Both blocks are newer than schema version 3 and load with empty defaults, so an # older save restores unchanged, and the session records them from then on. From 4c19fa53986db4ce0c772b9fe0397a8d1fdc10f1 Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 21:04:16 -0800 Subject: [PATCH 13/14] Document the catalog names that embedded templates take 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 --- CHANGELOG.md | 1 + docs/guides/views-and-visibility.md | 2 +- docs/spec.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddc184f7..8ccfa332 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] and [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] name every item whose id the view shows, keyed by that id: a mundane stack's catalog id, and a magic item's or a valuable's instance id, in a member's inventory or a known pile (#316). A mundane stack, carried or in a pile, is named from the session's catalog, [`GameSession.effective_equipment`][osrlib.crawl.session.GameSession.effective_equipment], so an item the adventure bundles is named, and a stack from a 2.7.0 save or party document, which embeds a template without display names, is named as a new stack is. A carried stack whose id the catalog lacks, such as an item another adventure bundled, is named from the template it embeds. An unidentified magic item is named by its masked name without the article, like `"potion"` or `"shield with a faint aura"`, so a cursed item has the names of the item it passes for, and the view never includes its template id. An identified item is named by its template's display names, under its instance id, and under its template id while a member carries it, because a pile shows a magic item by its instance id alone. A gem is `"gem"` and a piece of jewellery `"piece of jewellery"`. Before, a client with only the view and the events couldn't word "The party finds 2 vials of holy water". - [`PileView.contents`][osrlib.crawl.views.PileView.contents] gives each thing in a pile as a [`PileItemView`][osrlib.crawl.views.PileItemView], with the id that the events use for it and its count, in the order of `items` (#316). A client reads `"holy_water"` and 2 there where `items` has `"holy_water×2"`. `items` doesn't change. - [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] has two new fields, `display_name` and `display_name_plural`, the identified item's display names, like `"potion of healing"` (#316). A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, but the event does. An event recorded before this release has empty names. Every field this release adds has a default, so a 2.7.0 save, view, or event still parses, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. +- The gear in a save or a party document that osrlib 2.7.0 wrote takes the display names of the session's catalog (#316). Its embedded templates have no display names, so they validate with the defaults from the price-list `name`, like `"Holy water (vial)"`. When a session starts, when [`load_game`][osrlib.persistence.load_game] restores one, and when [`AddMember`][osrlib.crawl.commands.AddMember] adds a member, each template that a party member's or an NPC adventurer's stack embeds takes 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. So holy water from a 2.7.0 save reads `"vial of holy water"` in `MemberView.inventory`, in the referee view, and in [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names], and the next save writes those names. Nothing else in the template changes, a template whose id the catalog lacks keeps its names, `AddMember`'s logged character keeps the templates it arrived with, and loading a save draws nothing. ### Fixed diff --git a/docs/guides/views-and-visibility.md b/docs/guides/views-and-visibility.md index 3f963209..01f90cf0 100644 --- a/docs/guides/views-and-visibility.md +++ b/docs/guides/views-and-visibility.md @@ -34,7 +34,7 @@ Each party member appears in `PlayerView.party` as a [`MemberView`][osrlib.crawl A member's spell book and memorized spells name each spell by id, and so does the `kind` of a spell's effect in `PlayerView.effects`. Show the names in [`PlayerView.spell_names`][osrlib.crawl.views.PlayerView.spell_names], keyed by those ids, and the names of reversed forms, like *darkness* for *light*, in [`PlayerView.reversed_spell_names`][osrlib.crawl.views.PlayerView.reversed_spell_names]. The view reads both from the session's catalog, so a spell the adventure bundles has its name there too. Neither includes a spell that is absent from the rest of the view, like one on a scroll. -Items work the same way. An inventory identifies a mundane stack by its template's catalog id, like `"holy_water"`, and a magic item or a gem or piece of jewellery by its instance id, like `"magic-item-0003"`, and the item events use the same ids. Show the names in [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names], a noun phrase for one with no article, like `"vial of holy water"`, and in [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] for a count, so you can word "The party finds 2 vials of holy water". Both have a key for each item id that the inventories and the known piles show, and only for those ids. A mundane stack, carried or in a pile, is named from the session's catalog, so an item the adventure bundles has its name there too, and a stack from a 2.7.0 save, which embeds a template without display names, is named as a new stack is. A carried stack whose id the catalog lacks, such as an item another adventure bundled, is named from the template it embeds. A valuable is named by its kind, `"gem"` or `"piece of jewellery"`, whereas the inventory's `valuables` contain the piece's name and value. A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, and the [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] contains its names instead. +Items work the same way. An inventory identifies a mundane stack by its template's catalog id, like `"holy_water"`, and a magic item or a gem or piece of jewellery by its instance id, like `"magic-item-0003"`, and the item events use the same ids. Show the names in [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names], a noun phrase for one with no article, like `"vial of holy water"`, and in [`PlayerView.item_names_plural`][osrlib.crawl.views.PlayerView.item_names_plural] for a count, so you can word "The party finds 2 vials of holy water". Both have a key for each item id that the inventories and the known piles show, and only for those ids. A mundane stack, carried or in a pile, is named as the session's catalog names it, so an item the adventure bundles has its name there too. The session gives the template each carried stack embeds the catalog's display names when it starts, when a save loads, and when [`AddMember`][osrlib.crawl.commands.AddMember] adds a member, so a stack from a 2.7.0 save, whose template has no display names, shows the catalog's names in `inventory` too, and the next save writes them. A carried stack whose id the catalog lacks, such as an item another adventure bundled, keeps the names its template has. A valuable is named by its kind, `"gem"` or `"piece of jewellery"`, whereas the inventory's `valuables` contain the piece's name and value. A potion drunk before the party knew what it was is identified and used up in one command, so no view contains its name, and the [`ItemIdentifiedEvent`][osrlib.crawl.events.ItemIdentifiedEvent] contains its names instead. Derived combat and exploration stats include bonuses from worn equipment (such as armour, a shield, or a ring of protection), even before the party identifies a magic item: diff --git a/docs/spec.md b/docs/spec.md index 24560263..057e444b 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -127,7 +127,7 @@ for event in result.events: view = session.view(Visibility.PLAYER) ``` -The player view is a safe projection: party status, explored map cells, entered dungeons and areas, known features and transitions, known active effects, active quests (id, name, display narrative with the block's speaker attribution beside it, since a wire client holds no adventure document to resolve one from, and visible objectives with their ids, display names, and states), and the journal. When areas overlap, the first area in `LevelSpec.areas` owns a shared cell, matching `LevelSpec.area_at`. An area enters only when the party walks an owned cell. An entered area exposes its authored id, name, description, only those owned cells the party walked, and the `trap_state` of its room trap once the party has found or sprung it, so a room whose trap the party hasn't met looks the same as a room without one. A `MapFeatureView` exposes a stable `feature:` handle, public kind, description, safe location, a `trap_state` limited to `"found"`, `"sprung"`, or `"removed"`, and `emptied`, true for an authored treasure cache the party has emptied, which stays listed under its handle. A feature's `area_id` names the entered area that lists it, or for a generated cache the entered area that owns its cell, and never an area the party hasn't entered. The handle is HMAC-SHA-256 over a length-prefixed tuple of dungeon id, level number, and authored feature id or generated cache key, with separate domains for those two identity types. Individual dungeon, area, and feature ids may contain colons. Validation requires every canonical `"{dungeon}:{level}:{id}"` area and feature reference to occur once, so repeated definitions and colon-delimited component collisions both fail. New sessions and loaded saves fail closed before they can use ambiguous state. A server adapter supplies an independent key of at least 32 bytes. Omitting the key derives a deterministic pseudonym from the master seed, which is not confidential from someone who knows or can guess that seed. A generated lair cache appears only after the party resolves its keyed encounter. Feature commands resolve only current-location authored features and available generated caches. `PlayerView.features_here` lists the handles of the treasure caches among those candidates, from the same resolution the commands run, and is empty unless the mode is exploring. An ambiguous legacy raw id rejects, and an id that starts with `feature:` never falls back to a raw id. A feature with no trap and a cache with an unfound trap give the same `exploration.feature.unknown` response to trap removal. The map feature list never exposes a raw internal id. `PlayerView.emptied_caches` retains its existing fully qualified raw references, and a client reads `MapFeatureView.emptied` to tell which listed cache is emptied. `PlayerView.can_travel_to_town` is true only while the mode is exploring, the current level has an entrance, and the party stands on it. The player view names every item id it shows, a mundane stack's catalog id and a magic item's or valuable's instance id, in `item_names` and `item_names_plural`, read from the session's catalog, or from the template a stack embeds when the catalog lacks its id, and a pile lists each thing's id and count in `PileView.contents`. An unidentified magic item is named by its category mask or its base, like "potion" or "arrow with a faint aura", never by its true name or template id, and a valuable by its kind. The player view never contains unexplored geometry, cache contents, hidden trap or construction data, a transition destination or gate, monster HP, referee-only roll outcomes, session flags, hidden objectives, gate or trigger wiring, the player-handle key, or the master seed. +The player view is a safe projection: party status, explored map cells, entered dungeons and areas, known features and transitions, known active effects, active quests (id, name, display narrative with the block's speaker attribution beside it, since a wire client holds no adventure document to resolve one from, and visible objectives with their ids, display names, and states), and the journal. When areas overlap, the first area in `LevelSpec.areas` owns a shared cell, matching `LevelSpec.area_at`. An area enters only when the party walks an owned cell. An entered area exposes its authored id, name, description, only those owned cells the party walked, and the `trap_state` of its room trap once the party has found or sprung it, so a room whose trap the party hasn't met looks the same as a room without one. A `MapFeatureView` exposes a stable `feature:` handle, public kind, description, safe location, a `trap_state` limited to `"found"`, `"sprung"`, or `"removed"`, and `emptied`, true for an authored treasure cache the party has emptied, which stays listed under its handle. A feature's `area_id` names the entered area that lists it, or for a generated cache the entered area that owns its cell, and never an area the party hasn't entered. The handle is HMAC-SHA-256 over a length-prefixed tuple of dungeon id, level number, and authored feature id or generated cache key, with separate domains for those two identity types. Individual dungeon, area, and feature ids may contain colons. Validation requires every canonical `"{dungeon}:{level}:{id}"` area and feature reference to occur once, so repeated definitions and colon-delimited component collisions both fail. New sessions and loaded saves fail closed before they can use ambiguous state. A server adapter supplies an independent key of at least 32 bytes. Omitting the key derives a deterministic pseudonym from the master seed, which is not confidential from someone who knows or can guess that seed. A generated lair cache appears only after the party resolves its keyed encounter. Feature commands resolve only current-location authored features and available generated caches. `PlayerView.features_here` lists the handles of the treasure caches among those candidates, from the same resolution the commands run, and is empty unless the mode is exploring. An ambiguous legacy raw id rejects, and an id that starts with `feature:` never falls back to a raw id. A feature with no trap and a cache with an unfound trap give the same `exploration.feature.unknown` response to trap removal. The map feature list never exposes a raw internal id. `PlayerView.emptied_caches` retains its existing fully qualified raw references, and a client reads `MapFeatureView.emptied` to tell which listed cache is emptied. `PlayerView.can_travel_to_town` is true only while the mode is exploring, the current level has an entrance, and the party stands on it. The player view names every item id it shows, a mundane stack's catalog id and a magic item's or valuable's instance id, in `item_names` and `item_names_plural`, read from the template a carried stack embeds, which the session gives the catalog's display names when it starts, loads a save, or adds a member, and from the session's catalog for a pile, and a pile lists each thing's id and count in `PileView.contents`. An unidentified magic item is named by its category mask or its base, like "potion" or "arrow with a faint aura", never by its true name or template id, and a valuable by its kind. The player view never contains unexplored geometry, cache contents, hidden trap or construction data, a transition destination or gate, monster HP, referee-only roll outcomes, session flags, hidden objectives, gate or trigger wiring, the player-handle key, or the master seed. Generated caches record whether they came from an area, a lair, or a legacy save with no provenance. A legacy cache stays hidden and refuses commands when any keyed encounter in an area containing its parsed cell remains unresolved. Malformed or unresolvable legacy cell references fail closed. After resolution establishes safety, the old cache becomes available. From 3a6204728cf96c0f54fa572d1c5810252902a4dc Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 25 Nov 2026 21:07:00 -0800 Subject: [PATCH 14/14] Remove the expected-to-fail markers from the embedded item name tests The implementation is in, so the tests run as ordinary tests. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3 --- tests/test_embedded_item_names.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/test_embedded_item_names.py b/tests/test_embedded_item_names.py index 6c5534dd..4a559e17 100644 --- a/tests/test_embedded_item_names.py +++ b/tests/test_embedded_item_names.py @@ -32,8 +32,6 @@ from osrlib.persistence import load_game, save_game from test_view_item_names import CATALOG_NAMES, PARTY_2_7_0, SAVE_2_7_0, UNNAMED_IDOL, _adventure, _embedded_templates -XFAIL = pytest.mark.xfail(reason="chunk: view-item-names") - NPCS_2_7_0 = Path(__file__).parent / "saves" / "view_item_names_npcs_2.7.0.json" """A save that osrlib 2.7.0 wrote, kept as it wrote it, in which a basic NPC party of four has attacked the party. @@ -107,7 +105,6 @@ def _without_names(templates: list[dict]) -> list[str]: # ---------------------------------------------------------------------- a 2.7.0 save -@XFAIL def test_a_2_7_0_save_embeds_the_catalogs_names_in_every_carried_stack(): """The inventory dump, the referee view, and the next save all carry the catalog's names. @@ -126,7 +123,6 @@ def test_a_2_7_0_save_embeds_the_catalogs_names_in_every_carried_stack(): assert _names(_embedded_templates(save_game(game))) == expected -@XFAIL def test_a_2_7_0_save_gives_npc_adventurers_the_catalogs_names(): """An NPC's gear is in the referee view and the save, and it takes the catalog's names too.""" game = _load(NPCS_2_7_0) @@ -150,7 +146,7 @@ def test_a_2_7_0_save_gives_npc_adventurers_the_catalogs_names(): @pytest.mark.parametrize( "path", - [pytest.param(SAVE_2_7_0, id="party", marks=XFAIL), pytest.param(NPCS_2_7_0, id="npcs", marks=XFAIL)], + [pytest.param(SAVE_2_7_0, id="party"), pytest.param(NPCS_2_7_0, id="npcs")], ) def test_loading_a_2_7_0_save_changes_only_the_two_names_of_an_embedded_template(path: Path): """Every embedded template, read as this osrlib reads it, is the same before and after but for its names.""" @@ -177,7 +173,6 @@ def test_loading_a_2_7_0_save_draws_nothing_and_keeps_the_logs(): # ---------------------------------------------------------------------- a 2.7.0 party document -@XFAIL def test_a_2_7_0_party_document_takes_the_adventures_names_for_its_bundled_item(): """A new session of an adventure whose idol has written names: the carried idol takes them.""" game = GameSession.new(_party_from_2_7_0(), _adventure(), seed=5) @@ -190,7 +185,6 @@ def test_a_2_7_0_party_document_takes_the_adventures_names_for_its_bundled_item( assert _names(_embedded_templates(save_game(game)["payload"]["party"])) == expected -@XFAIL def test_a_2_7_0_party_documents_bundled_item_keeps_its_names_without_the_adventure(): """The same party in an adventure that bundles no idol: the idol keeps the defaults its template has.""" game = GameSession.new(_party_from_2_7_0(), _empty_crypt(), seed=5) @@ -201,7 +195,6 @@ def test_a_2_7_0_party_documents_bundled_item_keeps_its_names_without_the_advent assert _names(_player_templates(player)) == {**CATALOG_NAMES, "temple_idol": UNNAMED_IDOL} -@XFAIL def test_a_new_session_changes_only_the_names_of_a_template_the_catalog_has(): """A torch of the fighter's own, with the catalog's id but its own rules data, keeps all but its names.""" party = build_party() @@ -232,7 +225,6 @@ def test_a_new_session_changes_only_the_names_of_a_template_the_catalog_has(): assert stack.quantity == 2 -@XFAIL def test_a_member_added_from_a_2_7_0_document_takes_the_catalogs_names(): """`AddMember` with the 2.7.0 fighter, given no id and none of the magic items a joining member can't carry.