Player now pays for what he buys and buying a heart does not put it in the inventory. Solves #38 and #36

This commit is contained in:
eichhornchen
2020-12-11 16:49:17 +01:00
parent 7ba49277a9
commit b9b776b7ad
4 changed files with 75 additions and 12 deletions

View File

@ -3,6 +3,7 @@ from ..translations import gettext as _
from .player import Player
from .items import Item
from random import choice
from typing import Dict, Tuple, Any
class Merchant(FriendlyEntity):
@ -50,6 +51,24 @@ class Merchant(FriendlyEntity):
d = super().save_state()
d["inventory"] = [item.save_state() for item in self.inventory]
return d
def add_to_inventory(self, obj: Any) -> None:
"""
Adds an object to inventory
"""
self.inventory.append(obj)
def remove_from_inventory(self, obj: Any) -> None:
"""
Removes an object from the inventory
"""
self.inventory.remove(obj)
def change_hazel_balance(self, hz: int) -> None:
"""
Change the number of hazel the merchant has by hz.
"""
self.hazel += hz
class Sunflower(FriendlyEntity):