From 8b56d5c6510b29f682fd9bda64866c2c4affc6fc Mon Sep 17 00:00:00 2001 From: Robert Kubosz Date: Tue, 12 May 2020 14:51:33 +0200 Subject: [PATCH] artificer is now fully usable Now user can pick Artificer and it works as it should. This commit adds spell slot calculations for multiclassing with Artificer. --- dungeonsheets/character.py | 29 ++++++++++++++++++++-- dungeonsheets/classes/artificer.py | 1 + dungeonsheets/forms/infusions_template.tex | 12 ++++++--- dungeonsheets/infusions.py | 2 +- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/dungeonsheets/character.py b/dungeonsheets/character.py index 0bbe21c..70358a0 100644 --- a/dungeonsheets/character.py +++ b/dungeonsheets/character.py @@ -6,11 +6,13 @@ import os import re import subprocess import warnings +import math import jinja2 from dungeonsheets import (armor, background, classes, exceptions, features, - magic_items, monsters, race, spells, weapons) + infusions, magic_items, monsters, race, spells, + weapons) from dungeonsheets.armor import Armor, NoArmor, NoShield, Shield from dungeonsheets.dice import read_dice_str from dungeonsheets.stats import (Ability, ArmorClass, Initiative, Skill, Speed, @@ -27,7 +29,7 @@ __version__ = read('../VERSION').strip() dice_re = re.compile('(\d+)d(\d+)') -__all__ = ('Barbarian', 'Bard', 'Cleric', 'Druid', 'Fighter', 'Monk', +__all__ = ('Artificer', 'Barbarian', 'Bard', 'Cleric', 'Druid', 'Fighter', 'Monk', 'Paladin', 'Ranger', 'Rogue', 'Sorcerer', 'Warlock', 'Wizard', ) multiclass_spellslots_by_level = { @@ -128,6 +130,7 @@ class Character(): spellcasting_ability = None _spells = list() _spells_prepared = list() + infusions = list() # Features IN MAJOR DEVELOPMENT custom_features = list() feature_choices = list() @@ -171,6 +174,7 @@ class Character(): self._proficiencies_text = list() self._spells = list() self._spells_prepared = list() + self.infusions = list() self.custom_features = list() self.feature_choices = list() @@ -417,6 +421,8 @@ class Character(): eff_level += c.level // 2 elif type(c) in [classes.Fighter, classes.Rogue]: eff_level += c.level // 3 + elif type(c) is classes.Artificer: + eff_level += math.ceil(c.level / 2) if eff_level == 0: return 0 else: @@ -516,6 +522,18 @@ class Character(): else: # Instantiate them all for the spells list self._spells_prepared = tuple(S() for S in _spells) + elif attr == 'infusions': + if hasattr(self, 'Artificer'): + _infusions = [] + for infusion_name in val: + try: + _infusions.append(findattr(infusions, infusion_name)) + except AttributeError: + msg = (f'Infusion "{infusion_name}" not defined. ' + f'Please add it to ``infusions.py``') + warnings.warn(msg) + _infusions.sort(key=lambda infusion: infusion.name) + self.infusions = tuple(I() for I in _infusions) else: if not hasattr(self, attr): warnings.warn(f"Setting unknown character attribute {attr}", @@ -788,6 +806,13 @@ def read_character_file(filename): # Add backwards compatability for tests +class Artificer(Character): + def __init__(self, level=1, **attrs): + attrs['classes'] = ['Artificer'] + attrs['levels'] = [level] + super().__init__(**attrs) + + class Barbarian(Character): def __init__(self, level=1, **attrs): attrs['classes'] = ['Barbarian'] diff --git a/dungeonsheets/classes/artificer.py b/dungeonsheets/classes/artificer.py index e6103e0..bfdb3a5 100644 --- a/dungeonsheets/classes/artificer.py +++ b/dungeonsheets/classes/artificer.py @@ -84,6 +84,7 @@ class Artificer(CharClass): "Light armor", "Medium armor", "Shields", "Thieve's tools", "Tinker's tools") weapon_proficiencies = (weapons.SimpleWeapon,) + infusions = [] class_skill_choices = ( 'Arcana', 'History', 'Investigation', 'Medicine', 'Nature', 'Perception', 'Sleight of Hand') diff --git a/dungeonsheets/forms/infusions_template.tex b/dungeonsheets/forms/infusions_template.tex index 9e9d10c..bbb9c4e 100644 --- a/dungeonsheets/forms/infusions_template.tex +++ b/dungeonsheets/forms/infusions_template.tex @@ -10,7 +10,7 @@ [% endif %] \title{Infusion Descriptions} -\author{[[ character.name ]]} +\author{[[ character.name ]] (Artificer [[ character.Artificer.level ]] level)} \date{} \begin{document} @@ -22,13 +22,17 @@ \section*{[[ inf.name ]]} [% if inf.prerequisite %]% + + \noindent \textit{Prerequisite: [[ inf.prerequisite ]]}% + [% endif %]% [% if inf.item %]% - \textit{Item: [[ inf.item ]]}% - [% endif %]% - %% \noindent + \noindent + \textit{Item: [[ inf.item ]]}% + + [% endif %]% [[ inf.__doc__|rst_to_latex ]] diff --git a/dungeonsheets/infusions.py b/dungeonsheets/infusions.py index 8df55dd..99f042c 100644 --- a/dungeonsheets/infusions.py +++ b/dungeonsheets/infusions.py @@ -9,7 +9,7 @@ class Infusion(): def __str__(self): indicator = ('$', self.special_material) if indicator: - return self.name += f' ({"".join(indicator)})' + return self.name + f' ({"".join(indicator)})' else: return self.name