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