Included companions and weight management

This commit is contained in:
bw-mutley
2022-03-19 12:31:03 -03:00
committed by GitHub
parent de1506c13f
commit f2949521d7
5 changed files with 361 additions and 13 deletions
+22 -3
View File
@@ -86,14 +86,20 @@ def create_monsters_content(
monsters: Sequence[Union[monsters.Monster, str]],
suffix: str,
use_dnd_decorations: bool = False,
base_template: str = "monsters_template"
) -> str:
# Convert strings to Monster objects
template = jinja_env.get_template(f"monsters_template.{suffix}")
template = jinja_env.get_template(base_template+f".{suffix}")
spell_list = [Spell() for monster in monsters for Spell in monster.spells]
return template.render(monsters=monsters,
use_dnd_decorations=use_dnd_decorations, spell_list=spell_list)
def create_gm_spellbook(spell_list, suffix):
template = jinja_env.get_template(f"gm_spellbook_template.{suffix}")
return template.render(spells=spell_list)
def create_party_summary_content(
party: Sequence[Creature],
summary_rst: str,
@@ -282,6 +288,12 @@ def make_gm_sheet(
monsters_, suffix=content_suffix, use_dnd_decorations=fancy_decorations
)
)
# Add the GM Spellbook
spells = [Spell() for monster in monsters_ for Spell in monster.spells]
spells = set(spells)
content.append(create_gm_spellbook(spells, content_suffix))
# Add the random tables
tables = [
find_content(s, valid_classes=[random_tables.RandomTable])
@@ -414,6 +426,13 @@ def make_character_content(
content.append(
create_druid_shapes_content(character, content_suffix=content_format, use_dnd_decorations=fancy_decorations)
)
# Create a list of companions
if len(getattr(character, "companions", [])) > 0:
content.append(
create_monsters_content(character.companions, suffix=content_format,
use_dnd_decorations=fancy_decorations, base_template="companions_template")
)
# Postamble, empty for HTML
content.append(
jinja_env.get_template(f"postamble.{content_format}").render(
@@ -479,8 +498,8 @@ def make_character_sheet(
character_props = readers.read_sheet_file(char_file)
character = _char.Character.load(character_props)
# Load image file if present
portrait_file=""
if character.portrait:
portrait_file = character.portrait
if portrait_file is True:
portrait_file=char_file.stem + ".jpeg"
# Set the fields in the FDF
basename = char_file.stem