Created
March 12, 2024 13:24
-
-
Save Alee14/53b249462e259de4d3a8ac016a605e0e to your computer and use it in GitHub Desktop.
Module 6 - Room "Game"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an interactive game where you explore rooms, and it logs each room and activity you do | |
def hub(fout): | |
fout.write('Entering the house\n') | |
while True: | |
print('You are at the main entrance of the house') | |
print('Which room you want to enter?') | |
print() | |
print('1. Living Room') | |
print('2. Kitchen') | |
print('3. Office') | |
print('4. Exit') | |
choice = input('> ') | |
if choice == "1": | |
fout.write('Entering living room\n') | |
room1(fout) | |
elif choice == "2": | |
fout.write('Entering kitchen\n') | |
room2(fout) | |
elif choice == "3": | |
fout.write('Entering office\n') | |
room3(fout) | |
elif choice == "4": | |
fout.write('Exiting house\n') | |
print('Exiting the house') | |
fout.close() | |
exit(0) | |
else: | |
print('Invalid choice. Select from the list.') | |
print() | |
continue | |
def room1(fout): | |
while True: | |
print('You are in the living room') | |
print('Which choice do you pick?') | |
print() | |
print('1. Watch TV') | |
print('2. Play games') | |
print('3. Walk to another room') | |
choice = input('> ') | |
if choice == "1": | |
print('You are watching some YouTube on the TV') | |
fout.write('Watching some YouTube\n') | |
continue | |
elif choice == "2": | |
print('You are playing some games on the Wii U') | |
fout.write('Playing some games\n') | |
continue | |
elif choice == "3": | |
print('Going back to the main entrance') | |
fout.write('Walking out of the living room\n') | |
hub(fout) | |
break | |
else: | |
print('Invalid choice. Select from the list.') | |
print() | |
continue | |
def room2(fout): | |
while True: | |
print('You are now in the kitchen') | |
print('Which choice do you pick?') | |
print() | |
print('1. Cook food') | |
print('2. Eat snack') | |
print('3. Walk to another room') | |
choice = input('> ') | |
if choice == "1": | |
print('Cooking some food') | |
fout.write('Cooking some food\n') | |
continue | |
elif choice == "2": | |
print('Eating snack') | |
fout.write('Eating snack\n') | |
continue | |
elif choice == "3": | |
print('Going back to the main entrance') | |
fout.write('Walking out of the kitchen\n') | |
hub(fout) | |
break | |
else: | |
print('Invalid choice. Select from the list.') | |
print() | |
continue | |
def room3(fout): | |
while True: | |
print('You are now in the office') | |
print('Which choice do you pick?') | |
print() | |
print('1. Work on the computer') | |
print('2. Browse on the internet') | |
print('3. Walk to another room') | |
choice = input('> ') | |
if choice == "1": | |
print('Working on computer') | |
fout.write('Working on computer\n') | |
continue | |
elif choice == "2": | |
print('Browsing the internet') | |
fout.write('Browsing the internet\n') | |
continue | |
elif choice == "3": | |
print('Going back to the main entrance') | |
fout.write('Walking out of the office\n') | |
hub(fout) | |
break | |
else: | |
print('Invalid choice. Select from the list.') | |
print() | |
continue | |
file = open('Rooms.txt', 'w') | |
hub(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment