From d26f520666c1ea65ffef3c5902c9abcfa1e43061 Mon Sep 17 00:00:00 2001 From: Mark Wolfman Date: Tue, 13 Jul 2021 12:28:56 -0500 Subject: [PATCH] Epub for gm notes now prints monster spells, if specified. --- dungeonsheets/forms/monsters_template.html | 10 +++++++ dungeonsheets/monsters/monsters_p.py | 3 ++ examples/gm-session-notes.py | 2 +- tests/test_make_sheets.py | 35 ++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/dungeonsheets/forms/monsters_template.html b/dungeonsheets/forms/monsters_template.html index 924a72c..17d1b87 100644 --- a/dungeonsheets/forms/monsters_template.html +++ b/dungeonsheets/forms/monsters_template.html @@ -64,7 +64,17 @@
Challenge
[[ monster.challenge_rating ]] 
+[% if monster.spells | length > 0 %] +
+ [% for level, spells in monster.spells | groupby('level') %] +
[% if level == 0 %]Cantrips[% else %]Level [[ level ]][% endif %]
+
[[ spells | map(attribute='name') | join(', ') ]]
+ [% endfor %] +
+[% endif %] [[ monster.__doc__ | rst_to_html(top_heading_level=2) ]] + + [% endfor %] diff --git a/dungeonsheets/monsters/monsters_p.py b/dungeonsheets/monsters/monsters_p.py index dbbb429..729311e 100644 --- a/dungeonsheets/monsters/monsters_p.py +++ b/dungeonsheets/monsters/monsters_p.py @@ -403,6 +403,9 @@ class Priest(Monster): climb_speed = 0 hp_max = 27 hit_dice = "5d8" + spells = ["light", "sacred_flame", "thaumaturgy", "cure wounds", + "guiding bolt", "sanctuary", "lesser_restoration", + "spiritual weapon", "dispel magic", "spirit guardians"] class Pseudodragon(Monster): diff --git a/examples/gm-session-notes.py b/examples/gm-session-notes.py index 362547f..97f99b2 100644 --- a/examples/gm-session-notes.py +++ b/examples/gm-session-notes.py @@ -15,4 +15,4 @@ session_title = "Objects in Space - Session 1" parent_sheets = ["gm-campaign-notes.py"] -monsters = ["aboleth", "wolf", "giant eagle", "Vashta Nerada"] +monsters = ["aboleth", "wolf", "giant eagle", "Vashta Nerada", "priest"] diff --git a/tests/test_make_sheets.py b/tests/test_make_sheets.py index 4855df4..931ae96 100644 --- a/tests/test_make_sheets.py +++ b/tests/test_make_sheets.py @@ -135,6 +135,41 @@ class VashtaNerada(monsters.Monster): damage_resistances = "Lightning" damage_vulnerabilities = "Wood-based" challenge_rating = 93 + spells = ["wish"] + + +class HtmlCreatorTestCase(unittest.TestCase): + def test_create_monsters_html(self): + monsters_ = [monsters.Priest()] + html = make_sheets.create_monsters_content(monsters=monsters_, suffix="html") + self.assertIn(r"Priest", html) + # Check extended properties + monsters_ = [VashtaNerada()] + html = make_sheets.create_monsters_content(monsters=monsters_, suffix="html") + self.assertIn(r"Vashta Nerada", html) + self.assertIn(r"35", html) + self.assertIn(r"45 fly", html) + self.assertIn(r"55 swim", html) + self.assertIn(r"65 burrow", html) + self.assertIn(r"petrified", html) + self.assertIn(r"Saving Throws", html) + self.assertIn(r"Damage Immunities", html) + self.assertIn(r"Damage Resistances", html) + self.assertIn(r"Damage Vulnerabilities", html) + self.assertIn(r"Senses", html) + self.assertIn(r"Challenge", html) + self.assertIn(r"Languages", html) + self.assertIn(r"Skills", html) + self.assertIn(r"petrified", html) + self.assertIn(r"Dex +8", html) + # Check spells and spell descriptions + self.assertIn(r"
Level 9
", html) + self.assertIn(r"Wish", html) + # Check fancy extended properties + html = make_sheets.create_monsters_content(monsters=monsters_, + suffix="html", + use_dnd_decorations=True) +