fix: fix buying logic for shop

This commit is contained in:
Niklas Haiden
2026-05-08 16:56:14 +02:00
parent 10e094d969
commit dd1773e142
+5 -4
View File
@@ -3,8 +3,8 @@ from src.item import Item
class Shop:
def __init__(self, ects, buyable_items):
self.ects = ects # give the ects object ot the shop
self.buyable_items: list[Item] = buyable_items # give the buyable items to the shop
self.ects = ects # give the ects object to the shop
self.buyable_items: list[Item] = buyable_items
def buy(self, item_name):
item_to_buy = self.get_item(item_name)
@@ -12,11 +12,12 @@ class Shop:
return False
cost = item_to_buy.get_cost()
if self.ects.is_over_balance(cost):
# is_over_balance() means "has enough balance"
if not self.ects.is_over_balance(cost):
return False
self.ects.decrease_balance(cost)
# self.buyable_items.remove(item_to_buy)
return True
def get_item(self, item_name):