Added a weapon class and a sword subclass
This commit is contained in:
parent
3f301423fb
commit
ca86572677
|
@ -107,3 +107,30 @@ class Bomb(Item):
|
||||||
d["exploding"] = self.exploding
|
d["exploding"] = self.exploding
|
||||||
d["damage"] = self.damage
|
d["damage"] = self.damage
|
||||||
return d
|
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"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue