Friendly entities can now talk to the player, a sunflower entity was added to test this new feature. Related to issue #22
This commit is contained in:
		@@ -1,15 +1,18 @@
 | 
			
		||||
from ..interfaces import FriendlyEntity, Map
 | 
			
		||||
from .player import Player
 | 
			
		||||
 | 
			
		||||
class Merchant(FriendlyEntity) :
 | 
			
		||||
    """
 | 
			
		||||
    The class for merchants in the dungeon
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    name = "Merchant"
 | 
			
		||||
    inventory = list
 | 
			
		||||
    hazel = int
 | 
			
		||||
 | 
			
		||||
    def __init__(self, inventory : list):
 | 
			
		||||
    def __init__(self, inventory : list, hazel : int = 75):
 | 
			
		||||
        super().__init__()
 | 
			
		||||
        self.inventory = inventory
 | 
			
		||||
        self.hazel = hazel
 | 
			
		||||
 | 
			
		||||
    def talk_to(self, player : Player) -> None:
 | 
			
		||||
        """
 | 
			
		||||
@@ -17,4 +20,14 @@ class Merchant(FriendlyEntity) :
 | 
			
		||||
        and allow the player to buy/sell objects
 | 
			
		||||
        """
 | 
			
		||||
        #TODO
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
class Sunflower(FriendlyEntity) :
 | 
			
		||||
    """
 | 
			
		||||
    A friendly sunflower
 | 
			
		||||
    """
 | 
			
		||||
    dialogue_option = ["Flower power!!", "The sun is warm today"]
 | 
			
		||||
    
 | 
			
		||||
    def __init__(self, maxhealth: int = 15,
 | 
			
		||||
                 *args, **kwargs) -> None:
 | 
			
		||||
        super().__init__(name="sunflower",
 | 
			
		||||
                         maxhealth=maxhealth, *args, **kwargs)
 | 
			
		||||
 
 | 
			
		||||
@@ -80,6 +80,8 @@ class Player(FightingEntity):
 | 
			
		||||
                    return True
 | 
			
		||||
                elif entity.is_item():
 | 
			
		||||
                    entity.hold(self)
 | 
			
		||||
                elif entity.is_friendly():
 | 
			
		||||
                    self.map.logs.add_message(entity.talk_to(self))
 | 
			
		||||
        return super().check_move(y, x, move_if_possible)
 | 
			
		||||
 | 
			
		||||
    def recalculate_paths(self, max_distance: int = 8) -> None:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user