Repository navigation
Say whether rolled ability scores are sub-par - #350
Merged
Merged
Conversation
The new names are stubs with their final docstrings: `scores_are_sub_par` in osrlib.core.character, which takes six scores and raises NotImplementedError until the chunk lands, and `AbilityScoreRolls.sub_par`, a pydantic computed field that calls it (#345). The scores are sub-par when every score is 8 or less, the SRD's own example, or when two or more are 5 or less, the band below 6 to 8 in every ability table on the SRD's Ability Scores page. Both docstrings quote the SRD's "Sub-Par Characters" sentence and say that `Ruleset` has no flag for it and that `create_character` never refuses or rerolls. tests/test_sub_par_scores.py marks the behaviour and documentation tests xfail until the sub-par-scores chunk lands. Its unmarked tests pin that the named seeds roll the scores written there, that `create_character` draws for a sub-par roll exactly what it drew before, the field's serialization and validation schemas, and the two docstrings. tests/saves/ gains a creation result that osrlib 2.8.0 wrote from seed 6, whose scores are sub-par. The new function's docstring example is marked expected to fail in both docs example harnesses. No golden file changes. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
`scores_are_sub_par` checks that the scores are all six abilities, each from 3 to 18, with the same helper `Character` uses, and then returns true when every score is 8 or less or two or more are 5 or less (#345). It draws nothing, so no RNG stream changes. `AbilityScoreRolls.scores` now has the field validator its docstring promised, so a document with a missing or out-of-range score fails to parse instead of failing later in `sub_par`. Step 1 of the module's creation walkthrough mentions `sub_par`. The function's docstring example moves to lines 1198-1211. No golden file changes. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
The quickstart says where to read `sub_par` on a creation result, the spec's rules scope lists the test, and the adaptations register records 5 or less as osrlib's reading of the SRD's "extremely low rating", with the ability-table steps between 6 and 5 that justify it. The changelog adds the feature under Added (#345) and the stricter `AbilityScoreRolls.scores` validation under Fixed. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
…er review The acceptance tests of the sub-par check now run as ordinary tests, and the docstring example is no longer listed as expected to fail. Every ability table has a row boundary between 6 and 5, but four columns don't change there, so the reason no longer says the tables step down. The changelog says why SCHEMA_VERSION stays 4 for the stricter validation of the scores. Claude-Session: https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3
# Conflicts: # CHANGELOG.md
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.
Closes #345.
The SRD's "Sub-Par Characters" rule lets a referee allow a player to discard a character with very poor ability scores. osrlib now says whether a roll is sub-par, and never discards or rerolls anything itself.
osrlib.core.character.scores_are_sub_par(scores)is true when every score is 8 or less, the SRD's own example, or when two or more scores are 5 or less. The second clause is osrlib's reading of "an extremely low rating in more than one ability", recorded indocs/adaptations.mdas an interpretation: every ability table in the SRD has a row boundary between 6 and 5.AbilityScoreRolls.sub_paris a computed field that calls the function, so it's in the JSON of a roll result, a document can't state a wrong value, and a result recorded by 2.8.0 parses and carries the right value.AbilityScoreRolls.scoresrefuses scores that aren't all six abilities, each from 3 to 18. Its docstring already stated that range and nothing enforced it.There is no
Rulesetflag, because osrlib has nothing to apply: whether a referee allows the discard is the front end's setting.create_charactercreates a sub-par character as before, and no draw changes.How it was checked
The acceptance tests in
tests/test_sub_par_scores.pywere written before the implementation by a different agent. An independent review compared the branch with osrlib 2.8.0 over 20,000 seeds:roll_ability_scoresandcreate_characteragree on every one, andsub_parequals the rule computed independently for every roll. Of the 20,000 3d6 rolls, 613 are sub-par, 8 by the first clause and 607 by the second. All eleven mutations of the rule and the validator were caught. The review also confirmed that no save contains a roll result, so the stricter validation can't refuse a released save.https://claude.ai/code/session_01V7Ertq3gKJ46oFQD6635f3