Display the amount of hazels in the store menu, closes #49
This commit is contained in:
parent
46ce7c33bf
commit
5ae49e71ff
|
@ -5,8 +5,9 @@ import curses
|
|||
from random import randint
|
||||
from typing import List
|
||||
|
||||
from squirrelbattle.menus import Menu, MainMenu, SettingsMenu
|
||||
from squirrelbattle.menus import Menu, MainMenu, SettingsMenu, StoreMenu
|
||||
from .display import Box, Display
|
||||
from ..entities.player import Player
|
||||
from ..enums import KeyValues, GameMode
|
||||
from ..game import Game
|
||||
from ..resources import ResourceManager
|
||||
|
@ -144,10 +145,12 @@ class MainMenuDisplay(Display):
|
|||
|
||||
|
||||
class PlayerInventoryDisplay(MenuDisplay):
|
||||
player: Player = None
|
||||
selected: bool = True
|
||||
store_mode: bool = False
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
self.player = game.player
|
||||
self.update_menu(game.inventory_menu)
|
||||
self.store_mode = game.state == GameMode.STORE
|
||||
self.selected = game.state == GameMode.INVENTORY \
|
||||
|
@ -164,6 +167,12 @@ class PlayerInventoryDisplay(MenuDisplay):
|
|||
+ (": " + str(item.price) + " Hazels"
|
||||
if self.store_mode else ""))
|
||||
|
||||
if self.store_mode:
|
||||
price = f"{self.pack.HAZELNUT} {self.player.hazel} Hazels"
|
||||
width = len(price) + (self.pack.tile_width - 1)
|
||||
self.addstr(self.pad, self.height - 3, self.width - width - 2,
|
||||
price, italic=True)
|
||||
|
||||
@property
|
||||
def truewidth(self) -> int:
|
||||
return max(1, self.height if hasattr(self, "height") else 10)
|
||||
|
@ -182,6 +191,7 @@ class PlayerInventoryDisplay(MenuDisplay):
|
|||
|
||||
|
||||
class StoreInventoryDisplay(MenuDisplay):
|
||||
menu: StoreMenu
|
||||
selected: bool = False
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
|
@ -198,6 +208,11 @@ class StoreInventoryDisplay(MenuDisplay):
|
|||
+ " " + item.translated_name.capitalize()
|
||||
+ ": " + str(item.price) + " Hazels")
|
||||
|
||||
price = f"{self.pack.HAZELNUT} {self.menu.merchant.hazel} Hazels"
|
||||
width = len(price) + (self.pack.tile_width - 1)
|
||||
self.addstr(self.pad, self.height - 3, self.width - width - 2, price,
|
||||
italic=True)
|
||||
|
||||
@property
|
||||
def truewidth(self) -> int:
|
||||
return max(1, self.height if hasattr(self, "height") else 10)
|
||||
|
|
Loading…
Reference in New Issue