mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-05-18 12:13:27 +02:00
Removed duplicates from monsters and monster spells in GM notes.
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
||||
import re
|
||||
import warnings
|
||||
import math
|
||||
import logging
|
||||
from types import ModuleType
|
||||
from typing import Sequence, Union, MutableMapping
|
||||
|
||||
@@ -28,6 +29,9 @@ from dungeonsheets.dice import combine_dice
|
||||
from dungeonsheets.equipment_reader import equipment_weight_parser
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
dice_re = re.compile(r"(\d+)d(\d+)")
|
||||
|
||||
__all__ = (
|
||||
@@ -1060,6 +1064,9 @@ class Character(Creature):
|
||||
char_props["levels"] = [str(char_props.pop("level"))]
|
||||
# Create the character with loaded properties
|
||||
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
|
||||
|
||||
def save(self, filename, template_file="character_template.txt"):
|
||||
|
||||
@@ -280,20 +280,29 @@ def make_gm_sheet(
|
||||
warnings.warn(msg)
|
||||
continue
|
||||
else:
|
||||
# Make sure it's not already on the list
|
||||
if MyMonster in [type(m) for m in monsters_]:
|
||||
break
|
||||
new_monster = MyMonster()
|
||||
monsters_.append(new_monster)
|
||||
if len(monsters_) > 0:
|
||||
content.append(
|
||||
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
|
||||
spells = [Spell() for monster in monsters_ for Spell in monster.spells]
|
||||
spells = set(spells)
|
||||
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))
|
||||
|
||||
# Add the random tables
|
||||
tables = [
|
||||
find_content(s, valid_classes=[random_tables.RandomTable])
|
||||
|
||||
@@ -30,7 +30,7 @@ parent_sheets = ["gm-campaign-notes.py"]
|
||||
|
||||
# Defining a *monsters* attribute will include their stat blocks in
|
||||
# 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
|
||||
# ``extra_sections`` attribute should be a sequence of subclasses of
|
||||
|
||||
Reference in New Issue
Block a user