save function now works for a character... need to add defaults if options dont exist

This commit is contained in:
Ben Cook
2018-12-20 10:35:50 -05:00
parent b93b1ac6d7
commit 2b1f5981b4
10 changed files with 116 additions and 50 deletions
+7 -2
View File
@@ -14,7 +14,9 @@ def create_spell(**params):
NewSpell
New spell class, subclass of ``Spell``, with given params.
"""
NewSpell = type('UnknownSpell', (Spell,), params)
NewSpell = Spell
NewSpell.name = params.get('name', 'Unknown Spell')
NewSpell.level = params.get('level', 9)
return NewSpell
@@ -41,8 +43,11 @@ class Spell():
return s
def __repr__(self):
return f'<{self.name}>'
return "\"{:s}\"".format(self.name)
def __eq__(self, other):
return (self.name == other.name) and (self.level == other.level)
@property
def component_string(self):
s = f'{", ".join(self.components)}'