Swords add strength

This commit is contained in:
Yohann D'ANELLO 2020-12-18 17:39:11 +01:00
parent fe769c4488
commit 1b4612afd0

View File

@ -225,9 +225,28 @@ class Sword(Weapon):
"""
A basic weapon
"""
def __init__(self, name: str = "sword", price: int = 20, *args, **kwargs):
strength: int
def __init__(self, name: str = "sword", price: int = 20, strength: int = 3,
*args, **kwargs):
super().__init__(name=name, price=price, *args, **kwargs)
self.name = name
self.strength = strength
def equip(self) -> None:
"""
When a sword is equipped, the player gains strength.
"""
super().equip()
self.held_by.strength += self.strength
def unequip(self) -> None:
"""
Remove the strength earned by the sword.
:return:
"""
super().unequip()
self.held_by.strength -= self.strength
class BodySnatchPotion(Item):