from ..interfaces import FriendlyEntity, InventoryHolder from ..translations import gettext as _ from .player import Player from .items import Item from random import choice class Merchant(InventoryHolder, FriendlyEntity): """ The class for merchants in the dungeon """ def keys(self) -> list: """ Returns a friendly entitie's specific attributes """ return super().keys() + ["inventory", "hazel"] def __init__(self, name: str = "merchant", inventory: list = None, hazel: int = 75, *args, **kwargs): super().__init__(name=name, *args, **kwargs) self.inventory = self.translate_inventory(inventory or []) self.hazel = hazel if not self.inventory: for i in range(5): self.inventory.append(choice(Item.get_all_items())()) def talk_to(self, player: Player) -> str: """ This function is used to open the merchant's inventory in a menu, and allow the player to buy/sell objects """ return _("I don't sell any squirrel") def change_hazel_balance(self, hz: int) -> None: """ Change the number of hazel the merchant has by hz. """ self.hazel += hz class Sunflower(FriendlyEntity): """ A friendly sunflower """ def __init__(self, maxhealth: int = 15, *args, **kwargs) -> None: super().__init__(name="sunflower", maxhealth=maxhealth, *args, **kwargs) @property def dialogue_option(self) -> list: return [_("Flower power!!"), _("The sun is warm today")]