Added a weapon class and a sword subclass

This commit is contained in:
eichhornchen 2020-11-27 17:56:01 +01:00
parent 3f301423fb
commit ca86572677

View File

@ -107,3 +107,30 @@ class Bomb(Item):
d["exploding"] = self.exploding
d["damage"] = self.damage
return d
class Weapon(Item):
"""
Non-throwable items that improve player damage
"""
damage: int
def __init__(self, damage: int = 3, *args, **kwargs):
super().__init__(*args, **kwargs)
self.damage = damage
def save_state(self) -> dict:
"""
Saves the state of the weapon into a dictionary
"""
d = super().save_state()
d["damage"] = self.damage
return d
class Sword(Weapon) :
"""
A basic weapon
"""
def __init__(self, name: int, *args, **kwargs):
super().__init__(*args, **kwargs)
self.name = "sword"