Let authors place named magic items in treasure caches - #40
Merged
Conversation
FeatureSpec grows magic_item_ids, an additive tuple of shipped magic-item catalog ids. The instances are created when the cache is emptied: the new public instantiate_magic_item — the named-item half of generate_magic_item, now factored out — rolls the creation details (charges, quantities, generic armour's base type, scroll contents, sword sentience) on the treasure stream at the tier in force at the take, exactly as a generated hoard's would. validate_adventure resolves the new ids against the shipped magic-item catalog (loaded internally — adventures bundle no magic items), and validate_content_pack reports the same gap as the new pack.feature.unknown_magic_item finding. No schema bump: the field is additive with an empty default, existing documents load unchanged, and a cache placing no magic items consumes no extra draws — the goldens are untouched. Claude-Session: https://claude.ai/code/session_01FAGD8y9X4XeCdZN1nuLJxc
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.
What
An authored treasure cache could carry coins, mundane equipment ids, and named valuables — but a specific magic item (the sword +1 in the captain's strongbox) was unplaceable at every layer: magic entered play only through generated hoards. This PR adds the authoring surface:
FeatureSpec.magic_item_ids— an additive tuple of ids from the shipped magic-item catalog (see the magic item id index). Listing an id twice places two.instantiate_magic_item— the named-item half ofgenerate_magic_item, factored out as a public function: no table selection, just the depth-first creation-detail resolution (the Magic Armour Type d8, charges, quantities, wish counts, scroll contents, the energy-drain total, sword sentience).generate_magic_itemnow calls it per row item, so the two paths cannot drift.validate_adventureresolves the new ids against the shipped magic-item catalog (loaded internally; adventures bundle no magic items), a hard content error before play.validate_content_packreports the same gap as the newpack.feature.unknown_magic_itemfinding.Contracts
TREASURE_STREAMin tuple order at take time.osrlib.crawlcalls intoosrlib.core.treasure.Tests
test_treasure_kernel.py::TestMagicItemInstantiation— details roll like a generated item's (charges 2d10, ammunition 3d10, generic armour's base d8), same seed same instance, unknown id/tier raise.test_exploration.py::TestAuthoredMagicItems— placed items land in packs unidentified with allocator ids, rideItemAcquiredEvent, the cache empties once, and two seeded runs roll identical details.test_dungeon.py— a shipped magic id validates; an unknown one is aContentValidationErrornaming the id.test_content_pack.py— the new finding code, with the known id passing silently.Full suite: 1668 passed, 58 skipped.
ruff format/checkclean,mkdocs build -sclean.https://claude.ai/code/session_01FAGD8y9X4XeCdZN1nuLJxc