import time import sys rooms = { "start":"You're in a small, dark room with brick walls. There is a metal door to the south.", "south":"You are standing in a small room with a tiled floor, smooth white walls, and a small wooden table. There is a metal door to the north, a key on the table and a octahedron on the floor." } dirs = { "start":{"n":None,"e":None,"s":"south","w":None,"d":None,"u":None}, "south":{"n":"start","e":None,"s":None,"w":None,"d":None,"u":None} } items = { "start":[], "south":["key","octahedron"] } reqitem = { "south":{"n":"key"} } inv = set([]) def actions(): global action global room action = input("‒→") action = action.split() if (len(action) > 1): arg = action[1] action = action[0] if (action is "n" or action is "e" or action is "s" or action is "w" or action is "u" or action is "d"): roomdirs = dirs[room] if (roomdirs[action] != None): if (room in reqitem): #print(reqitem[room], roomdirs[action]) if (action in reqitem[room]): #print(reqitem[room]) curitem = reqitem[room] if (curitem[action] in inv): room = roomdirs[action] else: print("You need a "+curitem[action]+" to go through!") else: room = roomdirs[action] print(rooms[room]) else: print("You cannot go in that direction.") elif (action is "get"): if (arg in items[room]): print("Took "+arg+".") inv.add(arg) items[room].remove(arg) else: print("No item of that name.") elif (action is "inv"): if (inv): for i in inv: print(i) else: print("You have no items.") room = "start" action = None print("Welcome to my CYOA!\n") for i in range(5): print("."), time.sleep(0.2) print("\n"+"≡"*25+"\n\n\n") time.sleep(0.2) time.sleep(0.1) print(rooms[room]) while (1 is 1): actions()