From 679cc3f9f42348520af5fd16b802754ac57c9b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Mon, 6 Apr 2020 00:10:40 +0200 Subject: [PATCH] Add writing to console when player stats change --- src/ui/Ui.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ui/Ui.py b/src/ui/Ui.py index 394c2e8..7c50c6f 100644 --- a/src/ui/Ui.py +++ b/src/ui/Ui.py @@ -63,10 +63,24 @@ class Ui(): font=self.font) def updateBasedOnPlayerStats(self, statistics: Statistics): - self.healthBar.updateFill(statistics.hp) - self.hungerBar.updateFill(statistics.hunger) - self.staminaBar.updateFill(statistics.stamina) - self.thirstBar.updateFill(statistics.thirst) + consoleLines = [] + if self.healthBar.value != statistics.hp: + self.healthBar.updateFill(statistics.hp) + consoleLines.append("Health: " + str(statistics.hp)) + + if self.hungerBar.value != statistics.hunger: + self.hungerBar.updateFill(statistics.hunger) + consoleLines.append("Hunger: " + str(statistics.hunger)) + + if self.staminaBar.value != statistics.stamina: + self.staminaBar.updateFill(statistics.stamina) + consoleLines.append("Stamina: " + str(statistics.stamina)) + + if self.thirstBar.value != statistics.thirst: + self.thirstBar.updateFill(statistics.thirst) + consoleLines.append("Stamina: " + str(statistics.thirst)) + + self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines) def updateBasedOnPygameEvent(self, event: pygame.event): pass