From 6b72f4b284f77517f32399a6e32042c38e87d523 Mon Sep 17 00:00:00 2001 From: eichhornchen Date: Fri, 20 Nov 2020 17:42:56 +0100 Subject: [PATCH] Added a friendly entity class. --- squirrelbattle/interfaces.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index d1baa2a..7fc4171 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -422,3 +422,17 @@ class FightingEntity(Entity): for name in self.keys(): d[name] = getattr(self, name) return d + +class FriendlyEntity(Entity): + """ + Friendly entities are living entities which do not attack the player + """ + maxhealth: int + health: int #Friendly entities can be killed + + def __init__(self, maxhealth: int = 0, health: Optional[int] = None, + *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + self.maxhealth = maxhealth + self.health = maxhealth if health is None else health +