From 95b70424b5d83cec44de0acf2c39d76d80b2723a Mon Sep 17 00:00:00 2001 From: joak Date: Tue, 24 Jan 2023 14:58:20 +0100 Subject: [PATCH] added the undo function --- adagm.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/adagm.py b/adagm.py index aecf55c..73cecd1 100644 --- a/adagm.py +++ b/adagm.py @@ -5,6 +5,7 @@ import time #variables room = ["a knife" , "a piece of bread" , "a bottle of water"] bag = ["a prayer book"] +history = [] def here() : room_string = ", ".join(room) @@ -49,7 +50,12 @@ displayMsg() while True: reply = input() + if(reply == "back"): + reply = history[-1] + + print (history) if "north" in reply : + history.append("north") print ("""you passed through the door north of the bedroom. you find yourself in the kitchen. it's a spacious room, full of shiny metal and sharp sounds. the cult member on kitchen duty for breakfast turns around to look at you, startled.""") @@ -58,6 +64,7 @@ while True: 'you are late for worship, what are you doing here? quick, hurry back'. he nods his head towards the door facing behind you.""") elif "east" in reply: + history.append("east") print("""through the east-facing door you find yourself in the dining hall, where someone has started to set the table. the sun is shining through the open window, reminding you once again of how late you are.""") time.sleep(2) @@ -67,6 +74,7 @@ while True: print("""would you like to go north-east through the winodw or back, to the leader? (please type either window or back)""") elif "window" in reply: + history.append("window") print("""your heart starts beating faster as you make your way to the open window. you climb the oak tree, your hands are slippery from sweat.""") time.sleep(2) @@ -74,14 +82,16 @@ while True: your hand misses,suddendly you fall all the way to the ground.""") print(winreply()) break - elif "back" in reply: - print() + elif "west" in reply: + history.append("west") + print("""you follow the faint sound of chanting throgh the west door,down a spiral staircase. you reach an enormous cave, where a man is sitting on a big chair, facing what looks like a sea of small figures dressed in white. The man looks up at you, he looks quite angry. you join the others in prayer. it's just another day.""") break elif "south" in reply : + history.append("south") print ("""the south door leads to a cold room without windows. there is a cage in the middle of the room, but the door to it was left empty. with a shudder you think that a person could fit in that cage. you go back.""")