make Dungeons & Dragons characters as serializable objects
Project description
dnd-character
A Python library to make 5e Dungeons & Dragons characters for use in another app. Characters are serializable into Python dicts so they can be saved and loaded however you wish.
SRD rules are fetched from the 5e SRD API the first time they're requested, then the JSON is cached locally for faster retrieval in the future. I've included the json_cache
containing the SRD inside the repo in case this API changes, but when the API does change I will update this library. So please pin your version if you want to avoid any breaking changes.
Installation and Use
- Install from PyPI using
pip install dnd-character
- See
example.py
for example code on how to use the library.
Licenses
The software is EPL-2.0 and the text for this license is in LICENSE
as is standard for software. Originally forked from PyDnD. The contents of dnd_character/json_cache
are retrieved from 5e-srd-api, and are covered by the Open Game License. See dnd_character/json_cache/OGLv1.0a.txt
for details.
Character Object
Normal initialization arguments for a Character object:
name (str)
age (str)
gender (str)
alignment (str): character's two letter alignment
description (str): physical description of player character
biography (str): backstory of player character
level (int): starting level
wealth (int): starting wealth
strength (int)
dexterity (int)
constitution (int)
wisdom (int)
intelligence (int)
charisma (int)
hp (int):
classs (dict): JSON returned from the 5e API -- dnd_character.SRD.SRD_classes["bard"]
In addition, the Character object can receive attributes that are normally set automatically, such as the UUID. This is for re-loading the objects from serialized data (via Character(**characterData)
) and probably aren't arguments you would write manually into your code.
Leveling and Experience
The library should help leveling up characters automatically if you call Character.giveExp(amount)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dnd_character-20.10.31-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af2d2731820b51f2fc426583c8a653c0ed46bb196944ad031750edade399f057 |
|
MD5 | 145ff87b6a423215164f4b2e5b1412e0 |
|
BLAKE2b-256 | df95262e202651c5b24a879c965e5d33508c1b817832d5602e92324a19ba7b06 |