2020-11-11 00:17:00 +00:00
|
|
|
import curses
|
|
|
|
|
2020-11-10 17:08:06 +00:00
|
|
|
from .display import Display
|
2020-11-06 18:53:27 +00:00
|
|
|
|
2020-11-06 20:15:09 +00:00
|
|
|
from dungeonbattle.entities.player import Player
|
|
|
|
|
|
|
|
|
2020-11-10 17:08:06 +00:00
|
|
|
class StatsDisplay(Display):
|
2020-11-10 09:49:11 +00:00
|
|
|
player: Player
|
2020-11-10 19:34:22 +00:00
|
|
|
|
2020-11-10 19:43:30 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
2020-11-10 17:08:06 +00:00
|
|
|
self.pad = self.newpad(self.rows, self.cols)
|
2020-11-11 00:17:00 +00:00
|
|
|
self.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
|
2020-11-10 19:34:22 +00:00
|
|
|
|
|
|
|
def update_player(self, p: Player) -> None:
|
2020-11-10 17:08:06 +00:00
|
|
|
self.player = p
|
2020-11-06 20:15:09 +00:00
|
|
|
|
|
|
|
def update_pad(self) -> None:
|
2020-11-07 14:00:24 +00:00
|
|
|
string = ""
|
2020-11-10 17:08:06 +00:00
|
|
|
for _ in range(self.width - 1):
|
2020-11-07 14:00:24 +00:00
|
|
|
string = string + "-"
|
|
|
|
self.pad.addstr(0, 0, string)
|
|
|
|
string2 = "Player -- LVL {} EXP {}/{} HP {}/{}"\
|
2020-11-06 20:15:09 +00:00
|
|
|
.format(self.player.level, self.player.current_xp,
|
|
|
|
self.player.max_xp, self.player.health,
|
2020-11-07 14:00:24 +00:00
|
|
|
self.player.maxhealth)
|
2020-11-10 17:08:06 +00:00
|
|
|
for _ in range(self.width - len(string2) - 1):
|
2020-11-07 14:00:24 +00:00
|
|
|
string2 = string2 + " "
|
|
|
|
self.pad.addstr(1, 0, string2)
|
|
|
|
string3 = "Stats : STR {} INT {} CHR {} DEX {} CON {}"\
|
|
|
|
.format(self.player.strength,
|
2020-11-06 20:15:09 +00:00
|
|
|
self.player.intelligence, self.player.charisma,
|
|
|
|
self.player.dexterity, self.player.constitution)
|
2020-11-10 17:08:06 +00:00
|
|
|
for _ in range(self.width - len(string3) - 1):
|
2020-11-07 14:00:24 +00:00
|
|
|
string3 = string3 + " "
|
2020-11-08 21:48:50 +00:00
|
|
|
self.pad.addstr(2, 0, string3)
|
2020-11-11 22:41:06 +00:00
|
|
|
|
|
|
|
inventory_str = "Inventaire : " + "".join(
|
|
|
|
self.pack[item.name.upper()] for item in self.player.inventory)
|
|
|
|
self.pad.addstr(3, 0, inventory_str)
|
|
|
|
|
2020-11-11 00:17:00 +00:00
|
|
|
if self.player.dead:
|
2020-11-11 22:41:06 +00:00
|
|
|
self.pad.addstr(4, 0, "VOUS ÊTES MORT",
|
2020-11-11 00:17:00 +00:00
|
|
|
curses.A_BOLD | curses.A_BLINK | curses.A_STANDOUT
|
|
|
|
| self.color_pair(3))
|
2020-11-06 20:15:09 +00:00
|
|
|
|
2020-11-10 17:08:06 +00:00
|
|
|
def display(self) -> None:
|
2020-11-06 18:50:26 +00:00
|
|
|
self.pad.clear()
|
|
|
|
self.update_pad()
|
2020-11-10 17:08:06 +00:00
|
|
|
self.pad.refresh(0, 0, self.y, self.x,
|
2020-11-11 22:41:06 +00:00
|
|
|
4 + self.y, self.width + self.x)
|