Display inventory content in statdisplay

This commit is contained in:
Yohann D'ANELLO 2020-11-11 23:41:06 +01:00
parent 12c653fe15
commit 21e85078a4
3 changed files with 16 additions and 5 deletions

View File

@ -35,8 +35,13 @@ class StatsDisplay(Display):
for _ in range(self.width - len(string3) - 1): for _ in range(self.width - len(string3) - 1):
string3 = string3 + " " string3 = string3 + " "
self.pad.addstr(2, 0, string3) self.pad.addstr(2, 0, string3)
inventory_str = "Inventaire : " + "".join(
self.pack[item.name.upper()] for item in self.player.inventory)
self.pad.addstr(3, 0, inventory_str)
if self.player.dead: if self.player.dead:
self.pad.addstr(3, 0, "YOU ARE DEAD", self.pad.addstr(4, 0, "VOUS ÊTES MORT",
curses.A_BOLD | curses.A_BLINK | curses.A_STANDOUT curses.A_BOLD | curses.A_BLINK | curses.A_STANDOUT
| self.color_pair(3)) | self.color_pair(3))
@ -44,4 +49,4 @@ class StatsDisplay(Display):
self.pad.clear() self.pad.clear()
self.update_pad() self.update_pad()
self.pad.refresh(0, 0, self.y, self.x, self.pad.refresh(0, 0, self.y, self.x,
3 + self.y, self.width + self.x) 4 + self.y, self.width + self.x)

View File

@ -13,8 +13,10 @@ class Item(Entity):
self.held = False self.held = False
def drop(self, y: int, x: int) -> None: def drop(self, y: int, x: int) -> None:
self.held = False if self.held:
self.held_by = None self.held_by.inventory.remove(self)
self.held = False
self.held_by = None
self.map.add_entity(self) self.map.add_entity(self)
self.move(y, x) self.move(y, x)

View File

@ -15,9 +15,13 @@ class Player(FightingEntity):
level: int = 1 level: int = 1
current_xp: int = 0 current_xp: int = 0
max_xp: int = 10 max_xp: int = 10
inventory: list = list() inventory: list
paths: Dict[Tuple[int, int], Tuple[int, int]] paths: Dict[Tuple[int, int], Tuple[int, int]]
def __init__(self):
super().__init__()
self.inventory = list()
def move(self, y: int, x: int) -> None: def move(self, y: int, x: int) -> None:
""" """
When the player moves, move the camera of the map. When the player moves, move the camera of the map.