From 4cd4bc90052a1bd5ccd932a551115ddb7de1fb3e Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 Jan 2021 15:17:02 +0100 Subject: [PATCH] Display the current floor in the StatsDisplay --- squirrelbattle/display/statsdisplay.py | 18 ++++++++++-------- squirrelbattle/game.py | 1 + squirrelbattle/interfaces.py | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/squirrelbattle/display/statsdisplay.py b/squirrelbattle/display/statsdisplay.py index ef358bb..fb5160f 100644 --- a/squirrelbattle/display/statsdisplay.py +++ b/squirrelbattle/display/statsdisplay.py @@ -20,15 +20,17 @@ class StatsDisplay(Display): self.player = game.player def update_pad(self) -> None: - string2 = "Player -- LVL {}\nEXP {}/{}\nHP {}/{}"\ - .format(self.player.level, self.player.current_xp, - self.player.max_xp, self.player.health, - self.player.maxhealth) + string2 = f"{_(self.player.name).capitalize()} " \ + f"-- LVL {self.player.level} -- " \ + f"FLOOR {-self.player.map.floor}\n" \ + f"EXP {self.player.current_xp}/{self.player.max_xp}\n" \ + f"HP {self.player.health}/{self.player.maxhealth}" self.addstr(self.pad, 0, 0, string2) - string3 = "STR {}\nINT {}\nCHR {}\nDEX {}\nCON {}"\ - .format(self.player.strength, - self.player.intelligence, self.player.charisma, - self.player.dexterity, self.player.constitution) + string3 = f"STR {self.player.strength}\n" \ + f"INT {self.player.intelligence}\n" \ + f"CHR {self.player.charisma}\n" \ + f"DEX {self.player.dexterity}\n" \ + f"CON {self.player.constitution}" self.addstr(self.pad, 3, 0, string3) inventory_str = _("Inventory:") + " " diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index dff09e0..05b4003 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -173,6 +173,7 @@ class Game: self.maps.append(Map.load(ResourceManager.get_asset_path( "example_map_2.txt"))) new_map = self.map + new_map.floor = self.map_index old_map.remove_entity(self.player) new_map.add_entity(self.player) if move_down: diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index ff94cc6..556f55c 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -35,6 +35,7 @@ class Map: Object that represents a Map with its width, height and tiles, that have their custom properties. """ + floor: int width: int height: int start_y: int @@ -49,6 +50,7 @@ class Map: def __init__(self, width: int, height: int, tiles: list, start_y: int, start_x: int): + self.floor = 0 self.width = width self.height = height self.start_y = start_y