Skip to content

Docstrings: core creatures - #93

Merged
mmacy merged 2 commits into
mainfrom
docs/api-ref-core-creatures
Sep 14, 2026
Merged

Docstrings: core creatures#93
mmacy merged 2 commits into
mainfrom
docs/api-ref-core-creatures

Conversation

@mmacy

@mmacy mmacy commented Sep 14, 2026

Copy link
Copy Markdown
Owner

A reader who has only the published reference can now build a party and run it. create_character says where a seeded stream comes from, what a purchase lot is, and which class ids are valid, and its example carries a character into a Party. spawn_monster says why you spawn instead of passing templates around, and the template and the instance each say which one they are and link the other. Every pydantic field and every enum member in the four modules has its own docstring, so the rendered field rows read as descriptions instead of bare names. The docs harness runs 32 examples from these files, and I checked every printed line against a real run.

I corrected five claims the code disagreed with. Character.initiative_modifier (src/osrlib/core/character.py:382) said the DEX modifier ran from -3 to +3; the initiative column runs from -2 to +2. Character.literacy (src/osrlib/core/character.py:416) said literacy gates reading a scroll; nothing in osrlib reads it, so the docstring now says that and leaves the decision to the caller. TreasureRef.parenthetical (src/osrlib/core/monsters.py:517) said bracketed letters are rolled per creature; resolve_treasure_ref rolls them as lair treasure. MonsterTemplate.morale (src/osrlib/core/monsters.py:659) said a None morale belongs to unthinking constructs; the merchant is the only entry with one, so the docstring now just says the stat block prints no score. current_hp on both Character and MonsterInstance said zero or below, but the field floor is 0.

The monsters module docstring used to open with a count of SRD pages. I dropped the number, since the project's guide rules out surface counts in prose.

The adaptations register is linked as a full URL rather than the heading anchor: the anchor slug is adaptations-and-pinned-interpretations, and the word inside it trips the vocabulary gate in the docs gate tests, which I am not allowed to edit.

No examples are marked no-run, and I left nothing undocumented on purpose.

https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa

Rewrite the reference prose for the four modules that define the creatures a game
plays with: player characters and their creation, class definitions and level
tables, NPC adventuring parties, and monster templates and instances.

Every public member answers what it does, why you'd reach for it, what you need
first and where to get it, what to call next, what to use instead, and where it
stops. Every pydantic field and enum member gets its own attribute docstring, so
the rendered field rows carry descriptions instead of bare names. Entry points
get runnable examples with the printed output copied from a real run.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
Point TreasureRef at plan_treasure_ref, which is the only function that honors the
bracketed letters, the flat gold, and the multiplier, and say what a loop over
`letters` alone would drop.

State level_up's two settings separately: whether a die is rolled follows the hit
dice count rising, and whether CON counts follows con_applies. They change over
together in the shipped classes but are independent in the data, which is what
LevelUpResult.con_applied is for. Give drain_levels and the result fields the same
wording.

Say that generate_npc_party rolls the first level's hit die itself and sends only
levels 2 and up through level_up, and that a level past name level takes no draw.

Use TREASURE_STREAM in the NPC examples, link EXPLORATION_STREAM from the thief and
detection rolls, and fix the equipment id index link text and an unexpanded
abbreviation in a comment.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
@mmacy
mmacy merged commit 556ad88 into main Sep 14, 2026
5 checks passed
@mmacy
mmacy deleted the docs/api-ref-core-creatures branch September 14, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant