Add method updating console on player's death

This commit is contained in:
Michał Czekański 2020-04-06 13:41:33 +02:00
parent b22e69712c
commit 9d8768cb15

View File

@ -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():