diff --git a/README.md b/README.md
index f6800627..b2601d5c 100644
--- a/README.md
+++ b/README.md
@@ -1,135 +1,32 @@
-# Project: Escape Room Python Game
+# Escape Room Python Game
## Overview
-The goal of this project is for you to apply the Python programming skills you have learned this week in solving a real problem. We present you the design of a classic game that can be played via text - Escape Room. Your goal is to develop the game using Python based on the game design.
+Welcome to our Escape Room Python Game project! In this project, my team has developed an exciting text-based Escape Room game using Python. The objective is to challenge players' problem-solving skills and creativity as they navigate through a series of rooms to find clues and ultimately escape.
-Read the game narratives and technical requirements carefully. Plan how you will achieve your goal with pseudo codes and/or flowchart. Review the logic and process in order to avoid potential errors. Then implement with Python code. After that, test your code several times with different inputs and make sure it's rock solid. The instructional team is standing by to help you in case you run into any problems.
----
+## Challenges Faced
-## Game Design
+Our journey wasn't without its obstacles. In the initial stages, we encountered several challenges that demanded creative solutions:
+- In our first code iteration, the order of actions (examine or explore) didn't align logically. We revised the sequence to enhance player experience.
+- The game loop lacked a clear option for the player to exit, leading to frustration. We addressed this issue by refining the user interaction flow.
-### Game Map
+## Improvements Made
-
+We implemented several enhancements to elevate the player experience:
+- **Immersive Sound**: Added sound effects to enhance the atmosphere and engagement.
+- **Visual Keys**: Incorporated visual cues to guide players through the game.
+- **Timer**: Introduced a time limit feature to add urgency and excitement.
+- **Ranking**: Implemented a ranking system to encourage replayability and competition.
-### Game Narratives
+## Future Enhancements
-#### Game Room
+We have identified areas for further improvement:
+- **Language Translator**: Integrating a language selection feature to cater to a diverse audience.
+- **Game Data Saving**: Implementing a feature to save game progress and rankings for future reference.
+- **Level of Difficulty**: Adding multiple difficulty levels to accommodate players of varying skill levels.
-You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!
+Feel free to contribute to the project and suggest additional enhancements to make the Escape Room Python Game even more captivating and enjoyable!
-You are now in game room.
-
-What would you like to do?
-
-You explore the room. This is Game Room. You find couch, piano, and Door A.
-
-You examine couch. There isn't anything interesting about it.
-
-You examine Door A. It is locked but you don't have the key.
-
-You examine piano. You find key for Door A.
-
-You examine Door A. Your unlock it with a key you have.
-
-Do you want to go to the next room?
-
-#### Bedroom 1
-
-You are now in Bedroom 1.
-
-What would you like to do?
-
-You explore the room. This is Bedroom 1. You find queen bed, Door A, Door B, and Door C.
-
-You examine queen bed. You find key for Door B.
-
-You examine Door C. It is locked but you don't have the key.
-
-You examine Door B. Your unlock it with a key you have.
-
-Do you want to go to the next room?
-
-#### Bedroom 2
-
-You are now in Bedroom 2.
-
-What would you like to do?
-
-You explore the room. This is Bedroom 2. You find double bed, dresser, and Door B.
-
-You examine double bed. You find key for Door C.
-
-You examine dresser. You find key for Door D.
-
-You examine Door B. Your unlock it with a key you have.
-
-Do you want to go to the next room?
-
-#### Bedroom 1
-
-You are now in Bedroom 1.
-
-What would you like to do?
-
-You examine Door C. Your unlock it with a key you have.
-
-Do you want to go to the next room?
-
-#### Living Room
-
-You are now in Living Room.
-
-What would you like to do?
-
-You explore the room. This is Living Room. You find dining table, Door C, and Door D.
-
-You examine Door D. Your unlock it with a key you have.
-
-Do you want to go to the next room?
-
-#### Outside
-
-Congrats! You escaped the room!
-
----
-
-## Getting Started
-
-Overwhelmed and don't know where to start? This is a tough challenge we know. But don't worry. We have included a working example for you to reference in which only 1 room (game room) is included. Read the example and make sure you understand it. Then you can expand on top of the example to code the rest of the rooms.
-
-The provided example is just a Minimal Viable Product (MVP). It is fully functional but not bullet proof. You should be aware of its limitations while you are working and try to make your final product as robust as possible.
-
-## Technical Requirements
-
-* Use Python lists and dictionaries to define the rooms, items, and relations of them.
-
-* Use a Python dictionary to store the game state. Update the state dictionary when progresses are made such as a key is collected.
-
-* Use Python functions to play the game. Don't use procedural code.
-
-* After completing each game action, call the next function to continue playing until the winning condition is reached.
-
-* The winning condition is for the player to successfully make to the "Outside" room. When this happens, congrat the player and end the game.
-
-## Necessary Deliverables
-
-The following deliverables should be pushed to your Github repo.
-
-* `main.ipynb` that contains your solution.
-
-## Suggested Ways to Get Started
-
-1. Start Jupyter Notebook from this lab directory.
-
-1. Launch `sample-code.ipynb` and read through the file. Also execute the code and play the game. Make sure you understand what each line of the codes does.
-
-1. Create `main.ipynb` and copy the codes from `sample-code.ipynb`. Expand the code following the example to create Bedroom 1.
-
-1. Test the game with Game Room and Bedroom 1. Make sure everything works then work on Bedroom 2 then Living Room.
-
-1. Test the whole game. Try to make all kinds of inputs to make sure your game is rock solid and will not break.
diff --git a/specifications.md b/specifications.md
new file mode 100644
index 00000000..f6800627
--- /dev/null
+++ b/specifications.md
@@ -0,0 +1,135 @@
+
+
+# Project: Escape Room Python Game
+
+## Overview
+
+The goal of this project is for you to apply the Python programming skills you have learned this week in solving a real problem. We present you the design of a classic game that can be played via text - Escape Room. Your goal is to develop the game using Python based on the game design.
+
+Read the game narratives and technical requirements carefully. Plan how you will achieve your goal with pseudo codes and/or flowchart. Review the logic and process in order to avoid potential errors. Then implement with Python code. After that, test your code several times with different inputs and make sure it's rock solid. The instructional team is standing by to help you in case you run into any problems.
+
+---
+
+## Game Design
+
+### Game Map
+
+
+
+### Game Narratives
+
+#### Game Room
+
+You wake up on a couch and find yourself in a strange house with no windows which you have never been to before. You don't remember why you are here and what had happened before. You feel some unknown danger is approaching and you must get out of the house, NOW!
+
+You are now in game room.
+
+What would you like to do?
+
+You explore the room. This is Game Room. You find couch, piano, and Door A.
+
+You examine couch. There isn't anything interesting about it.
+
+You examine Door A. It is locked but you don't have the key.
+
+You examine piano. You find key for Door A.
+
+You examine Door A. Your unlock it with a key you have.
+
+Do you want to go to the next room?
+
+#### Bedroom 1
+
+You are now in Bedroom 1.
+
+What would you like to do?
+
+You explore the room. This is Bedroom 1. You find queen bed, Door A, Door B, and Door C.
+
+You examine queen bed. You find key for Door B.
+
+You examine Door C. It is locked but you don't have the key.
+
+You examine Door B. Your unlock it with a key you have.
+
+Do you want to go to the next room?
+
+#### Bedroom 2
+
+You are now in Bedroom 2.
+
+What would you like to do?
+
+You explore the room. This is Bedroom 2. You find double bed, dresser, and Door B.
+
+You examine double bed. You find key for Door C.
+
+You examine dresser. You find key for Door D.
+
+You examine Door B. Your unlock it with a key you have.
+
+Do you want to go to the next room?
+
+#### Bedroom 1
+
+You are now in Bedroom 1.
+
+What would you like to do?
+
+You examine Door C. Your unlock it with a key you have.
+
+Do you want to go to the next room?
+
+#### Living Room
+
+You are now in Living Room.
+
+What would you like to do?
+
+You explore the room. This is Living Room. You find dining table, Door C, and Door D.
+
+You examine Door D. Your unlock it with a key you have.
+
+Do you want to go to the next room?
+
+#### Outside
+
+Congrats! You escaped the room!
+
+---
+
+## Getting Started
+
+Overwhelmed and don't know where to start? This is a tough challenge we know. But don't worry. We have included a working example for you to reference in which only 1 room (game room) is included. Read the example and make sure you understand it. Then you can expand on top of the example to code the rest of the rooms.
+
+The provided example is just a Minimal Viable Product (MVP). It is fully functional but not bullet proof. You should be aware of its limitations while you are working and try to make your final product as robust as possible.
+
+## Technical Requirements
+
+* Use Python lists and dictionaries to define the rooms, items, and relations of them.
+
+* Use a Python dictionary to store the game state. Update the state dictionary when progresses are made such as a key is collected.
+
+* Use Python functions to play the game. Don't use procedural code.
+
+* After completing each game action, call the next function to continue playing until the winning condition is reached.
+
+* The winning condition is for the player to successfully make to the "Outside" room. When this happens, congrat the player and end the game.
+
+## Necessary Deliverables
+
+The following deliverables should be pushed to your Github repo.
+
+* `main.ipynb` that contains your solution.
+
+## Suggested Ways to Get Started
+
+1. Start Jupyter Notebook from this lab directory.
+
+1. Launch `sample-code.ipynb` and read through the file. Also execute the code and play the game. Make sure you understand what each line of the codes does.
+
+1. Create `main.ipynb` and copy the codes from `sample-code.ipynb`. Expand the code following the example to create Bedroom 1.
+
+1. Test the game with Game Room and Bedroom 1. Make sure everything works then work on Bedroom 2 then Living Room.
+
+1. Test the whole game. Try to make all kinds of inputs to make sure your game is rock solid and will not break.
diff --git a/your-code/dramatic_sound.wav b/your-code/dramatic_sound.wav
new file mode 100644
index 00000000..b2815ba1
Binary files /dev/null and b/your-code/dramatic_sound.wav differ
diff --git a/your-code/game.py b/your-code/game.py
new file mode 100644
index 00000000..2f15bacb
--- /dev/null
+++ b/your-code/game.py
@@ -0,0 +1,290 @@
+# -*- coding: utf-8 -*-
+"""er_main_v20042024_3.ipynb
+
+Automatically generated by Colab.
+
+Original file is located at
+ https://colab.research.google.com/drive/1fNgQF34pf-rnyFmY91ml0Z-zyCVsepvo
+"""
+
+import time
+import pygame
+
+# Initialize pygame and mixer
+pygame.init()
+pygame.mixer.init() # Initialize the mixer module
+
+# Load background sound
+try:
+ background_sound = pygame.mixer.Sound('./dramatic_sound.wav')
+ background_sound.play(-1) # Play the sound on loop
+except Exception as e:
+ print(f"Error loading sound: {e}")
+
+winners_list = []
+
+def initialize_variables():
+ # Define all items, doors, and keys with details
+ couch = {
+ "name": "couch",
+ "type": "furniture",
+ "detail": "There isn't anything interesting about it."
+ }
+
+ piano = {
+ "name": "piano",
+ "type": "furniture",
+ "detail": "You find a key for door A.",
+ "key": {
+ "name": "Key for Door A",
+ "type": "key",
+ "target": "Door A",
+ "found": False
+ }
+ }
+ queen_bed = {
+ "name": "queen bed",
+ "type": "furniture",
+ "detail": "You find a key for door B.",
+ "key": {
+ "name": "Key for Door B",
+ "type": "key",
+ "target": "Door B",
+ "found": False
+ }
+ }
+
+ double_bed = {
+ "name": "double bed",
+ "type": "furniture",
+ "detail": "You find a key for door C.",
+ "key": {
+ "name": "Key for Door C",
+ "type": "key",
+ "target": "Door C",
+ "found": False
+ }
+ }
+
+ dresser = {
+ "name": "dresser",
+ "type": "furniture",
+ "detail": "You find a key for door D.",
+ "key": {
+ "name": "Key for door D",
+ "type": "key",
+ "target": "Door D",
+ "found": False
+ }
+ }
+
+ dinning_table = {
+ "name": "dinning table",
+ "type": "furniture",
+ "detail": "There isn't anything interesting about it."
+ }
+
+ # Define doors
+ door_a = {"name": "Door A", "type": "door", "locked": True}
+ door_b = {"name": "Door B", "type": "door", "locked": True}
+ door_c = {"name": "Door C", "type": "door", "locked": True}
+ door_d = {"name": "Door D", "type": "door", "locked": True}
+
+ # Define rooms and their items
+ game_room = {"name": "Game Room", "items": [couch, piano, door_a]}
+ bedroom_1 = {"name": "Bedroom 1", "items": [queen_bed, door_a, door_b, door_c]}
+ bedroom_2 = {"name": "Bedroom 2", "items": [double_bed, dresser, door_b]}
+ living_room = {"name": "Living Room", "items": [dinning_table,door_c, door_d]}
+ outside = {"name": "Outside", "items": []}
+
+ # Room connections
+ global object_relations
+ object_relations = {
+ "Door A": [game_room, bedroom_1],
+ #"Door A": [game_room, outside],
+ "Door B": [bedroom_1, bedroom_2],
+ "Door C": [bedroom_1, living_room],
+ "Door D": [living_room, outside]
+ }
+
+ # Initial game state
+ global INIT_GAME_STATE
+ INIT_GAME_STATE = {
+ "current_room": game_room,
+ "keys_collected": [],
+ "target_room": outside,
+ "start_time": time.time(),
+ "time_limit": 60*5, # 5 minutes
+ "player_name": ""
+ }
+
+
+def return_player_time(player):
+ return player["player_time"]
+
+def linebreak():
+ """
+ Print a line break
+ """
+ print("\n")
+
+def draw_key():
+ key = [
+ " _ __ ",
+ " / \ ",
+ "| _ |____________ ",
+ "| |_| | | ",
+ " \_ _ _/ ",
+ ]
+ for line in key:
+ print(line)
+
+def start_game():
+ initialize_variables()
+ global game_state
+ game_state = INIT_GAME_STATE.copy()
+
+ print("You wake up on a couch and find yourself in a strange house with no windows which you have never been to before.")
+ print("You don't remember why you are here and what had happened before.")
+ print("You feel some unknown danger is approaching and you must get out of the house, NOW!")
+ linebreak()
+ player_name = input("What is your name? ")
+ game_state['player_name'] = player_name
+
+ linebreak()
+ play_room(game_state["current_room"], first_entry=True)
+
+
+def check_time_left():
+ elapsed_time = time.time() - game_state["start_time"]
+ time_left = game_state["time_limit"] - elapsed_time
+ if time_left <= 0:
+ print("Time's up! You didn't escape in time.")
+ print("Game Over!!!")
+ background_sound.stop()
+ pygame.quit()
+ exit()
+ else:
+ minutes, seconds = divmod(int(time_left), 60)
+ print(f"Time remaining: {minutes} minutes {seconds} seconds")
+ return time_left
+
+def ending_sequence():
+ print("Congrats! You escaped the room!")
+ linebreak()
+ print("Game Over!!!")
+ linebreak()
+ finish_time = time.time()
+ player_time = finish_time - game_state["start_time"]
+ winner_result = {
+ 'player_name': game_state['player_name'],
+ 'player_time': player_time
+ }
+ winners_list.append(winner_result)
+ winners_list.sort(key=return_player_time)
+ print('------------------------------------------------------------')
+ print('-----------------')
+ i = 0
+ for winner in winners_list:
+ i += 1
+ print(f"Rank {i}. Name: {winner['player_name']}, Time: {int(winner['player_time'])} sec")
+ print('-----------------')
+ print('------------------------------------------------------------')
+ another_game = input('Do you want to play another game? (Yes or no)')
+ if another_game.lower().strip() == 'yes':
+ linebreak()
+ linebreak()
+ linebreak()
+ start_game()
+ else:
+ background_sound.stop()
+ pygame.quit()
+ exit()
+
+def play_room(room, first_entry):
+ time_left = check_time_left()
+ if room == game_state["target_room"]:
+ ending_sequence()
+
+ if first_entry:
+ print(f"\nYou are now in {room['name']}.")
+ else:
+ print(f"\nYou are still in {room['name']}.")
+ linebreak()
+ ask_for_next_action(room)
+
+def ask_for_next_action(room):
+ check_time_left()
+ action = input("What would you like to do? 'Explore' items in the room or 'Exit' the game: ").strip().lower()
+ if action == "explore":
+ explore_room(room)
+ elif action == "exit":
+ print("Exiting the game. Goodbye!")
+ print("Game Over!!!")
+ background_sound.stop()
+ pygame.quit()
+ exit()
+ else:
+ print("Not sure what you mean. Please choose a valid option.")
+ linebreak()
+ ask_for_next_action(room)
+
+def explore_room(room):
+ items = [i["name"] for i in room["items"]]
+ print("Available items: " + ", ".join(items))
+ linebreak()
+ examine_items(room)
+
+def examine_items(room):
+ desired_item_name = input("What would you like to examine?: ").strip().lower()
+ item_found = False
+ for item in room["items"]:
+ if item['name'].strip().lower() == desired_item_name:
+ item_found = True
+ if item["type"] == "furniture":
+ examine_furniture(item, room)
+ elif item["type"] == "door":
+ examine_door(item, room)
+ if not item_found:
+ print("No such item here. Please try another item.")
+ linebreak()
+ ask_for_next_action(room)
+
+def examine_furniture(item, room):
+ if "key" in item and not item["key"]["found"]:
+ item["key"]["found"] = True
+ game_state["keys_collected"].append(item["key"])
+ print(f"You've found {item['key']['name']}. It unlocks {item['key']['target']}.")
+ draw_key()
+ else:
+ print(item["detail"])
+ linebreak()
+ ask_for_next_action(room)
+
+def examine_door(item, room):
+ have_correct_key = False
+ for collected_key in game_state["keys_collected"]:
+ if collected_key["name"].strip().lower() == f"Key for {item['name']}".strip().lower():
+ have_correct_key = True
+ print(f"You unlock {item['name']} with {collected_key['name']}.")
+ item["locked"] = False
+ next_room = get_next_room_of_door(item, room)
+ play_room(next_room, first_entry=True)
+ if not have_correct_key:
+ print(f"It is locked but you don't have the key.")
+ linebreak()
+ ask_for_next_action(room)
+
+
+def get_next_room_of_door(door, current_room):
+ connected_rooms = object_relations[door["name"]]
+ for room in connected_rooms:
+ if(current_room != room):
+ return room
+
+# Start the game
+start_game()
+
+# Keep the window open until the user decides to close it
+input("Press Enter to exit...")
+
diff --git a/your-code/main.py b/your-code/main.py
new file mode 100644
index 00000000..2f15bacb
--- /dev/null
+++ b/your-code/main.py
@@ -0,0 +1,290 @@
+# -*- coding: utf-8 -*-
+"""er_main_v20042024_3.ipynb
+
+Automatically generated by Colab.
+
+Original file is located at
+ https://colab.research.google.com/drive/1fNgQF34pf-rnyFmY91ml0Z-zyCVsepvo
+"""
+
+import time
+import pygame
+
+# Initialize pygame and mixer
+pygame.init()
+pygame.mixer.init() # Initialize the mixer module
+
+# Load background sound
+try:
+ background_sound = pygame.mixer.Sound('./dramatic_sound.wav')
+ background_sound.play(-1) # Play the sound on loop
+except Exception as e:
+ print(f"Error loading sound: {e}")
+
+winners_list = []
+
+def initialize_variables():
+ # Define all items, doors, and keys with details
+ couch = {
+ "name": "couch",
+ "type": "furniture",
+ "detail": "There isn't anything interesting about it."
+ }
+
+ piano = {
+ "name": "piano",
+ "type": "furniture",
+ "detail": "You find a key for door A.",
+ "key": {
+ "name": "Key for Door A",
+ "type": "key",
+ "target": "Door A",
+ "found": False
+ }
+ }
+ queen_bed = {
+ "name": "queen bed",
+ "type": "furniture",
+ "detail": "You find a key for door B.",
+ "key": {
+ "name": "Key for Door B",
+ "type": "key",
+ "target": "Door B",
+ "found": False
+ }
+ }
+
+ double_bed = {
+ "name": "double bed",
+ "type": "furniture",
+ "detail": "You find a key for door C.",
+ "key": {
+ "name": "Key for Door C",
+ "type": "key",
+ "target": "Door C",
+ "found": False
+ }
+ }
+
+ dresser = {
+ "name": "dresser",
+ "type": "furniture",
+ "detail": "You find a key for door D.",
+ "key": {
+ "name": "Key for door D",
+ "type": "key",
+ "target": "Door D",
+ "found": False
+ }
+ }
+
+ dinning_table = {
+ "name": "dinning table",
+ "type": "furniture",
+ "detail": "There isn't anything interesting about it."
+ }
+
+ # Define doors
+ door_a = {"name": "Door A", "type": "door", "locked": True}
+ door_b = {"name": "Door B", "type": "door", "locked": True}
+ door_c = {"name": "Door C", "type": "door", "locked": True}
+ door_d = {"name": "Door D", "type": "door", "locked": True}
+
+ # Define rooms and their items
+ game_room = {"name": "Game Room", "items": [couch, piano, door_a]}
+ bedroom_1 = {"name": "Bedroom 1", "items": [queen_bed, door_a, door_b, door_c]}
+ bedroom_2 = {"name": "Bedroom 2", "items": [double_bed, dresser, door_b]}
+ living_room = {"name": "Living Room", "items": [dinning_table,door_c, door_d]}
+ outside = {"name": "Outside", "items": []}
+
+ # Room connections
+ global object_relations
+ object_relations = {
+ "Door A": [game_room, bedroom_1],
+ #"Door A": [game_room, outside],
+ "Door B": [bedroom_1, bedroom_2],
+ "Door C": [bedroom_1, living_room],
+ "Door D": [living_room, outside]
+ }
+
+ # Initial game state
+ global INIT_GAME_STATE
+ INIT_GAME_STATE = {
+ "current_room": game_room,
+ "keys_collected": [],
+ "target_room": outside,
+ "start_time": time.time(),
+ "time_limit": 60*5, # 5 minutes
+ "player_name": ""
+ }
+
+
+def return_player_time(player):
+ return player["player_time"]
+
+def linebreak():
+ """
+ Print a line break
+ """
+ print("\n")
+
+def draw_key():
+ key = [
+ " _ __ ",
+ " / \ ",
+ "| _ |____________ ",
+ "| |_| | | ",
+ " \_ _ _/ ",
+ ]
+ for line in key:
+ print(line)
+
+def start_game():
+ initialize_variables()
+ global game_state
+ game_state = INIT_GAME_STATE.copy()
+
+ print("You wake up on a couch and find yourself in a strange house with no windows which you have never been to before.")
+ print("You don't remember why you are here and what had happened before.")
+ print("You feel some unknown danger is approaching and you must get out of the house, NOW!")
+ linebreak()
+ player_name = input("What is your name? ")
+ game_state['player_name'] = player_name
+
+ linebreak()
+ play_room(game_state["current_room"], first_entry=True)
+
+
+def check_time_left():
+ elapsed_time = time.time() - game_state["start_time"]
+ time_left = game_state["time_limit"] - elapsed_time
+ if time_left <= 0:
+ print("Time's up! You didn't escape in time.")
+ print("Game Over!!!")
+ background_sound.stop()
+ pygame.quit()
+ exit()
+ else:
+ minutes, seconds = divmod(int(time_left), 60)
+ print(f"Time remaining: {minutes} minutes {seconds} seconds")
+ return time_left
+
+def ending_sequence():
+ print("Congrats! You escaped the room!")
+ linebreak()
+ print("Game Over!!!")
+ linebreak()
+ finish_time = time.time()
+ player_time = finish_time - game_state["start_time"]
+ winner_result = {
+ 'player_name': game_state['player_name'],
+ 'player_time': player_time
+ }
+ winners_list.append(winner_result)
+ winners_list.sort(key=return_player_time)
+ print('------------------------------------------------------------')
+ print('-----------------')
+ i = 0
+ for winner in winners_list:
+ i += 1
+ print(f"Rank {i}. Name: {winner['player_name']}, Time: {int(winner['player_time'])} sec")
+ print('-----------------')
+ print('------------------------------------------------------------')
+ another_game = input('Do you want to play another game? (Yes or no)')
+ if another_game.lower().strip() == 'yes':
+ linebreak()
+ linebreak()
+ linebreak()
+ start_game()
+ else:
+ background_sound.stop()
+ pygame.quit()
+ exit()
+
+def play_room(room, first_entry):
+ time_left = check_time_left()
+ if room == game_state["target_room"]:
+ ending_sequence()
+
+ if first_entry:
+ print(f"\nYou are now in {room['name']}.")
+ else:
+ print(f"\nYou are still in {room['name']}.")
+ linebreak()
+ ask_for_next_action(room)
+
+def ask_for_next_action(room):
+ check_time_left()
+ action = input("What would you like to do? 'Explore' items in the room or 'Exit' the game: ").strip().lower()
+ if action == "explore":
+ explore_room(room)
+ elif action == "exit":
+ print("Exiting the game. Goodbye!")
+ print("Game Over!!!")
+ background_sound.stop()
+ pygame.quit()
+ exit()
+ else:
+ print("Not sure what you mean. Please choose a valid option.")
+ linebreak()
+ ask_for_next_action(room)
+
+def explore_room(room):
+ items = [i["name"] for i in room["items"]]
+ print("Available items: " + ", ".join(items))
+ linebreak()
+ examine_items(room)
+
+def examine_items(room):
+ desired_item_name = input("What would you like to examine?: ").strip().lower()
+ item_found = False
+ for item in room["items"]:
+ if item['name'].strip().lower() == desired_item_name:
+ item_found = True
+ if item["type"] == "furniture":
+ examine_furniture(item, room)
+ elif item["type"] == "door":
+ examine_door(item, room)
+ if not item_found:
+ print("No such item here. Please try another item.")
+ linebreak()
+ ask_for_next_action(room)
+
+def examine_furniture(item, room):
+ if "key" in item and not item["key"]["found"]:
+ item["key"]["found"] = True
+ game_state["keys_collected"].append(item["key"])
+ print(f"You've found {item['key']['name']}. It unlocks {item['key']['target']}.")
+ draw_key()
+ else:
+ print(item["detail"])
+ linebreak()
+ ask_for_next_action(room)
+
+def examine_door(item, room):
+ have_correct_key = False
+ for collected_key in game_state["keys_collected"]:
+ if collected_key["name"].strip().lower() == f"Key for {item['name']}".strip().lower():
+ have_correct_key = True
+ print(f"You unlock {item['name']} with {collected_key['name']}.")
+ item["locked"] = False
+ next_room = get_next_room_of_door(item, room)
+ play_room(next_room, first_entry=True)
+ if not have_correct_key:
+ print(f"It is locked but you don't have the key.")
+ linebreak()
+ ask_for_next_action(room)
+
+
+def get_next_room_of_door(door, current_room):
+ connected_rooms = object_relations[door["name"]]
+ for room in connected_rooms:
+ if(current_room != room):
+ return room
+
+# Start the game
+start_game()
+
+# Keep the window open until the user decides to close it
+input("Press Enter to exit...")
+