Docstrings: core effects and events - #95
Merged
Merged
Conversation
Every public member of osrlib.core.effects and osrlib.core.events now answers what it does, why you would call it, what you need first, and what to call next, and every pydantic field and enum member has an attribute docstring so its rendered row is not a bare name. Examples run under the docs harness. Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
The immunity gate in grant_condition and attach reads every condition, so "nothing in the core rules reads it" was wrong for poisoned and charmed, which many monster templates declare immunity to, and for afraid, which remove fear cures behind a save. DeathEvent has a second emitter in deal_damage with its own ordering. An expiry outcome runs after the ordinary ending, not instead of it. The two morale exemptions share a code and resolve opposite ways, and hit points are reported as a standing total only by HitPointsReportedEvent. Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A reader who has only the published reference can now work the effects engine and the event log without opening the source. The effects module says up front who calls it (a session at every clock move,
cast_spellwhen a cast lands, and you when you run the rules yourself), what a condition and a modifier are, and that nothing expires until you advance the clock through the ledger. EachConditionmember says which rules turn on it and which spell cures it, eachMODIFIER_KINDSentry says what combat does with it, and every ledger call says what it returns and when it returns nothing. In the events module, every event class says who emits it, when, which codes it can carry, and why its visibility is what it is, and every field and enum member has an attribute docstring so the rendered rows carry prose instead of bare names. Every example runs under the docs harness.I corrected three docstrings the code disagreed with, all in
src/osrlib/core/effects.pyat the line numbers they had before this branch. TheEffectsLedger.attachdocstring at line 583 said(None, [])came back on a refresh, and a refresh returns the existing effect with an empty event list, so the text now separates the twoNonecases from the refresh case. TheEffectDefinition.expirydocstring at line 476 said an expiry outcome resolves when the duration runs out without saying it runs after the ordinary ending;_expiredrops the effect, emits the expiry event, removes the condition and modifiers, and dispatches onexpirylast, and the field now states that order. TheConditionclass docstring at line 86 listedpoisonedamong the conditions the core rules consume alongside a set of others, which understated the rule that actually applies:grant_conditionandEffectsLedger.attachrefuse any condition a target's template lists in its defenses'condition_immunities, whichever condition it is, so the class docstring now states that rule once for every member and each member says what else reads it.A first draft of this branch went the other way and called
poisoned,charmed, andafraidvocabulary nothing reads. Review caught it and the second commit fixes it: many monster templates declare immunity topoisonedand tocharmed, neutralize poison and remove fear cure two of the three, and the fear cure demands a save versus spells at +1 per caster level before it takes. The same commit documents the secondDeathEventemitter indeal_damage, which carries the permanent code after a hit point report and with no condition event; states that both morale exemptions sharecombat.morale.exemptand resolve opposite ways, soscoreis what tells them apart; and narrows the claim thatHitPointsReportedEventis the only event reporting hit points to the only one reporting a standing current and maximum.Nothing is fenced
no-run, and I left nothing undocumented.I did not use the adaptations register anchor. Neither of these files mentions the register, and the anchor slug contains "pinned", which the vocabulary gate in the docs gates rejects inside a docstring, so the full URL is the form to use if a later batch needs it here.
https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa