dndwright 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dndwright/__init__.py +69 -0
- dndwright/content/__init__.py +56 -0
- dndwright/content/classes.json +147 -0
- dndwright/content/creatures.json +334 -0
- dndwright/content/generate.py +87 -0
- dndwright/content/magic_items.json +1915 -0
- dndwright/content/species.json +111 -0
- dndwright/ontology/__init__.py +25 -0
- dndwright/ontology/dnd.yaml +141 -0
- dndwright/ontology/loader.py +104 -0
- dndwright/rules/__init__.py +35 -0
- dndwright/rules/adapters.py +691 -0
- dndwright/rules/assembler.py +377 -0
- dndwright/rules/character_evaluator.py +248 -0
- dndwright/rules/components.py +654 -0
- dndwright/rules/dnd_5e_2024.py +606 -0
- dndwright/rules/evaluator.py +217 -0
- dndwright/rules/lookup_tables.py +501 -0
- dndwright/rules/operations.py +412 -0
- dndwright/rules/schema.py +69 -0
- dndwright/rules/theme_scaling.py +207 -0
- dndwright-0.2.0.dist-info/METADATA +101 -0
- dndwright-0.2.0.dist-info/RECORD +26 -0
- dndwright-0.2.0.dist-info/WHEEL +4 -0
- dndwright-0.2.0.dist-info/licenses/LICENSE +21 -0
- dndwright-0.2.0.dist-info/licenses/NOTICE +24 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dndwright
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Domain-neutral D&D 5e (2024) rules & character-sheet computation engine: a data-driven DAG of formulas (ability mods, proficiency, spell DC/slots, HP, AC).
|
|
5
|
+
Project-URL: Homepage, https://github.com/sligara7/dndwright
|
|
6
|
+
Project-URL: Repository, https://github.com/sligara7/dndwright
|
|
7
|
+
Author: Anthony Sligar
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Keywords: character-sheet,computation-graph,dnd,dnd5e,rules-engine,srd,ttrpg
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Games/Entertainment :: Role-Playing
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: pydantic>=2.5
|
|
18
|
+
Requires-Dist: pyyaml>=6.0
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=7.4; extra == 'dev'
|
|
21
|
+
Requires-Dist: ruff>=0.1; extra == 'dev'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# dndwright
|
|
25
|
+
|
|
26
|
+
> ⚠️ **Early development (v0.1, alpha).** The API is still moving and may change without
|
|
27
|
+
> notice between minor versions. Extracted from a working application; usable today, but
|
|
28
|
+
> pin a tag/commit if you depend on it.
|
|
29
|
+
|
|
30
|
+
**A domain-neutral D&D 5e (2024) rules & character-sheet computation engine.** A character
|
|
31
|
+
sheet is modelled as a **directed acyclic computation graph** — nodes are values, edges are
|
|
32
|
+
dependencies, and formulas are *data* (a JSON-serialisable DSL), not code. Pure Python
|
|
33
|
+
(`pydantic` + stdlib), no application or framework coupling: map your own character data in,
|
|
34
|
+
read computed stats out.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install git+https://github.com/sligara7/dndwright.git
|
|
40
|
+
# or, for local development:
|
|
41
|
+
pip install -e ".[dev]"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quickstart
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from dndwright import evaluate_character
|
|
48
|
+
|
|
49
|
+
sheet = evaluate_character({
|
|
50
|
+
"ability_scores": {"strength": 8, "dexterity": 14, "constitution": 14,
|
|
51
|
+
"intelligence": 18, "wisdom": 12, "charisma": 10},
|
|
52
|
+
"class_data": {"class_name": "wizard"},
|
|
53
|
+
"species_data": {"name": "Human", "speed": 30},
|
|
54
|
+
"level": 5,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
sheet["proficiency_bonus"] # 3
|
|
58
|
+
sheet["ability_modifiers"] # {"intelligence": 4, "dexterity": 2, ...}
|
|
59
|
+
sheet["spellcasting_type"] # "full_caster"
|
|
60
|
+
# ...plus armor_class, hit_points, hit_dice, initiative, saves, features, ...
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Lower level — assemble typed inputs and evaluate against the ruleset:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from dndwright import DND_5E_2024_RULESET, assemble_character_inputs, evaluate, apply_modifiers
|
|
67
|
+
from dndwright.rules.components import ClassMechanics
|
|
68
|
+
|
|
69
|
+
inputs = assemble_character_inputs(class_mechanics=..., ability_scores={...}, level=5)
|
|
70
|
+
computed = apply_modifiers(evaluate(DND_5E_2024_RULESET, inputs), inputs)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Why a computation graph?
|
|
74
|
+
|
|
75
|
+
Derived character values form a dependency DAG: ability scores → modifiers → proficiency →
|
|
76
|
+
save DCs / spell slots / AC / HP. dndwright represents that DAG explicitly and stores the
|
|
77
|
+
formulas as **data** (`FormulaSpec`: an op + args), so the rules are inspectable, testable,
|
|
78
|
+
and serialisable — not buried in imperative code. `DND_5E_2024_RULESET` is a 135-node graph.
|
|
79
|
+
|
|
80
|
+
## What's inside
|
|
81
|
+
|
|
82
|
+
| Component | What it does |
|
|
83
|
+
|-----------|--------------|
|
|
84
|
+
| `evaluate_character` | One call: character data dict → fully computed sheet. |
|
|
85
|
+
| `DND_5E_2024_RULESET` | The 135-node 5e-2024 computation DAG (formulas as data). |
|
|
86
|
+
| `evaluate` / `assemble_character_inputs` / `apply_modifiers` | The lower-level engine. |
|
|
87
|
+
| `Ruleset` / `ComputationNode` / `FormulaSpec` / `NodeType` | The DAG schema. |
|
|
88
|
+
| `dndwright.rules.components` | Typed inputs (`ClassMechanics`, `SpeciesMechanics`, …). |
|
|
89
|
+
| `dndwright.rules.lookup_tables` | SRD-derived rules tables (hit dice, spell slots, AC, saves). |
|
|
90
|
+
|
|
91
|
+
## API stability
|
|
92
|
+
|
|
93
|
+
The public API is exactly `dndwright.__all__`, pinned by `tests/test_api_contract.py`.
|
|
94
|
+
Versioning follows [SemVer](https://semver.org/); at `0.x` minor versions may break, with
|
|
95
|
+
every change recorded in `CHANGELOG.md`.
|
|
96
|
+
|
|
97
|
+
## Credits & license
|
|
98
|
+
|
|
99
|
+
MIT licensed (see `LICENSE`). The rules tables encode game *mechanics* derived from the
|
|
100
|
+
**D&D System Reference Document 5.2** (© Wizards of the Coast, **CC-BY-4.0**); see `NOTICE`.
|
|
101
|
+
Not affiliated with or endorsed by Wizards of the Coast. Contains no PHB/DMG/MM content.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
dndwright/__init__.py,sha256=3AypfLVs2LTP1F9ddNjy8hNLhYDSL75rPaZMWSwwZpk,2668
|
|
2
|
+
dndwright/content/__init__.py,sha256=gp7GuTMOZ5OR8VVaSGwwkbTSwQpalXUNBou1BaPKef4,1669
|
|
3
|
+
dndwright/content/classes.json,sha256=n_bq9TzFA8meCK4uDRY-NNxeSLGV1-WklEJirox1k1s,5029
|
|
4
|
+
dndwright/content/creatures.json,sha256=NjpdckyqRUv88aLGHfdvy2OImvVb6uER0zu7sI02lBk,8980
|
|
5
|
+
dndwright/content/generate.py,sha256=zAIeULBbNHBSYu58GJCm-zoA_fJt5TmsSGzLABFSlXA,5151
|
|
6
|
+
dndwright/content/magic_items.json,sha256=9C6bMuqo6L8UQuV0di925K7DY4uY6CAz9IJqZnBLe-U,204317
|
|
7
|
+
dndwright/content/species.json,sha256=QX_4XW2P9zkgDhMXt7KpiyGm9FBD52fx3olhGLb9gIg,3970
|
|
8
|
+
dndwright/ontology/__init__.py,sha256=PLJuTBiiVBJpHAAy1x_Pz7jRq52in1--40RSzaE1WPg,551
|
|
9
|
+
dndwright/ontology/dnd.yaml,sha256=93rlQ1Ts8X5MYJ_kX0T74GWEQY5MhDX1y9kh5UOyVyQ,5705
|
|
10
|
+
dndwright/ontology/loader.py,sha256=YceqJJ96GZGYJC7xUOPVpy5VD2hhpgd3hTXBRh3uLkk,3497
|
|
11
|
+
dndwright/rules/__init__.py,sha256=32PP2LR_67iEp-MFRj8BNuX8Fi9QjncpRAJvbINptbE,1096
|
|
12
|
+
dndwright/rules/adapters.py,sha256=JFzI0D4acoLo2Oa0EaQgIUb458clerfhZzSKQZS_JRw,26977
|
|
13
|
+
dndwright/rules/assembler.py,sha256=7uu4JdBcezbDSXH66IrmbUyeqA6YuuksIQUtqeVER3Q,14419
|
|
14
|
+
dndwright/rules/character_evaluator.py,sha256=Rvvv2BcMUTrA0m67g8N02E4R_W5J_oz_t_Uypcgosck,8358
|
|
15
|
+
dndwright/rules/components.py,sha256=RuOhKNrQ5JhPIZsD4uy-jzW5rzUnkZCLGw0gm-MFiko,22062
|
|
16
|
+
dndwright/rules/dnd_5e_2024.py,sha256=yUg6yoYPhN7-ENAB3Pb1G5pUPwFOEpUvPiPb0yvsNZw,19057
|
|
17
|
+
dndwright/rules/evaluator.py,sha256=GFUr7xtnemVw43ze84IGMlfO_0yXkBIZOKRL1fsONC8,6373
|
|
18
|
+
dndwright/rules/lookup_tables.py,sha256=G9EauJCXFMdJtPHS6s82FsqJ3NEqldIX6U5cJUhemCg,16181
|
|
19
|
+
dndwright/rules/operations.py,sha256=LskHIA4V608zBhl2YxmYIy-fRDcVB1wN9ZPFX6TQg-w,12941
|
|
20
|
+
dndwright/rules/schema.py,sha256=yguB2nnHKiaqQHlwJHrMZAhrvswt1aHoSI2xqh4U-GU,2606
|
|
21
|
+
dndwright/rules/theme_scaling.py,sha256=_0YGOmflBu1zXlHbqNY3pNflGaAUXZCQQzLwHKECLUY,7975
|
|
22
|
+
dndwright-0.2.0.dist-info/METADATA,sha256=-hBu_IQUmOQVmCS_TWL0P_wLqbSNIVP50nBr2bYSz-8,4228
|
|
23
|
+
dndwright-0.2.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
24
|
+
dndwright-0.2.0.dist-info/licenses/LICENSE,sha256=SH_gQdl3Ihoor4g_7cE-qaRM8o1tGRh1Alo3oPsLJGI,1071
|
|
25
|
+
dndwright-0.2.0.dist-info/licenses/NOTICE,sha256=Ng3qyEeIGYD2HwF84NoQ4qW86EK2NDUsCFEpfyAvMOE,1164
|
|
26
|
+
dndwright-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anthony Sligar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
dndwright
|
|
2
|
+
Copyright (c) 2026 Anthony Sligar
|
|
3
|
+
Licensed under the MIT License (see LICENSE).
|
|
4
|
+
|
|
5
|
+
------------------------------------------------------------------------------
|
|
6
|
+
Game-rules content
|
|
7
|
+
------------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
dndwright's rules tables (hit dice, spellcasting progression / spell slots,
|
|
10
|
+
armor base AC, save proficiencies, class spellcasting abilities, etc.) encode
|
|
11
|
+
game *mechanics* — facts about how D&D 5e (2024) characters are computed. Where
|
|
12
|
+
those facts come from published game content, they derive from the:
|
|
13
|
+
|
|
14
|
+
Dungeons & Dragons System Reference Document 5.2 (SRD 5.2)
|
|
15
|
+
© Wizards of the Coast LLC, licensed under
|
|
16
|
+
Creative Commons Attribution 4.0 International (CC-BY-4.0).
|
|
17
|
+
https://creativecommons.org/licenses/by/4.0/
|
|
18
|
+
|
|
19
|
+
This project is not affiliated with, endorsed, or sponsored by Wizards of the
|
|
20
|
+
Coast. It contains no content from the Player's Handbook, Dungeon Master's
|
|
21
|
+
Guide, Monster Manual, or any other non-SRD source.
|
|
22
|
+
|
|
23
|
+
"Dungeons & Dragons" and "D&D" are trademarks of Wizards of the Coast; they are
|
|
24
|
+
used here only nominatively to describe the rules system this engine computes.
|