Add method updating console on player's death
This commit is contained in:
parent
b22e69712c
commit
9d8768cb15
23
src/ui/Ui.py
23
src/ui/Ui.py
@ -2,6 +2,7 @@ from enum import Enum
|
|||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
from src.entities.Player import StatisticNames
|
||||||
from src.entities.Statistics import Statistics
|
from src.entities.Statistics import Statistics
|
||||||
from src.ui.UiBar import UiBar
|
from src.ui.UiBar import UiBar
|
||||||
from src.ui.UiConsole import UiConsole
|
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.console.addLinesToConsoleAndScrollToDisplayThem([self.timer.getPrettyTime() + " - Player interacted with " + str(interactedObject.id) + ":"])
|
||||||
self.updateConsoleBasedOnPlayerStats(playerStats)
|
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):
|
def updateTime(self):
|
||||||
self.timerTextView.changeText(self.timer.getPrettyTime())
|
self.timerTextView.changeText(self.timer.getPrettyTime())
|
||||||
if self.timer.isItDay():
|
if self.timer.isItDay():
|
||||||
|
Loading…
Reference in New Issue
Block a user