Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- [`RefereeView.feature_handles`][osrlib.crawl.views.RefereeView.feature_handles] maps each feature's save reference to the player handle the player view shows for it, for every authored feature and every generated cache, including a lair cache the players can't see yet (#318). A referee tool can use it to show a referee the feature the players see, and to send the same `feature_id` they do. The player-handle key stays out of both views. The session derives the five fields from state a save already contains, so a 2.7.0 save loads with them filled in, every new field has a default, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4.
- [`FeatureSpec.referee_notes`][osrlib.crawl.dungeon.FeatureSpec.referee_notes] is a new string field for what the referee reads about a feature and the players never do, such as what a cache holds or how its trap is hidden (#318). osrlib never reads it, no event includes it, and no rule depends on it. It's in the adventure document, so a save and [`RefereeView.adventure`][osrlib.crawl.views.RefereeView.adventure] have it, but the player view doesn't include it. It defaults to an empty string, so an adventure document written before this release loads unchanged, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4.
- [`EncounterView.can_back_stab`][osrlib.crawl.views.EncounterView.can_back_stab] lists the members who can declare an `attack` with [`back_stab`][osrlib.crawl.commands.BattleDeclaration.back_stab] this round: those whose class has the `back_stab` ability, in the party's free round or while they're hiding (#319). The session never refuses a back-stab by a member in it with `battle.declaration.back_stab_no_ability` or `battle.declaration.back_stab_target_aware`, and always refuses one by any other declarer with one of them, because the list comes from the same checks. So a client no longer needs to combine the class catalog, `party_free_round`, and `hiding`, and the list is also correct for a custom class, which isn't in the catalog. [`BattleRoundPreview.can_hide`][osrlib.crawl.battle.BattleRoundPreview.can_hide] and [`BattleRoundPreview.can_back_stab`][osrlib.crawl.battle.BattleRoundPreview.can_back_stab] give the two lists beside the declarations planned so far, judging each member as if the `hide` or the back-stab took the place of their own planned declaration. So another member's planned fighting withdrawal can take a thief out of `can_hide`, and another member's planned `close` can put one in it. A preview with no planned move gives the view's lists. Building the lists takes no draw, and each new field has an empty default, so a view or a preview from 2.7.0 still parses.
- 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.
- 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

- The docstrings of [`FeatureSpec.description`][osrlib.crawl.dungeon.FeatureSpec.description] and [`MapFeatureView.description`][osrlib.crawl.views.MapFeatureView.description], and the guide to authoring custom content, say who reads a feature's description (#318). Since 2.6.0, the player view shows a cache's authored description as soon as the cache comes into view, before anyone opens it and after the party empties it. Before 2.6.0, only a referee read that text, but neither the 2.6.0 changelog nor the docstring, which called it "Text to show when the party finds the feature", said that the players now read it. If you wrote an adventure before 2.6.0, check each cache's description for its contents, the identity of a magic item the players see masked, and a trap the party hasn't found. Leave in `description` what the party sees from outside the cache, and move the rest: the contents to the cache's `item_ids`, `magic_item_ids`, `coins`, and `valuables`, the trap to its `trap`, and what only the referee reads to the new `referee_notes`.
- The docstrings of [`FeatureSpec.id`][osrlib.crawl.dungeon.FeatureSpec.id] and of the `feature_id` field of [`TakeTreasure`][osrlib.crawl.commands.TakeTreasure], [`InspectTreasure`][osrlib.crawl.commands.InspectTreasure], and [`RemoveTreasureTrap`][osrlib.crawl.commands.RemoveTreasureTrap] say that both forms of feature id stay supported, the `feature:` handle from [`MapFeatureView.id`][osrlib.crawl.views.MapFeatureView.id] and the raw id (#318). A player client sends the handle, because the player view lists only handles, and a referee tool can send the raw id. Both forms resolve against the same features, the ones the party can reach where it stands, so a raw id reaches only the features that a handle reaches and reveals nothing more. Before, the docstrings called the raw id a form that current callers could still pass for compatibility, and didn't say what it could reach.
- Outside a battle, [`CastSpell`][osrlib.crawl.commands.CastSpell] and [`UseItem`][osrlib.crawl.commands.UseItem] refuse a target that isn't a party member and isn't a creature in a group of the open encounter that hasn't fled (#317). The refusal is the one an id that matches nothing gets, `magic.cast.unknown_target` for a spell or a scroll and `items.use.unknown_target` for a staff of healing, with the same params, and it costs no draw, no time, and no state. Before, the session accepted as a target any creature still in `session.registry()`, so after the referee's `EndEncounter` a magic-user's *magic missile* at `monster-0001` damaged a goblin that the player view no longer listed. A monster or an NPC adventurer of an encounter that has ended, a monster of a group that fled, and a monster spawned into no encounter now get the unknown id's answer, alive or dead. A party member is still a target in any state, so *raise dead* and *stone to flesh* work as before. The fix also changes two related rejections. A scroll read at a dead creature of the open encounter gets `magic.cast.unknown_target`, as a `cast` declaration in a battle does, where before the spell landed on the corpse. A staff of healing declared in a battle at a dead creature of an encounter that has ended gets `items.use.unknown_target`, where before it got `items.use.target_cannot_be_healed`, which told you the creature was dead. A refused scroll read also no longer adds the `magic` stream to the session's saved RNG state. A command log recorded on 2.7.0 that holds such a command no longer replays, because the command is now refused. A session with no such command draws exactly as before on every stream.
- [`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"`. 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
Expand Down
14 changes: 13 additions & 1 deletion docs/adaptations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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, 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

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.
Expand Down Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/front-ends/fastapi-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`. [`PlayerView.features_here`][osrlib.crawl.views.PlayerView.features_here] lists the handles the treasure commands accept from where the party stands, and [`MapFeatureView.emptied`][osrlib.crawl.views.MapFeatureView.emptied] marks an authored cache the party has emptied, so the client can draw that cache opened and stop offering it. 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)). `PlayerView.emptied_caches` can contain a fully qualified raw feature id after the party empties that cache.
[`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`. [`PlayerView.features_here`][osrlib.crawl.views.PlayerView.features_here] lists the handles the treasure commands accept from where the party stands, and [`MapFeatureView.emptied`][osrlib.crawl.views.MapFeatureView.emptied] marks an authored cache the party has emptied, so the client can draw that cache opened and stop offering it. 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)). `PlayerView.emptied_caches` can contain a fully qualified raw feature id after the party empties that cache.

Authored narrative also reaches web clients through `POST /sessions/{session_id}/commands` responses in two places:

Expand Down
Loading
Loading