feat(combat): inject optional allowed-set into clean_damage_types/combatant_defenses (0.26.0)#8
Open
sligara7 wants to merge 1 commit into
Open
feat(combat): inject optional allowed-set into clean_damage_types/combatant_defenses (0.26.0)#8sligara7 wants to merge 1 commit into
sligara7 wants to merge 1 commit into
Conversation
…batant_defenses Add a keyword-only allowed: frozenset[str] = DAMAGE_TYPES to clean_damage_types and combatant_defenses. Default preserves SRD-13 behavior (backward-compatible); a caller governing its own damage-type vocabulary passes SRD-13 ∪ custom so registered types survive the filter at assembly, computed-stats read, AND live combat damage application — no split-brain. dndwright stays domain-agnostic. Bump 0.25.2 -> 0.26.0. Public API (__all__) unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JXPSRe6rg8jtdAAvqZrxvf
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
Adds a keyword-only
allowed: frozenset[str] = DAMAGE_TYPESparameter toclean_damage_types()andcombatant_defenses()incombat/combat.py.DAMAGE_TYPESexactly as before (backward-compatible; all existing call sites compile + behave identically).SRD-13 ∪ custom) so registered types survive the filter at component assembly, the computed-stats read, and live combat damage application.allowedcomes from). Members must be lower-cased (caller owns canonicalisation).__all__) unchanged.Why
Downstream StoryFlow v1.1.0 adds a per-universe damage-type registry. The hardcoded SRD-13 frozenset was the single chokepoint that silently dropped any custom type — and it is applied by two consumers (the character-sheet compute path AND the live-combat
combatant_defensescall). Dependency-injecting the allowed-set is the single-source-of-truth fix that avoids a split-brain (registry honored on the sheet but not in combat) and avoids duplicating the filter across consumers.Tests
tests/test_defenses_and_serialization.py: widened-vocab survival, default-unchanged back-compat, per-channel threading, and a registered type actually halving damage inapply_damage(governed at the point damage is applied, not just on the sheet).__all__unchanged).Minor bump 0.25.2 → 0.26.0 + CHANGELOG. Release/PyPI publish (
gh release create v0.26.0) is a separate gated step.