mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-06-13 16:13:32 +02:00
Ran flake8 and black linters, and other cleanup-related fixes.
Project now passes flake8 and black linter (also including more rst cleanup). Moved latex related things to dedicated ``latex.py`` module, and removed the ``makesheets -dF`` call from travis.
This commit is contained in:
@@ -11,28 +11,29 @@ def all_spells():
|
||||
|
||||
def create_spell(**params):
|
||||
"""Create a new subclass of ``Spell`` with given default parameters.
|
||||
|
||||
|
||||
Useful for spells that haven't been entered into the ``spells.py``
|
||||
file yet.
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
params : optional
|
||||
Saved as attributes of the new class.
|
||||
|
||||
|
||||
Returns
|
||||
-------
|
||||
NewSpell
|
||||
New spell class, subclass of ``Spell``, with given params.
|
||||
"""
|
||||
NewSpell = Spell
|
||||
NewSpell.name = params.get('name', 'Unknown Spell')
|
||||
NewSpell.level = params.get('level', 9)
|
||||
NewSpell.name = params.get("name", "Unknown Spell")
|
||||
NewSpell.level = params.get("level", 9)
|
||||
return NewSpell
|
||||
|
||||
|
||||
class Spell():
|
||||
class Spell:
|
||||
"""A magical spell castable by a player character."""
|
||||
|
||||
level = 0
|
||||
name = "Unknown spell"
|
||||
casting_time = "1 action"
|
||||
@@ -44,38 +45,42 @@ class Spell():
|
||||
_concentration = False
|
||||
magic_school = ""
|
||||
classes = ()
|
||||
|
||||
|
||||
def __str__(self):
|
||||
if len(self.components) == 0:
|
||||
s = self.name
|
||||
else:
|
||||
s = self.name + ' ({:s}) '.format(','.join(self.components))
|
||||
s = self.name + " ({:s}) ".format(",".join(self.components))
|
||||
# Indicate if this is a ritual or a concentration
|
||||
indicators = [('R', self.ritual), ('C', self.concentration), ('$', self.special_material)]
|
||||
indicators = [
|
||||
("R", self.ritual),
|
||||
("C", self.concentration),
|
||||
("$", self.special_material),
|
||||
]
|
||||
indicators = tuple(letter for letter, is_active in indicators if is_active)
|
||||
if len(indicators):
|
||||
s += f' ({", ".join(indicators)})'
|
||||
return s
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return "\"{:s}\"".format(self.name)
|
||||
return '"{:s}"'.format(self.name)
|
||||
|
||||
def __eq__(self, other):
|
||||
return (self.name == other.name) and (self.level == other.level)
|
||||
|
||||
def __hash__(self):
|
||||
return 0
|
||||
|
||||
|
||||
@property
|
||||
def component_string(self):
|
||||
s = f'{", ".join(self.components)}'
|
||||
if "M" in self.components:
|
||||
s += f' ({self.materials})'
|
||||
s += f" ({self.materials})"
|
||||
return s
|
||||
|
||||
|
||||
@property
|
||||
def concentration(self):
|
||||
return ('concentration' in self.duration.lower()) or self._concentration
|
||||
return ("concentration" in self.duration.lower()) or self._concentration
|
||||
|
||||
@concentration.setter
|
||||
def concentration(self, val: bool):
|
||||
@@ -83,5 +88,4 @@ class Spell():
|
||||
|
||||
@property
|
||||
def special_material(self):
|
||||
return ('worth at least' in self.materials.lower())
|
||||
|
||||
return "worth at least" in self.materials.lower()
|
||||
|
||||
Reference in New Issue
Block a user