mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-06-07 13:15:53 +02:00
splits out features to multiple templates and added DnD styling
This commit is contained in:
@@ -392,7 +392,7 @@ class Character:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def subclasses(self):
|
def subclasses(self):
|
||||||
return list([c.subclass or "" for c in self.class_list])
|
return [c.subclass for c in self.class_list if c.subclass is not None]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def level(self):
|
def level(self):
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ class SubClass:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
name = ""
|
name = ""
|
||||||
|
character_class = CharClass
|
||||||
features_by_level = defaultdict(list)
|
features_by_level = defaultdict(list)
|
||||||
weapon_proficiencies = ()
|
weapon_proficiencies = ()
|
||||||
_proficiencies_text = ()
|
_proficiencies_text = ()
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class DwarvenToughness(Feature):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = "DwarvenToughness"
|
name = "Dwarven Toughness"
|
||||||
source = "Race (Hill Dwarf)"
|
source = "Race (Hill Dwarf)"
|
||||||
needs_implementation = True
|
needs_implementation = True
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
\newpage
|
|
||||||
\section*{Known Beasts}
|
\section*{Known Beasts}
|
||||||
|
|
||||||
[% if use_dnd_decorations %]
|
[% if use_dnd_decorations %]
|
||||||
[% for shape in character.all_wild_shapes|sort(attribute='challenge_rating') %]
|
[% for shape in character.all_wild_shapes|sort(attribute='challenge_rating') %]
|
||||||
[% if not character.can_assume_shape(shape) %]
|
[% if not character.can_assume_shape(shape) %]
|
||||||
\subsection*{Cannot assume form}
|
\subsection*{Cannot assume form}
|
||||||
[% endif %]
|
[% endif %]
|
||||||
\begin{DndMonster}{[[ shape.name ]]}
|
\begin{DndMonster}{[[ shape.name ]]}
|
||||||
\DndMonsterType{[[ shape.description ]]}
|
\DndMonsterType{[[ shape.description ]]}
|
||||||
|
|||||||
@@ -1,44 +1,23 @@
|
|||||||
\section*{Subclasses}
|
\section*{Features}
|
||||||
|
[% if use_dnd_decorations %]
|
||||||
|
[% for feat in character.features %]
|
||||||
|
\DndFeatHeader{[[ feat.name ]]}[Source: [[ feat.source ]]]
|
||||||
|
|
||||||
[% for sc in character.subclasses if sc not in ['', None, 'None', 'none']%]
|
[[ feat.__doc__|rst_to_latex ]]
|
||||||
|
[% endfor %]
|
||||||
|
[% else %]
|
||||||
|
[% for feat in character.features %]
|
||||||
|
|
||||||
\subsection*{Subclass: [[ sc.name ]]}
|
\subsection*{[[ feat.name ]]}
|
||||||
|
|
||||||
[[ sc.__doc__ | rst_to_latex(top_heading_level=2) ]]
|
\noindent
|
||||||
|
\textbf{Source:} [[ feat.source ]] \\
|
||||||
|
|
||||||
[% endfor %]
|
[% if feat.needs_implementation %] %
|
||||||
|
\textbf{**Not included in stats on Character Sheet} %
|
||||||
|
[% endif %] %
|
||||||
|
|
||||||
\section*{Features}
|
[[ feat.__doc__|rst_to_latex ]]
|
||||||
|
|
||||||
[% for feat in character.features %]
|
|
||||||
|
|
||||||
\subsection*{[[ feat.name ]]}
|
|
||||||
|
|
||||||
\noindent
|
|
||||||
\textbf{Source:} [[ feat.source ]] \\
|
|
||||||
|
|
||||||
[% if feat.needs_implementation %] %
|
|
||||||
\textbf{**Not included in stats on Character Sheet} %
|
|
||||||
[% endif %] %
|
|
||||||
|
|
||||||
[[ feat.__doc__|rst_to_latex ]]
|
|
||||||
|
|
||||||
[% endfor %]
|
|
||||||
|
|
||||||
\section*{Magic Items}
|
|
||||||
|
|
||||||
[% for mitem in character.magic_items %]
|
|
||||||
|
|
||||||
\subsection*{[[ mitem.name ]]}
|
|
||||||
|
|
||||||
\noindent
|
|
||||||
\textbf{Requires Attunement:} [[ mitem.requires_attunement ]] \\
|
|
||||||
\textbf{Rarity:} [[ mitem.rarity ]] \\
|
|
||||||
|
|
||||||
[% if mitem.needs_implementation %] %
|
|
||||||
\textbf{**Not included in stats on Character Sheet} %
|
|
||||||
[% endif %] %
|
|
||||||
|
|
||||||
[[ mitem.__doc__|rst_to_latex ]]
|
|
||||||
|
|
||||||
[% endfor %]
|
[% endfor %]
|
||||||
|
[% endif %]
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
\section*{Magic Items}
|
||||||
|
|
||||||
|
[% if use_dnd_decorations %]
|
||||||
|
[% for mitem in character.magic_items %]
|
||||||
|
\DndItemHeader{[[ mitem.name ]]}{[% if mitem.item_type %][[ mitem.item_type ]], [[ mitem.rarity.lower() ]][% else %][[ mitem.rarity ]] item[% endif %][% if mitem.requires_attunement %] (requires attunement)[% endif %]}
|
||||||
|
[% if mitem.needs_implementation %] %
|
||||||
|
\textbf{**Not included in stats on Character Sheet} %
|
||||||
|
[% endif %] %
|
||||||
|
|
||||||
|
[[ mitem.__doc__|rst_to_latex ]]
|
||||||
|
[% endfor %]
|
||||||
|
[% else %]
|
||||||
|
[% for mitem in character.magic_items %]
|
||||||
|
|
||||||
|
\subsection*{[[ mitem.name ]]}
|
||||||
|
|
||||||
|
\noindent
|
||||||
|
\textbf{Requires Attunement:} [[ mitem.requires_attunement ]] \\
|
||||||
|
\textbf{Rarity:} [[ mitem.rarity ]] \\
|
||||||
|
|
||||||
|
[% if mitem.needs_implementation %] %
|
||||||
|
\textbf{**Not included in stats on Character Sheet} %
|
||||||
|
[% endif %] %
|
||||||
|
|
||||||
|
[[ mitem.__doc__|rst_to_latex ]]
|
||||||
|
|
||||||
|
[% endfor %]
|
||||||
|
[% endif %]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
\documentclass[10pt,twocolumn,lettersize]{article}
|
\documentclass[10pt,twocolumn,lettersize]{book}
|
||||||
|
|
||||||
% For parsed docstrings
|
% For parsed docstrings
|
||||||
\usepackage[T1]{fontenc}
|
\usepackage[T1]{fontenc}
|
||||||
@@ -51,3 +51,4 @@
|
|||||||
[% endraw %]
|
[% endraw %]
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
|
\chapter*{Features, Magical Items and Spells}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
\section*{Subclasses}
|
||||||
|
[% if use_dnd_decorations %]
|
||||||
|
[% for sc in character.subclasses if sc not in ['', None, 'None', 'none']%]
|
||||||
|
\DndFeatHeader{[[ sc.name ]]}
|
||||||
|
|
||||||
|
[[ sc.__doc__ | rst_to_latex(top_heading_level=2) ]]
|
||||||
|
|
||||||
|
[% endfor %]
|
||||||
|
[% else %]
|
||||||
|
[% for sc in character.subclasses if sc not in ['', None, 'None', 'none']%]
|
||||||
|
|
||||||
|
\subsection*{[[ sc.name ]]}
|
||||||
|
|
||||||
|
[[ sc.__doc__ | rst_to_latex(top_heading_level=2) ]]
|
||||||
|
|
||||||
|
[% endfor %]
|
||||||
|
[% endif %]
|
||||||
@@ -65,7 +65,7 @@ def create_latex_pdf(
|
|||||||
"-interaction=nonstopmode",
|
"-interaction=nonstopmode",
|
||||||
tex_file,
|
tex_file,
|
||||||
]
|
]
|
||||||
passes = 2 if use_dnd_decorations else 1
|
passes = 3 if use_dnd_decorations else 1
|
||||||
try:
|
try:
|
||||||
for i in range(passes):
|
for i in range(passes):
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class MagicItem:
|
|||||||
requires_attunement = False
|
requires_attunement = False
|
||||||
needs_implementation = False
|
needs_implementation = False
|
||||||
rarity = ""
|
rarity = ""
|
||||||
|
item_type = ""
|
||||||
|
|
||||||
def __init__(self, owner=None):
|
def __init__(self, owner=None):
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
@@ -42,6 +43,7 @@ class RingOfProtection(MagicItem):
|
|||||||
ac_bonus = 1
|
ac_bonus = 1
|
||||||
requires_attunement = True
|
requires_attunement = True
|
||||||
rarity = "Rare"
|
rarity = "Rare"
|
||||||
|
item_type = "Ring"
|
||||||
|
|
||||||
|
|
||||||
class DecanterOfEndlessWater(MagicItem):
|
class DecanterOfEndlessWater(MagicItem):
|
||||||
@@ -70,6 +72,7 @@ class DecanterOfEndlessWater(MagicItem):
|
|||||||
|
|
||||||
name = "Decanter of Endless Water"
|
name = "Decanter of Endless Water"
|
||||||
rarity = "Uncommon"
|
rarity = "Uncommon"
|
||||||
|
item_type = "Wondrous item"
|
||||||
|
|
||||||
|
|
||||||
class ToothOfAnimalFriendship(MagicItem):
|
class ToothOfAnimalFriendship(MagicItem):
|
||||||
|
|||||||
@@ -134,22 +134,26 @@ jinja_env.filters["mod_str"] = mod_str
|
|||||||
PDFTK_CMD = "pdftk"
|
PDFTK_CMD = "pdftk"
|
||||||
|
|
||||||
|
|
||||||
def create_druid_shapes_tex(
|
def create_subclasses_tex(
|
||||||
character: Character,
|
character: Character,
|
||||||
use_dnd_decorations: bool = False,
|
use_dnd_decorations: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
template = jinja_env.get_template("druid_shapes_template.tex")
|
template = jinja_env.get_template("subclasses_template.tex")
|
||||||
return template.render(character=character, use_dnd_decorations=use_dnd_decorations)
|
return template.render(character=character, use_dnd_decorations=use_dnd_decorations)
|
||||||
|
|
||||||
|
def create_features_tex(
|
||||||
|
|
||||||
def create_infusions_tex(
|
|
||||||
character: Character,
|
character: Character,
|
||||||
use_dnd_decorations: bool = False,
|
use_dnd_decorations: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
template = jinja_env.get_template("infusions_template.tex")
|
template = jinja_env.get_template("features_template.tex")
|
||||||
return template.render(character=character, use_dnd_decorations=use_dnd_decorations)
|
return template.render(character=character, use_dnd_decorations=use_dnd_decorations)
|
||||||
|
|
||||||
|
def create_magic_items_tex(
|
||||||
|
character: Character,
|
||||||
|
use_dnd_decorations: bool = False,
|
||||||
|
) -> str:
|
||||||
|
template = jinja_env.get_template("magic_items_template.tex")
|
||||||
|
return template.render(character=character, use_dnd_decorations=use_dnd_decorations)
|
||||||
|
|
||||||
def create_spellbook_tex(
|
def create_spellbook_tex(
|
||||||
character: Character,
|
character: Character,
|
||||||
@@ -158,12 +162,18 @@ def create_spellbook_tex(
|
|||||||
template = jinja_env.get_template("spellbook_template.tex")
|
template = jinja_env.get_template("spellbook_template.tex")
|
||||||
return template.render(character=character, ordinals=ORDINALS, use_dnd_decorations=use_dnd_decorations)
|
return template.render(character=character, ordinals=ORDINALS, use_dnd_decorations=use_dnd_decorations)
|
||||||
|
|
||||||
|
def create_infusions_tex(
|
||||||
def create_features_tex(
|
|
||||||
character: Character,
|
character: Character,
|
||||||
use_dnd_decorations: bool = False,
|
use_dnd_decorations: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
template = jinja_env.get_template("features_template.tex")
|
template = jinja_env.get_template("infusions_template.tex")
|
||||||
|
return template.render(character=character, use_dnd_decorations=use_dnd_decorations)
|
||||||
|
|
||||||
|
def create_druid_shapes_tex(
|
||||||
|
character: Character,
|
||||||
|
use_dnd_decorations: bool = False,
|
||||||
|
) -> str:
|
||||||
|
template = jinja_env.get_template("druid_shapes_template.tex")
|
||||||
return template.render(character=character, use_dnd_decorations=use_dnd_decorations)
|
return template.render(character=character, use_dnd_decorations=use_dnd_decorations)
|
||||||
|
|
||||||
|
|
||||||
@@ -217,23 +227,35 @@ def make_sheet(
|
|||||||
sheets.append(spell_base + ".pdf")
|
sheets.append(spell_base + ".pdf")
|
||||||
# end of PDF gen
|
# end of PDF gen
|
||||||
|
|
||||||
|
features_base = "{:s}_features".format(os.path.splitext(character_file)[0])
|
||||||
|
# Create a list of subcasses
|
||||||
|
if character.subclasses:
|
||||||
|
tex.append(create_subclasses_tex(character, use_dnd_decorations=fancy_decorations))
|
||||||
|
|
||||||
|
# Create a list of features
|
||||||
|
if character.features:
|
||||||
|
tex.append(create_features_tex(character, use_dnd_decorations=fancy_decorations))
|
||||||
|
|
||||||
|
if character.magic_items:
|
||||||
|
tex.append(create_magic_items_tex(character, use_dnd_decorations=fancy_decorations))
|
||||||
|
|
||||||
|
# Create a list of spells
|
||||||
if character.is_spellcaster:
|
if character.is_spellcaster:
|
||||||
tex.append(create_spellbook_tex(character, use_dnd_decorations=fancy_decorations))
|
tex.append(create_spellbook_tex(character, use_dnd_decorations=fancy_decorations))
|
||||||
|
|
||||||
# Create a list of Artificer infusions
|
# Create a list of Artificer infusions
|
||||||
infusions = getattr(character, "infusions", [])
|
if getattr(character, "infusions", []):
|
||||||
if len(infusions) > 0:
|
|
||||||
tex.append(create_infusions_tex(character, use_dnd_decorations=fancy_decorations))
|
tex.append(create_infusions_tex(character, use_dnd_decorations=fancy_decorations))
|
||||||
|
|
||||||
# Create a list of Druid wild_shapes
|
# Create a list of Druid wild_shapes
|
||||||
wild_shapes = getattr(character, "wild_shapes", [])
|
if getattr(character, "wild_shapes", []):
|
||||||
if len(wild_shapes) > 0:
|
|
||||||
tex.append(create_druid_shapes_tex(character, use_dnd_decorations=fancy_decorations))
|
tex.append(create_druid_shapes_tex(character, use_dnd_decorations=fancy_decorations))
|
||||||
|
|
||||||
|
|
||||||
tex.append(jinja_env.get_template("postamble.tex").render(use_dnd_decorations=fancy_decorations))
|
tex.append(jinja_env.get_template("postamble.tex").render(use_dnd_decorations=fancy_decorations))
|
||||||
latex.create_latex_pdf("".join(tex), "name", keep_temp_files=debug)
|
latex.create_latex_pdf("".join(tex), features_base, keep_temp_files=debug)
|
||||||
if len(tex) > 2:
|
if len(tex) > 2:
|
||||||
sheets.append("name.pdf")
|
sheets.append(features_base + ".pdf")
|
||||||
# Typeset combined LaTeX file
|
# Typeset combined LaTeX file
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user