diff --git a/CHANGELOG.md b/CHANGELOG.md index 38e4cbd..1782eaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Added -- Two house rules for character creation, which the SRD doesn't print and `Ruleset()` leaves off (#341). [`Ruleset.ability_score_method`][osrlib.core.ruleset.Ruleset.ability_score_method] is `"3d6"` by default. With `"4d6_drop_lowest"`, [`create_character`][osrlib.core.character.create_character] throws four d6 for each ability and drops the lowest, the first of them thrown when two or more tie, and [`roll_ability_scores`][osrlib.core.character.roll_ability_scores] does the same when you pass the method to its new `method` keyword. [`AbilityScoreRolls.rolls`][osrlib.core.character.AbilityScoreRolls.rolls] keeps the three dice that count, and the new [`AbilityScoreRolls.dropped`][osrlib.core.character.AbilityScoreRolls.dropped] has the dropped die of each ability, so a client can show all four. The method draws 24 dice instead of 18, so the same seed gives a different character, and NPC adventurers always roll 3d6. With [`Ruleset.max_hp_at_first_level`][osrlib.core.ruleset.Ruleset.max_hp_at_first_level] on, a first-level character's hit points are the hit die's size plus the CON modifier, and at least 1, and the new [`HitPointRoll.maximized`][osrlib.core.character.HitPointRoll.maximized] is true. The hit die and any rerolls of `hp_reroll_at_first_level` are still thrown, so the starting gold is the same as with the flag off. `examples/rulesets/creation_house_rules.json` is a ruleset with both house rules on and every other field at its default, for a front end to copy. With both flags at their defaults, every draw and result is what 2.8.0 gave. A 2.8.0 save loads with both off, a 2.8.0 creation result parses with an empty `dropped` and a false `maximized`, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. +- Two house rules for character creation, which the SRD doesn't print and `Ruleset()` leaves off (#341). [`Ruleset.ability_score_method`][osrlib.core.ruleset.Ruleset.ability_score_method] is `"3d6"` by default. With `"4d6_drop_lowest"`, [`create_character`][osrlib.core.character.create_character] throws four d6 for each ability and drops the lowest, the first of them thrown when two or more tie, and [`roll_ability_scores`][osrlib.core.character.roll_ability_scores] does the same when you pass the method to its new `method` keyword. [`AbilityScoreRolls.rolls`][osrlib.core.character.AbilityScoreRolls.rolls] keeps the three dice that count, and the new [`AbilityScoreRolls.dropped`][osrlib.core.character.AbilityScoreRolls.dropped] has the dropped die of each ability, so a client can show all four. The method draws 24 dice instead of 18, so the same seed gives a different character, and NPC adventurers always roll 3d6. With [`Ruleset.max_hp_at_first_level`][osrlib.core.ruleset.Ruleset.max_hp_at_first_level] on, a first-level character's hit points are the hit die's size plus the CON modifier, and at least 1, and the new [`HitPointRoll.maximized`][osrlib.core.character.HitPointRoll.maximized] is true. The hit die and any rerolls of `hp_reroll_at_first_level` are still thrown, so the starting gold is the same as with the flag off. `examples/rulesets/creation_house_rules.json` is a ruleset with both house rules on and every other field at its default, for a front end to copy. With both flags at their defaults, every draw and every value is what 2.8.0 gave. A 2.8.0 save loads with both off, a 2.8.0 creation result parses with an empty `dropped` and a false `maximized`, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. - [`scores_are_sub_par`][osrlib.core.character.scores_are_sub_par] and [`AbilityScoreRolls.sub_par`][osrlib.core.character.AbilityScoreRolls.sub_par] say whether a set of ability scores as rolled is sub-par, so that a referee may let the player discard the character and start again, as the SRD's "Sub-Par Characters" rule allows (#345). The scores are sub-par when every score is 8 or less, or when two or more scores are 5 or less. `sub_par` is computed from the roll's `scores`, so it's in `model_dump()` and the JSON, a 2.8.0 creation result parses with it filled in, and a `sub_par` key in a document you parse is ignored. It describes the scores as rolled, before the adjustment step. osrlib only reports the fact: [`Ruleset`][osrlib.core.ruleset.Ruleset] has no flag for it, [`create_character`][osrlib.core.character.create_character] creates a sub-par character as before, and no draw changes. - [`SpellMode.display_name`][osrlib.core.spells.SpellMode.display_name] is a short label for a mode, such as `"Blind a creature"`, for a client to show where a player chooses one of a form's modes, such as a cast dialog (#340). It says what the caster does, in sentence case with no closing punctuation, and in the built-in catalog no two modes of one form have the same label. Each built-in label comes from the lead-in that the OSE SRD prints before the usage, such as "Blinding a creature:". Where the page prints no lead-in, or one that names a situation such as *bless*'s "Battle:", the SRD compiler has a label written from the page's words, such as `"Bless allies in battle"`. A mode that leaves the label out, or gives one that is empty or only spaces, gets a label made from its key: each run of underscores becomes one space, the spaces at either end are dropped, and the first letter becomes a capital, so `"kill_green_slime"` is labelled `"Kill green slime"`. The one mode of a single-mode form is labelled the same way, such as *fire ball*'s `"Damage"`. As a result, a spell document, an adventure, or a save from 2.8.0 loads with a label on every mode, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. -- [`MemberView.reverses_at`][osrlib.crawl.views.MemberView.reverses_at], [`MemberView.can_prepare_now`][osrlib.crawl.views.MemberView.can_prepare_now], and [`MemberView.needs_sleep_to_prepare`][osrlib.crawl.views.MemberView.needs_sleep_to_prepare] let a client decide when to offer a prepare dialog and which forms of a spell to put in it and in a cast dialog (#338). `reverses_at` is `"memorize"` for an arcane caster, `"cast"` for a divine caster, and `None` for a class that casts nothing, read from the class's casting ability, so it's right for a custom class too. `can_prepare_now` is true exactly when the session accepts a [`PrepareSpells`][osrlib.crawl.commands.PrepareSpells] from the member with a selection that fits `preparable_spells` and `spell_slots`, and `needs_sleep_to_prepare` is true exactly when the party hasn't slept since the member last prepared. The session reads them from its own state, so they're right in a session restored from a save. Before, a client inferred the kind of caster from the spell book and read the event log for the last rest and the last preparation. -- [`PlayerView.valuable_names`][osrlib.crawl.views.PlayerView.valuable_names] gives the own name of each gem and piece of jewellery that has one, like `"Prior's chain of office"`, keyed by the instance id, for the pieces in the members' inventories and in the known piles (#339). A piece placed by a [`ValuableSpec`][osrlib.crawl.dungeon.ValuableSpec] with a `name` has one, and a piece rolled on the treasure tables doesn't. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] doesn't change and still names every valuable by its kind. Before, a client that wanted a piece's own name in a pile paired the pile's `contents` with its `items` by position. +- [`MemberView.reverses_at`][osrlib.crawl.views.MemberView.reverses_at], [`MemberView.can_prepare_now`][osrlib.crawl.views.MemberView.can_prepare_now], and [`MemberView.needs_sleep_to_prepare`][osrlib.crawl.views.MemberView.needs_sleep_to_prepare] let a client decide when to offer a prepare dialog and which forms of a spell to put in it and in a cast dialog (#338). `reverses_at` is `"memorize"` for an arcane caster, `"cast"` for a divine caster, and `None` for a class that casts nothing, read from the class's casting ability, so it's right for a custom class too. `can_prepare_now` is true exactly when the session accepts a [`PrepareSpells`][osrlib.crawl.commands.PrepareSpells] from the member with a selection that fits `preparable_spells` and `spell_slots`, and `needs_sleep_to_prepare` is true exactly when the member's class casts spells and the party hasn't slept since the member last prepared. The session reads them from its own state, so they're right in a session restored from a save. Before, a client inferred the kind of caster from the spell book and read the event log for the last rest and the last preparation. +- [`PlayerView.valuable_names`][osrlib.crawl.views.PlayerView.valuable_names] gives the own name of each gem and piece of jewellery that has one, like `"Prior's chain of office"`, keyed by the instance id, for the pieces in the members' inventories and in the known piles (#339). A piece placed by a [`ValuableSpec`][osrlib.crawl.dungeon.ValuableSpec] with a `name` has one, unless the name is the plain `"Gem"` or `"Jewellery"` that a rolled piece of its kind gets, and a piece rolled on the treasure tables doesn't. [`PlayerView.item_names`][osrlib.crawl.views.PlayerView.item_names] doesn't change and still names every valuable by its kind. Before, a client that wanted a piece's own name in a pile paired the pile's `contents` with its `items` by position. ### Changed @@ -20,8 +20,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Fixed -- [`PrepareSpells`][osrlib.crawl.commands.PrepareSpells] refuses a member whose class casts nothing with `magic.memorize.not_a_caster` whether or not the party has slept. Before, it refused such a member with `magic.memorize.needs_sleep` until the party's first sleep, which said that the member could prepare after a rest. -- [`AbilityScoreRolls`][osrlib.core.character.AbilityScoreRolls] refuses `scores` that don't have all six abilities, each from 3 to 18, with a `pydantic.ValidationError`. The docstring of `scores` already stated that range, but nothing enforced it, so a document with a missing or out-of-range score parsed without an error. No save contains a roll result, and every result that `roll_ability_scores` and `create_character` have returned has six scores in that range, so a result recorded by an earlier release still parses, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. +- [`PrepareSpells`][osrlib.crawl.commands.PrepareSpells] refuses a member whose class casts nothing with `magic.memorize.not_a_caster` whether or not the party has slept (#338). Before, it refused such a member with `magic.memorize.needs_sleep` until the party's first sleep, which said that the member could prepare after a rest. +- [`AbilityScoreRolls`][osrlib.core.character.AbilityScoreRolls] refuses `scores` that don't have all six abilities, each from 3 to 18, with a `pydantic.ValidationError` (#345). The docstring of `scores` already stated that range, but nothing enforced it, so a document with a missing or out-of-range score parsed without an error. No save contains a roll result, and every result that `roll_ability_scores` and `create_character` have returned has six scores in that range, so a result recorded by an earlier release still parses, and [`SCHEMA_VERSION`][osrlib.versioning.SCHEMA_VERSION] stays 4. ## [2.8.0] - 2026-11-25 diff --git a/src/osrlib/crawl/commands.py b/src/osrlib/crawl/commands.py index 8730b82..a286367 100644 --- a/src/osrlib/crawl/commands.py +++ b/src/osrlib/crawl/commands.py @@ -1624,9 +1624,9 @@ class PrepareSpells(Command): session has ended. - `session.command.unknown_member` - `character_id` matches no party member. - `session.command.member_incapacitated` - the member can't act. + - `magic.memorize.not_a_caster` - the member's class casts no spells. - `magic.memorize.needs_sleep` - the party hasn't slept since this caster's last preparation. - - `magic.memorize.not_a_caster` - the member's class casts no spells. - `magic.memorize.unknown_spell` - a selection matches no spell in the session's catalog. - `magic.memorize.wrong_list` - a selection isn't on the caster's spell list. diff --git a/tests/test_creation_house_rules.py b/tests/test_creation_house_rules.py index ec1e242..973cff4 100644 --- a/tests/test_creation_house_rules.py +++ b/tests/test_creation_house_rules.py @@ -2,10 +2,9 @@ `Ruleset.ability_score_method` picks 3d6 or 4d6 drop lowest for the ability scores, and `Ruleset.max_hp_at_first_level` counts the first-level hit die as its maximum. Both are off by -default. The tests marked `chunk: creation-house-rules` wait for the implementation. The unmarked -ones hold the contract that the default rules draw and give exactly what osrlib 2.8.0 drew and gave, -and that what 2.8.0 wrote still loads. Their literal values were computed by running the 2.8.0 -source from `git archive v2.8.0` on the creation stream of each seed. +default. Some of the tests hold the contract that the default rules draw and give exactly what +osrlib 2.8.0 drew and gave, and that what 2.8.0 wrote still loads. Their literal values were +computed by running the 2.8.0 source from `git archive v2.8.0` on the creation stream of each seed. Every die on the creation stream is one `randbelow(sides) + 1` draw, so a replayed stream gives the dice each test derives its numbers from. diff --git a/tests/test_sub_par_scores.py b/tests/test_sub_par_scores.py index 8eaba28..6d13073 100644 --- a/tests/test_sub_par_scores.py +++ b/tests/test_sub_par_scores.py @@ -10,11 +10,10 @@ `AbilityScoreRolls.sub_par` answers for a roll, computed from its `scores`, the scores as rolled before the adjustment step. osrlib never discards or rerolls a character, so no draw changes. -The tests marked `chunk: sub-par-scores` wait for the implementation. The unmarked ones hold what already holds: the -draws and the characters that `create_character` gives for the seeds below, the schemas, and the docstrings. Every -literal score and draw was computed by running the source from `git archive v2.8.0`, which gives the same values as -the source this chunk starts from, on the creation stream of each seed. The 4d6 drop lowest values, which 2.8.0 can't -roll, were computed on the source this chunk starts from. +Some of the tests hold what 2.8.0 already gave: the draws and the characters that `create_character` gives for the +seeds below. Every literal 3d6 score and draw was computed by running the source from `git archive v2.8.0` on the +creation stream of each seed. The 4d6 drop lowest values, which 2.8.0 can't roll, were computed on the source this +chunk started from, osrlib 2.8.0 with the creation house rules merged. """ import json @@ -492,7 +491,9 @@ def test_the_spec_mentions_the_check_in_the_ability_score_scope(): def test_the_changelog_bullet_names_the_function_and_the_field(): - bullets = [line for line in CHANGELOG.read_text(encoding="utf-8").splitlines() if "(#345)" in line] + # The fix to the validation of `scores` cites the issue too, so the bullet is the one that names the function. + cited = [line for line in CHANGELOG.read_text(encoding="utf-8").splitlines() if "(#345)" in line] + bullets = [line for line in cited if "scores_are_sub_par" in line] assert len(bullets) == 1 (bullet,) = bullets assert bullet.startswith("- ")