From ca86572677829b433dd4a325c27a0434f5635f5f Mon Sep 17 00:00:00 2001 From: eichhornchen Date: Fri, 27 Nov 2020 17:56:01 +0100 Subject: [PATCH] Added a weapon class and a sword subclass --- squirrelbattle/entities/items.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/squirrelbattle/entities/items.py b/squirrelbattle/entities/items.py index 9927ef4..f5da235 100644 --- a/squirrelbattle/entities/items.py +++ b/squirrelbattle/entities/items.py @@ -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" +