Skip to content

Commit

Permalink
Added command to see inventory by typing "inventory" and it shows all…
Browse files Browse the repository at this point in the history
… items in the player.py inventory.
  • Loading branch information
thepersonwithears committed Nov 3, 2024
1 parent fd132e3 commit fee338a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dungeontext_lib/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .utils import Clear
from .utils import Commands


class Game:
def __init__(self, player):
self.player = player
Expand All @@ -21,6 +22,9 @@ def interpret(self, command):
elif command == "help":
Clear()
Commands()
elif command == "inventory":
Clear()
self.player.Show_Inventory()
def take_item(self, item_name):
item = next((i for i in self.player.current_room.items if i.name == item_name), None)
if item:
Expand Down
9 changes: 9 additions & 0 deletions dungeontext_lib/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ def move(self, direction):
else:
Clear()
print("You can't go that way.")


def Show_Inventory(self):
if self.inventory:
print("You are carrying:")
for item in self.inventory:
print(f"- {item.name}")
else:
print("You are not carrying anything.")

0 comments on commit fee338a

Please sign in to comment.