testing all new class features

This commit is contained in:
Ben Cook
2019-01-01 16:17:00 -05:00
parent 73cb2b5e16
commit 708a39403c
52 changed files with 2117 additions and 213 deletions
+11 -4
View File
@@ -616,11 +616,18 @@ class Character():
"""
# Retrieve the weapon class from the weapons module
try:
NewWeapon = findattr(weapons, weapon)
except AttributeError:
if isinstance(weapon, weapons.Weapon):
weapon_ = type(weapon)()
elif isinstance(weapon, str):
try:
NewWeapon = findattr(weapons, weapon)
except AttributeError:
raise AttributeError(f'Weapon "{weapon}" is not defined')
weapon_ = NewWeapon()
elif issubclass(weapon, weapons.Weapon):
weapon_ = weapon()
else:
raise AttributeError(f'Weapon "{weapon}" is not defined')
weapon_ = NewWeapon()
# check if features add any bonuses
for f in self.features:
weapon_ = f.weapon_func(weapon_)