From d20625ce302b0d663a231fd1d7ac41d9c3f77413 Mon Sep 17 00:00:00 2001 From: Manetta <> Date: Tue, 31 Jan 2023 13:52:23 +0100 Subject: [PATCH] adding the game made in class two weeks ago --- game-made-in-class.py | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 game-made-in-class.py diff --git a/game-made-in-class.py b/game-made-in-class.py new file mode 100644 index 0000000..d5d68b2 --- /dev/null +++ b/game-made-in-class.py @@ -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") \ No newline at end of file