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

@@ -70,6 +70,13 @@ class Player(FightingEntity):
self.current_xp += xp
self.level_up()
def change_hazel_balance(self, hz: int) -> None:
"""
Change the number of hazel the player has by hz. hz is negative
when the player loses money and positive when he gains money
"""
self.hazel += hz
# noinspection PyTypeChecker,PyUnresolvedReferences
def check_move(self, y: int, x: int, move_if_possible: bool = False) \
-> bool:
@@ -125,6 +132,12 @@ class Player(FightingEntity):
"""
self.inventory.append(obj)
def remove_from_inventory(self, obj: Any) -> None:
"""
Removes an object from the inventory
"""
self.inventory.remove(obj)
def save_state(self) -> dict:
"""
Saves the state of the entity into a dictionary