mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-05-18 20:23:27 +02:00
Included companions and weight management
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user