45 lines
1.6 KiB
Python
Raw Normal View History

2020-11-11 01:17:00 +01:00
import curses
from .display import Display
2020-11-06 19:53:27 +01:00
2020-11-19 02:18:08 +01:00
from squirrelbattle.entities.player import Player
2020-11-06 21:15:09 +01:00
class StatsDisplay(Display):
2020-11-10 10:49:11 +01:00
player: Player
2020-11-10 20:34:22 +01:00
2020-11-10 20:43:30 +01:00
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.pad = self.newpad(self.rows, self.cols)
2020-11-11 01:17:00 +01:00
self.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
2020-11-10 20:34:22 +01:00
def update_player(self, p: Player) -> None:
self.player = p
2020-11-06 21:15:09 +01:00
def update_pad(self) -> None:
string2 = "Player -- LVL {}\nEXP {}/{}\nHP {}/{}"\
2020-11-06 21:15:09 +01:00
.format(self.player.level, self.player.current_xp,
self.player.max_xp, self.player.health,
2020-11-07 15:00:24 +01:00
self.player.maxhealth)
self.addstr(self.pad, 0, 0, string2)
string3 = "STR {}\nINT {}\nCHR {}\nDEX {}\nCON {}"\
2020-11-07 15:00:24 +01:00
.format(self.player.strength,
2020-11-06 21:15:09 +01:00
self.player.intelligence, self.player.charisma,
self.player.dexterity, self.player.constitution)
self.addstr(self.pad, 3, 0, string3)
inventory_str = "Inventaire : " + "".join(
self.pack[item.name.upper()] for item in self.player.inventory)
self.addstr(self.pad, 8, 0, inventory_str)
2020-11-11 01:17:00 +01:00
if self.player.dead:
self.addstr(self.pad, 10, 0, "VOUS ÊTES MORT",
curses.A_BOLD | curses.A_BLINK | curses.A_STANDOUT
| self.color_pair(3))
2020-11-06 21:15:09 +01:00
def display(self) -> None:
self.pad.clear()
self.update_pad()
self.refresh_pad(self.pad, 0, 0, self.y, self.x,
self.y + self.height - 1, self.width + self.x - 1)