From c6ab7cc2f46fc66f1387e19ce84b7c39aa7c3fc3 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Mon, 6 Apr 2020 10:29:43 +0200 Subject: [PATCH] Refactor: interactable now has methods from pickupable --- src/entities/Interactable.py | 26 ++++++++------------------ src/entities/Pickupable.py | 8 -------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/entities/Interactable.py b/src/entities/Interactable.py index a3f3fb9..d3e399b 100644 --- a/src/entities/Interactable.py +++ b/src/entities/Interactable.py @@ -2,23 +2,13 @@ from src.entities.Entity import Entity class Interactable(Entity): + def __init__(self, texture, size, pos, Statistics): + super().__init__(texture, size, pos, Statistics) + self.Statistics = Statistics - def __init__(self, texture, pos, id): - super().__init__(texture, pos, id) - - @staticmethod - def interact_with_hp(hp, Statistics): - Statistics.set_hp(hp) - - @staticmethod - def interact_with_hunger(hunger, Statistics): - Statistics.set_hunger(hunger) - - @staticmethod - def interact_with_thirst(thirst, Statistics): - Statistics.set_thirst(thirst) - - @staticmethod - def interact_with_stamina(stamina, Statistics): - Statistics.set_stamina(stamina) + def on_interaction(self, Player): + Player.statistics.set_hp(self.Statistics.hp) + Player.statistics.set_stamina(self.Statistics.stamina) + Player.statistics.set_thirst(self.Statistics.thirst) + Player.statistics.set_hunger(self.Statistics.hunger) diff --git a/src/entities/Pickupable.py b/src/entities/Pickupable.py index cae4981..a0a62c5 100644 --- a/src/entities/Pickupable.py +++ b/src/entities/Pickupable.py @@ -1,4 +1,3 @@ -from src.entities import Statistics, Player from src.entities.Interactable import Interactable @@ -6,11 +5,4 @@ class Pickupable(Interactable): def __init__(self, texture, size, pos, Statistics): super().__init__(texture, size, pos) self.is_pickupable = True - self.Statistics = Statistics - - def on_pickup(self, Player): - Player.statistics.set_hp(self.Statistics.hp) - Player.statistics.set_stamina(self.Statistics.stamina) - Player.statistics.set_thirst(self.Statistics.thirst) - Player.statistics.set_hunger(self.Statistics.hunger)