Functions to build 2nd page of the character sheet

This commit is contained in:
tim_jackins
2021-05-28 11:26:56 -04:00
parent 428b9ea2e3
commit ca4bed23cf
2 changed files with 31 additions and 1 deletions
+24
View File
@@ -172,6 +172,30 @@ def create_character_pdf_template(character, basename, flatten=False):
return make_pdf(fields, src_pdf=src_pdf, basename=basename, flatten=flatten)
def create_personality_pdf_template(character, basename, flatten=False):
# Prepare the list of fields
fields = {
"CharacterName 2": character.name,
"Age": str(character.age),
"Height": character.height,
"Weight": character.weight,
"Eyes": character.eyes,
"Skin": character.skin,
"Hair": character.hair,
# "CHARACTER IMAGE": None
# "Faction Symbol Image": None
"Allies": text_box(character.allies),
"FactionName": character.faction_name,
"Backstory": text_box(character.backstory),
"Feat+Traits": text_box(character.other_feats_traits),
"Treasure": text_box(character.treasure)
}
# Prepare the actual PDF
dirname = os.path.join(os.path.dirname(os.path.abspath(__file__)), "forms/")
src_pdf = os.path.join(dirname, "blank-personality-sheet-default.pdf")
return make_pdf(fields, src_pdf=src_pdf, basename=basename, flatten=flatten)
def create_spells_pdf_template(character, basename, flatten=False):
classes_and_levels = " / ".join(
[c.name + " " + str(c.level) for c in character.spellcasting_classes]
+7 -1
View File
@@ -17,6 +17,7 @@ from dungeonsheets import exceptions, readers, latex
from dungeonsheets.stats import mod_str
from dungeonsheets.fill_pdf_template import (
create_character_pdf_template,
create_personality_pdf_template,
create_spells_pdf_template,
)
from dungeonsheets.character import Character
@@ -136,7 +137,8 @@ def make_sheet(
# Set the fields in the FDF
char_base = os.path.splitext(character_file)[0] + "_char"
sheets = [char_base + ".pdf"]
person_base = os.path.splitext(character_file)[0] + "_person"
sheets = [char_base + ".pdf", person_base + ".pdf"]
pages = []
tex = [
jinja_env.get_template("preamble.tex").render(
@@ -149,6 +151,10 @@ def make_sheet(
character=character, basename=char_base, flatten=flatten
)
pages.append(char_pdf)
person_pdf = create_personality_pdf_template(
character=character, basename=person_base, flatten=flatten
)
pages.append(person_pdf)
if character.is_spellcaster:
# Create spell sheet
spell_base = "{:s}_spells".format(os.path.splitext(character_file)[0])