From 9d8768cb1540782182328cc656c576a83ce97473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Mon, 6 Apr 2020 13:41:33 +0200 Subject: [PATCH] Add method updating console on player's death --- src/ui/Ui.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/ui/Ui.py b/src/ui/Ui.py index f75b6b8..4a87745 100644 --- a/src/ui/Ui.py +++ b/src/ui/Ui.py @@ -2,6 +2,7 @@ from enum import Enum import pygame +from src.entities.Player import StatisticNames from src.entities.Statistics import Statistics from src.ui.UiBar import UiBar from src.ui.UiConsole import UiConsole @@ -89,6 +90,28 @@ class Ui(): self.console.addLinesToConsoleAndScrollToDisplayThem([self.timer.getPrettyTime() + " - Player interacted with " + str(interactedObject.id) + ":"]) self.updateConsoleBasedOnPlayerStats(playerStats) + def updateOnDeath(self, player): + consoleLines = [] + + deathReason: StatisticNames = player.deathReason + + consoleLines.append(self.timer.getPrettyTime() + " - Game Over") + deathReasonString = "" + if deathReason is StatisticNames.HP: + deathReasonString = "Health issues" + elif deathReason is StatisticNames.HUNGER: + deathReasonString = "Hunger" + elif deathReason is StatisticNames.STAMINA: + deathReasonString = "Exhaustion" + elif deathReason is StatisticNames.THIRST: + deathReasonString = "Dehydration" + + consoleLines.append("Death reason: " + deathReasonString) + + consoleLines.append("Time alive: " + str(player.timeAlive / 1000)) + + self.console.addLinesToConsoleAndScrollToDisplayThem(consoleLines) + def updateTime(self): self.timerTextView.changeText(self.timer.getPrettyTime()) if self.timer.isItDay():