Merchant inventory is working!
This commit is contained in:
parent
8540a8f354
commit
b24cc1877f
|
@ -59,7 +59,7 @@ class DisplayManager:
|
|||
def refresh(self) -> None:
|
||||
if self.game.state == GameMode.PLAY \
|
||||
or self.game.state == GameMode.INVENTORY \
|
||||
or self.game.state == GameMode.STORE :
|
||||
or self.game.state == GameMode.STORE:
|
||||
# The map pad has already the good size
|
||||
self.mapdisplay.refresh(0, 0, self.rows * 4 // 5,
|
||||
self.mapdisplay.pack.tile_width
|
||||
|
|
|
@ -112,7 +112,7 @@ class MainMenuDisplay(Display):
|
|||
class InventoryDisplay(MenuDisplay):
|
||||
message : str
|
||||
def update_pad(self) -> None:
|
||||
self.addstr(self.pad, 0, (self.width - len(message)) // 2, message,
|
||||
self.addstr(self.pad, 0, (self.width - len(self.message)) // 2, self.message,
|
||||
curses.A_BOLD | curses.A_ITALIC)
|
||||
for i, item in enumerate(self.menu.values):
|
||||
rep = self.pack[item.name.upper()]
|
||||
|
|
|
@ -59,6 +59,7 @@ TexturePack.ASCII_PACK = TexturePack(
|
|||
MERCHANT='M',
|
||||
SUNFLOWER='I',
|
||||
BODY_SNATCH_POTION='S',
|
||||
SWORD='\u2020',
|
||||
)
|
||||
|
||||
TexturePack.SQUIRREL_PACK = TexturePack(
|
||||
|
@ -81,4 +82,5 @@ TexturePack.SQUIRREL_PACK = TexturePack(
|
|||
MERCHANT='🦜',
|
||||
SUNFLOWER='🌻',
|
||||
BODY_SNATCH_POTION='🔀',
|
||||
SWORD='🗡️',
|
||||
)
|
||||
|
|
|
@ -18,12 +18,12 @@ class Merchant(FriendlyEntity) :
|
|||
"""
|
||||
return ["maxhealth", "health", "inventory", "hazel"]
|
||||
|
||||
def __init__(self, name : str = "merchant", hazel : int = 75):
|
||||
super().__init__(name = name)
|
||||
def __init__(self, name: str = "merchant", inventory: list = None,
|
||||
hazel: int = 75, *args, **kwargs):
|
||||
super().__init__(name=name, *args, **kwargs)
|
||||
self.inventory = inventory or []
|
||||
self.hazel = hazel
|
||||
self.name = name
|
||||
self.inventory = []
|
||||
for i in range(5) :
|
||||
for i in range(5):
|
||||
self.inventory.append(choice(Item.get_all_items())())
|
||||
|
||||
def talk_to(self, player : Player) -> str:
|
||||
|
@ -32,6 +32,7 @@ class Merchant(FriendlyEntity) :
|
|||
and allow the player to buy/sell objects
|
||||
"""
|
||||
# TODO
|
||||
return _("I don't sell any squirrel")
|
||||
|
||||
class Sunflower(FriendlyEntity) :
|
||||
"""
|
||||
|
|
|
@ -59,9 +59,10 @@ class Item(Entity):
|
|||
d = super().save_state()
|
||||
d["held"] = self.held
|
||||
return d
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_all_items() -> list:
|
||||
return [BodySnatchPotion, Bomb, Heart, Weapon, Sword]
|
||||
return [BodySnatchPotion, Bomb, Heart, Sword]
|
||||
|
||||
|
||||
class Heart(Item):
|
||||
|
|
|
@ -122,18 +122,16 @@ class Game:
|
|||
keykey = KeyValues.translate_key(keykey, self.settings)
|
||||
if keykey == KeyValues.UP:
|
||||
xp = self.player.x
|
||||
yp = self.player.y+1
|
||||
yp = self.player.y-1
|
||||
elif keykey == KeyValues.DOWN:
|
||||
xp = self.player.x
|
||||
yp = self.player.y-1
|
||||
yp = self.player.y+1
|
||||
elif keykey == KeyValues.LEFT:
|
||||
xp = self.player.x-1
|
||||
yp = self.player.y
|
||||
elif keykey == KeyValues.RIGHT:
|
||||
xp = self.player.x+1
|
||||
yp = self.player.y
|
||||
else :
|
||||
raise Exception(keykey)
|
||||
if self.map.entity_is_present(yp, xp) :
|
||||
for entity in self.map.entities :
|
||||
if entity.is_friendly() and entity.x == xp and entity.y == yp :
|
||||
|
|
Loading…
Reference in New Issue