Skip to content

Commit

Permalink
Moved inventory clear function and added examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjdai1 committed Oct 18, 2023
1 parent 5a09f0a commit 1c1d24a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def start(self) -> None:
print(game.player.inventory, "\n")

for item in game.player.inventory:
print(itemk)
print(item)

#coins.count = -42

Expand Down
8 changes: 4 additions & 4 deletions src/inventory/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def add(self, *items: Item) -> None:
item.destroyed.connect(self._on_item_destroyed)
self._items.append(item)

def clear(self) -> None:
"""Clears the inventory"""
self._items = []

def _on_item_destroyed(self, item) -> None:
"""Removes inputted item from the inventory"""
self._items.remove(item)
Expand All @@ -29,7 +33,3 @@ def __next__(self):
if not self.iter_data:
raise StopIteration
return self.iter_data.pop()

def clear(self) -> None:
"""Clears the inventory"""
self._items = []

0 comments on commit 1c1d24a

Please sign in to comment.