2020-12-11 16:20:50 +00:00
|
|
|
from ..interfaces import FriendlyEntity, InventoryHolder
|
2020-12-01 16:12:22 +00:00
|
|
|
from ..translations import gettext as _
|
2020-11-27 17:35:52 +00:00
|
|
|
from .player import Player
|
2020-12-07 19:54:53 +00:00
|
|
|
from .items import Item
|
|
|
|
from random import choice
|
2020-11-27 15:56:22 +00:00
|
|
|
|
2020-12-01 16:12:22 +00:00
|
|
|
|
2020-12-11 16:20:50 +00:00
|
|
|
class Merchant(InventoryHolder, FriendlyEntity):
|
2020-11-27 15:56:22 +00:00
|
|
|
"""
|
|
|
|
The class for merchants in the dungeon
|
|
|
|
"""
|
2020-12-05 20:43:13 +00:00
|
|
|
def keys(self) -> list:
|
2020-12-03 23:27:25 +00:00
|
|
|
"""
|
|
|
|
Returns a friendly entitie's specific attributes
|
|
|
|
"""
|
2020-12-09 14:32:37 +00:00
|
|
|
return super().keys() + ["inventory", "hazel"]
|
2020-11-27 15:56:22 +00:00
|
|
|
|
2020-12-07 20:13:55 +00:00
|
|
|
def __init__(self, name: str = "merchant", inventory: list = None,
|
|
|
|
hazel: int = 75, *args, **kwargs):
|
|
|
|
super().__init__(name=name, *args, **kwargs)
|
2020-12-11 16:20:50 +00:00
|
|
|
self.inventory = self.translate_inventory(inventory or [])
|
2020-11-27 17:35:52 +00:00
|
|
|
self.hazel = hazel
|
2020-12-07 20:48:56 +00:00
|
|
|
|
|
|
|
if not self.inventory:
|
|
|
|
for i in range(5):
|
|
|
|
self.inventory.append(choice(Item.get_all_items())())
|
2020-11-27 15:56:22 +00:00
|
|
|
|
2020-12-07 20:22:06 +00:00
|
|
|
def talk_to(self, player: Player) -> str:
|
2020-11-27 15:56:22 +00:00
|
|
|
"""
|
|
|
|
This function is used to open the merchant's inventory in a menu,
|
|
|
|
and allow the player to buy/sell objects
|
|
|
|
"""
|
2020-12-07 20:13:55 +00:00
|
|
|
return _("I don't sell any squirrel")
|
2020-12-07 20:22:06 +00:00
|
|
|
|
2020-12-11 15:49:17 +00:00
|
|
|
def change_hazel_balance(self, hz: int) -> None:
|
|
|
|
"""
|
|
|
|
Change the number of hazel the merchant has by hz.
|
|
|
|
"""
|
|
|
|
self.hazel += hz
|
2020-12-07 20:48:56 +00:00
|
|
|
|
2020-12-07 20:22:06 +00:00
|
|
|
|
|
|
|
class Sunflower(FriendlyEntity):
|
2020-11-27 17:35:52 +00:00
|
|
|
"""
|
|
|
|
A friendly sunflower
|
|
|
|
"""
|
|
|
|
def __init__(self, maxhealth: int = 15,
|
|
|
|
*args, **kwargs) -> None:
|
2020-12-07 20:22:06 +00:00
|
|
|
super().__init__(name="sunflower", maxhealth=maxhealth, *args, **kwargs)
|
2020-12-12 16:39:12 +00:00
|
|
|
|
|
|
|
@property
|
2020-12-12 17:12:37 +00:00
|
|
|
def dialogue_option(self) -> list:
|
2020-12-12 16:39:12 +00:00
|
|
|
return [_("Flower power!!"), _("The sun is warm today")]
|