From 1b4612afd05991a62f0ea75308e986f500ae996e Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 18 Dec 2020 17:39:11 +0100 Subject: [PATCH] Swords add strength --- squirrelbattle/entities/items.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/squirrelbattle/entities/items.py b/squirrelbattle/entities/items.py index 9719e3a..5564cb0 100644 --- a/squirrelbattle/entities/items.py +++ b/squirrelbattle/entities/items.py @@ -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):