Added chests, they are immortal and contain objects the player can take for free.

This commit is contained in:
eichhornchen
2021-01-08 23:15:48 +01:00
parent 175706b1e4
commit bdbf214d8d
9 changed files with 178 additions and 13 deletions

View File

@@ -88,13 +88,18 @@ class Item(Entity):
Chestplate, Helmet, RingCritical, RingXP,
ScrollofDamage, ScrollofWeakening, Ruler, Bow, FireBallStaff]
def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder) -> bool:
def be_sold(self, buyer: InventoryHolder, seller: InventoryHolder,\
for_free: bool = False) -> bool:
"""
Does all necessary actions when an object is to be sold.
Is overwritten by some classes that cannot exist in the player's
inventory.
"""
if buyer.hazel >= self.price:
if for_free:
self.hold(buyer)
seller.remove_from_inventory(self)
return True
elif buyer.hazel >= self.price:
self.hold(buyer)
seller.remove_from_inventory(self)
buyer.change_hazel_balance(-self.price)