From 56ba9d186e394a2450ed5fec50c58f94fa6906c9 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 11 Nov 2020 01:17:00 +0100 Subject: [PATCH] Display message if we are dead --- dungeonbattle/display/statsdisplay.py | 10 ++++++++-- dungeonbattle/entities/player.py | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dungeonbattle/display/statsdisplay.py b/dungeonbattle/display/statsdisplay.py index bf204dd..2eb76aa 100644 --- a/dungeonbattle/display/statsdisplay.py +++ b/dungeonbattle/display/statsdisplay.py @@ -1,3 +1,5 @@ +import curses + from .display import Display from dungeonbattle.entities.player import Player @@ -9,6 +11,7 @@ class StatsDisplay(Display): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.pad = self.newpad(self.rows, self.cols) + self.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK) def update_player(self, p: Player) -> None: self.player = p @@ -32,10 +35,13 @@ class StatsDisplay(Display): for _ in range(self.width - len(string3) - 1): string3 = string3 + " " self.pad.addstr(2, 0, string3) + if self.player.dead: + self.pad.addstr(3, 0, "YOU ARE DEAD", + curses.A_BOLD | curses.A_BLINK | curses.A_STANDOUT + | self.color_pair(3)) def display(self) -> None: self.pad.clear() self.update_pad() self.pad.refresh(0, 0, self.y, self.x, - 2 + self.y, - self.width + self.x) + 3 + self.y, self.width + self.x) diff --git a/dungeonbattle/entities/player.py b/dungeonbattle/entities/player.py index 7fdf041..4e3affc 100644 --- a/dungeonbattle/entities/player.py +++ b/dungeonbattle/entities/player.py @@ -50,6 +50,9 @@ class Player(FightingEntity): the player fights this entity. It rewards some XP if it is dead. """ + # Don't move if we are dead + if self.dead: + return False for entity in self.map.entities: if entity.y == y and entity.x == x and \ isinstance(entity, FightingEntity):