Prepared package for adding GM sheets.

- Improved test coverage in ``make_sheets.py``.
- Refactor file loading to make it more flexible.
- Added a stub ``gm.py`` example.
This commit is contained in:
Mark Wolfman
2021-06-01 22:51:10 -05:00
parent bb3a40ed0e
commit 3b8dbc0566
7 changed files with 116 additions and 19 deletions
+21 -5
View File
@@ -4,7 +4,7 @@ import re
import warnings
import math
from types import ModuleType
from typing import Sequence, Union
from typing import Sequence, Union, MutableMapping
import jinja2
@@ -22,7 +22,7 @@ from dungeonsheets import (
)
from dungeonsheets.stats import findattr
from dungeonsheets.weapons import Weapon
from dungeonsheets.readers import read_character_file
from dungeonsheets.readers import read_sheet_file
from dungeonsheets.entity import Entity
@@ -884,9 +884,25 @@ class Character(Entity):
return ()
@classmethod
def load(Cls, character_file):
# Create a character from the character definition
char_props = read_character_file(character_file)
def load(Cls, char_props: MutableMapping):
"""Factory Creates a character from the character definition.
Parameters
==========
char_props
Keys and values holding all the attributes of the
character. E.g. ``char_props['strength'] = 16``
Returns
=======
char
The initialized ``Character`` object with associated
parameters.
"""
# Parse the sheet type
char_props.pop('sheet_type', "")
# Load classes
classes = char_props.get("classes", [])
# backwards compatability
if (len(classes) == 0) and ("character_class" in char_props):