From ac161785e0195f1f1a8ba70cf0bc4bd4ecd192d7 Mon Sep 17 00:00:00 2001 From: gyt Date: Thu, 9 Jul 2026 12:54:33 -0400 Subject: [PATCH] Initial commit: 4game.py --- 4game.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 4game.py diff --git a/4game.py b/4game.py new file mode 100755 index 0000000..3a18585 --- /dev/null +++ b/4game.py @@ -0,0 +1,48 @@ +# Define Rooms +rooms = { + 'start': { + 'name': 'Start', + 'description': "You find yourself in the dimly lit hallway. The walls are bare and you notice several doors leading to different rooms.", + 'north': 'hallway' + }, + 'hallway': { + 'name': 'Hallway', + 'description': "A long corridor with no visible exits." + } +} + +# Define Player State +player = { + 'current_room': 'start', + 'inventory': [] +} + +def move(current_room, direction): + return rooms[current_room][direction] + +def look(): + print(f"Current Room: {player['current_room']]}\n") + current_room_name = player['current_room'] + result = move(current_room_name, 'north') + if isinstance(result, str): + print(result) + else: + player['current_room'] = result + look() + +while True: + action = input("What do you want to do? Type 'look', 'move north', or 'quit' to exit: ") + + if action == 'look': + look() + elif action == 'move north': + current_room_name = player['current_room'] + result = move(current_room_name, 'north') + if isinstance(result, str): + print(result) + else: + player['current_room'] = result + look() + elif action == 'quit': + print("Goodbye!") + break