adding the game made in class two weeks ago
parent
749676030b
commit
d20625ce30
@ -0,0 +1,87 @@
|
|||||||
|
from random import choice
|
||||||
|
|
||||||
|
welcome_message = """
|
||||||
|
---------------------------
|
||||||
|
You are in the XPUB studio.
|
||||||
|
|
||||||
|
|
||||||
|
---------------------------
|
||||||
|
"""
|
||||||
|
|
||||||
|
room = ["breadcube", "cup", "book"]
|
||||||
|
bag = ["lamp"]
|
||||||
|
|
||||||
|
def look():
|
||||||
|
room_string = ", ".join(room)
|
||||||
|
message = f"There are so many Apple computers here, but they're all locked. All you can see is: { room_string }"
|
||||||
|
return message
|
||||||
|
|
||||||
|
def defaultReply():
|
||||||
|
messages = [
|
||||||
|
"Hmm, not sure about that...",
|
||||||
|
"I don't understand that.",
|
||||||
|
"No clue what you're saying, sorry."
|
||||||
|
]
|
||||||
|
# otherlist = ["hello","hallo"]
|
||||||
|
message = choice(messages)
|
||||||
|
return message
|
||||||
|
|
||||||
|
def get(obj):
|
||||||
|
if obj in room:
|
||||||
|
room.remove(obj)
|
||||||
|
bag.append(obj)
|
||||||
|
message = f"You took { obj }."
|
||||||
|
else:
|
||||||
|
message = f"{ obj } is not in the room!"
|
||||||
|
return message
|
||||||
|
|
||||||
|
# -----------------------
|
||||||
|
# START OF GAME
|
||||||
|
|
||||||
|
print(welcome_message)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
|
reply = input()
|
||||||
|
# reply = "get lamp"
|
||||||
|
|
||||||
|
command = reply.split()
|
||||||
|
# command = ["get", "lamp"]
|
||||||
|
print(f"[DEBUG] Your command: { command }")
|
||||||
|
|
||||||
|
if len(command) >= 1:
|
||||||
|
action = command[0]
|
||||||
|
else:
|
||||||
|
action = ""
|
||||||
|
|
||||||
|
if len(command) >= 2:
|
||||||
|
obj = command[1]
|
||||||
|
else:
|
||||||
|
obj = ""
|
||||||
|
|
||||||
|
print(f"[DEBUG] Your action: { action }")
|
||||||
|
print(f"[DEBUG] Your object: { obj }")
|
||||||
|
|
||||||
|
if "look" in action or "walk" in action:
|
||||||
|
print(look())
|
||||||
|
elif "jump" in action:
|
||||||
|
print("Hey nice jump.")
|
||||||
|
print("Look at that couch! Do you like it?")
|
||||||
|
reply = input()
|
||||||
|
if "yes" in reply:
|
||||||
|
print("You start jumping on it...")
|
||||||
|
else:
|
||||||
|
print(defaultReply())
|
||||||
|
elif "get" in action:
|
||||||
|
if obj:
|
||||||
|
print(get(obj))
|
||||||
|
else:
|
||||||
|
print("You cannot GET without an object.")
|
||||||
|
elif "exit" in action:
|
||||||
|
break
|
||||||
|
elif "inventory" in action:
|
||||||
|
print(bag)
|
||||||
|
else:
|
||||||
|
print(defaultReply())
|
||||||
|
|
||||||
|
print("goodbye")
|
Loading…
Reference in New Issue