Removed duplicates from monsters and monster spells in GM notes.

This commit is contained in:
Mark Wolfman
2022-07-30 20:39:44 -05:00
parent a0a6b58e07
commit 1d74ef8f80
3 changed files with 21 additions and 5 deletions
+7
View File
@@ -3,6 +3,7 @@ import os
import re import re
import warnings import warnings
import math import math
import logging
from types import ModuleType from types import ModuleType
from typing import Sequence, Union, MutableMapping from typing import Sequence, Union, MutableMapping
@@ -28,6 +29,9 @@ from dungeonsheets.dice import combine_dice
from dungeonsheets.equipment_reader import equipment_weight_parser from dungeonsheets.equipment_reader import equipment_weight_parser
log = logging.getLogger(__name__)
dice_re = re.compile(r"(\d+)d(\d+)") dice_re = re.compile(r"(\d+)d(\d+)")
__all__ = ( __all__ = (
@@ -1060,6 +1064,9 @@ class Character(Creature):
char_props["levels"] = [str(char_props.pop("level"))] char_props["levels"] = [str(char_props.pop("level"))]
# Create the character with loaded properties # Create the character with loaded properties
char = Cls(**char_props) char = Cls(**char_props)
log.info(f"Imported character: {char}")
log.debug(f"New character classes: {char.class_list} ({char.levels})")
log.debug(f"New character subclasses: {char.subclasses}")
return char return char
def save(self, filename, template_file="character_template.txt"): def save(self, filename, template_file="character_template.txt"):
+13 -4
View File
@@ -280,20 +280,29 @@ def make_gm_sheet(
warnings.warn(msg) warnings.warn(msg)
continue continue
else: else:
# Make sure it's not already on the list
if MyMonster in [type(m) for m in monsters_]:
break
new_monster = MyMonster() new_monster = MyMonster()
monsters_.append(new_monster) monsters_.append(new_monster)
if len(monsters_) > 0: if len(monsters_) > 0:
content.append( content.append(
create_monsters_content( create_monsters_content(
monsters_, suffix=content_suffix, use_dnd_decorations=fancy_decorations set(monsters_), suffix=content_suffix, use_dnd_decorations=fancy_decorations
) )
) )
# Add the GM Spellbook # Add the GM Spellbook
spells = [Spell() for monster in monsters_ for Spell in monster.spells] spells = []
spells = set(spells) for monster in monsters_:
for Spell in monster.spells:
# Make sure it's not already on the list
if Spell not in [type(spl) for spl in spells]:
spells.append(Spell())
# Alphabetical order
spells = sorted(spells, key=lambda x: x.name)
# Generate the content
content.append(create_gm_spellbook(spells, content_suffix)) content.append(create_gm_spellbook(spells, content_suffix))
# Add the random tables # Add the random tables
tables = [ tables = [
find_content(s, valid_classes=[random_tables.RandomTable]) find_content(s, valid_classes=[random_tables.RandomTable])
+1 -1
View File
@@ -30,7 +30,7 @@ parent_sheets = ["gm-campaign-notes.py"]
# Defining a *monsters* attribute will include their stat blocks in # Defining a *monsters* attribute will include their stat blocks in
# the output # the output
monsters = ["aboleth", "wolf", "giant eagle", "Vashta Nerada", "priest"] monsters = ["aboleth", "wolf", "giant eagle", "Vashta Nerada", "priest", "priest"]
# Arbitrary sections can be added to the GM notes. The # Arbitrary sections can be added to the GM notes. The
# ``extra_sections`` attribute should be a sequence of subclasses of # ``extra_sections`` attribute should be a sequence of subclasses of