This commit is contained in:
Yohann D'ANELLO
2020-12-07 21:22:06 +01:00
parent b24cc1877f
commit 57fab7db51
8 changed files with 80 additions and 70 deletions

View File

@ -5,13 +5,13 @@ from .items import Item
from random import choice
class Merchant(FriendlyEntity) :
class Merchant(FriendlyEntity):
"""
The class for merchants in the dungeon
"""
inventory = list
hazel = int
def keys(self) -> list:
"""
Returns a friendly entitie's specific attributes
@ -26,21 +26,21 @@ class Merchant(FriendlyEntity) :
for i in range(5):
self.inventory.append(choice(Item.get_all_items())())
def talk_to(self, player : Player) -> str:
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
"""
# TODO
return _("I don't sell any squirrel")
class Sunflower(FriendlyEntity) :
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)
super().__init__(name="sunflower", maxhealth=maxhealth, *args, **kwargs)

View File

@ -147,7 +147,8 @@ class Bomb(Item):
d["exploding"] = self.exploding
d["damage"] = self.damage
return d
class Weapon(Item):
"""
Non-throwable items that improve player damage
@ -166,14 +167,15 @@ class Weapon(Item):
d["damage"] = self.damage
return d
class Sword(Weapon) :
class Sword(Weapon):
"""
A basic weapon
"""
def __init__(self, name: str = "sword", *args, **kwargs):
super().__init__(name = name, *args, **kwargs)
super().__init__(name=name, *args, **kwargs)
self.name = name
class BodySnatchPotion(Item):
"""

View File

@ -15,7 +15,7 @@ class Player(FightingEntity):
max_xp: int = 10
inventory: list
paths: Dict[Tuple[int, int], Tuple[int, int]]
hazel: int #It is the currency of this game
hazel: int # It is the currency of this game
def __init__(self, name: str = "player", maxhealth: int = 20,
strength: int = 5, intelligence: int = 1, charisma: int = 1,
@ -91,7 +91,7 @@ class Player(FightingEntity):
elif entity.is_item():
entity.hold(self)
elif entity.is_friendly():
# self.map.logs.add_message(entity.talk_to(self))
# self.map.logs.add_message(entity.talk_to(self))
self.map.logs.add_message(self.hit(entity))
if entity.dead:
self.add_xp(randint(3, 7))
@ -124,12 +124,12 @@ class Player(FightingEntity):
queue.append((new_y, new_x))
self.paths = predecessors
def add_to_inventory(self, obj : Any) -> None :
def add_to_inventory(self, obj: Any) -> None:
"""
Adds an object to inventory
"""
self.inventory.append(obj)
def save_state(self) -> dict:
"""
Saves the state of the entity into a dictionary