1
0

Add character stats display screen, completing part 11

This commit is contained in:
Timothy Warren 2022-01-25 15:58:22 -05:00
parent c98ccc168c
commit 87bac7a322

View File

@ -195,6 +195,55 @@ class AskUserEventHandler(EventHandler):
return MainGameEventHandler(self.engine)
class CharacterScreenEventHandler(AskUserEventHandler):
TITLE = "Character Information"
def on_render(self, console: tcod.Console) -> None:
super().on_render(console)
if self.engine.player.x <= 30:
x = 40
else:
x = 0
y = 0
width = len(self.TITLE) + 4
console.draw_frame(
x,
y,
width,
height=7,
title=self.TITLE,
clear=True,
fg=(255, 255, 255),
bg=(0, 0, 0),
)
console.print(
x + 1,
y + 1,
f"Level: {self.engine.player.level.current_level}"
)
console.print(
x + 1,
y + 2,
f"XP: {self.engine.player.level.current_xp}"
)
console.print(
x + 1,
y + 3,
f"XP for next Level: {self.engine.player.level.experience_to_next_level}"
)
console.print(
x=x + 1, y=y + 4, string=f"Attack: {self.engine.player.fighter.power}"
)
console.print(
x=x + 1, y=y + 5, string=f"Defense: {self.engine.player.fighter.defense}"
)
class LevelUpEventHandler(AskUserEventHandler):
TITLE = "Level Up"
@ -501,6 +550,8 @@ class MainGameEventHandler(EventHandler):
return InventoryActivateHandler(self.engine)
elif key == tcod.event.K_d:
return InventoryDropHandler(self.engine)
elif key == tcod.event.K_c:
return CharacterScreenEventHandler(self.engine)
elif key == tcod.event.K_SLASH:
return LookHandler(self.engine)