def look(current, s): s = simplify(s) if(not s or s == '-n'): print current.name if(not s or s == '-d'): print str(current.door_num) + " door(s)" castle.throw_npc_exception(current)
def move(current, s): s = simplify(s) npc = None if(s): try: npc = castle.find_npc(s) print "Where would you like " + npc.name + " to be moved to?" except: print "I don't recognize that name...?" return current var = raw_input("? ") try: npc.location = castle.find_room(var) print npc.name + " is now in the " + npc.location.name return current except AttributeError: print "I don't recognize that room...?" else: print "Where would you like to move to?" var = raw_input("? ") try: print "You are now in (the) " + castle.find_room(var).name castle.throw_npc_exception(castle.find_room(var)) return castle.find_room(var) except AttributeError: print "I don't recognize that room...?"
def open_(current, s): s = simplify(s) if(not s): print "Enter a value after 'open'." elif(s == 'all'): current.print_adj() else: try: n = int(s) if(n > current.door_num): print "There aren't that many doors." else: n = n-1 print(current.adj[n].name) castle.throw_npc_exception(current, False, current.adj[n]) except ValueError: print "Enter a value after 'open'."
def step(current, s): s = simplify(s) if(not s): castle.step() castle.throw_npc_exception(current, True) return current elif(s == '-d'): # castle.step() # castle.print_npc_locations() castle.print_npc_vars() return current for i in range(len(current.adj)): if(s == current.adj[i].name.lower()): print "You are now in (the) " + current.adj[i].name + "." castle.throw_npc_exception() return current.adj[i] try: n = int(s) if(n > current.door_num): print "There aren't that many doors." return current else: n = n-1 print "You are now in (the) " + current.adj[n].name + "." castle.throw_npc_exception(current.adj[n]) return current.adj[n] except ValueError: print "I don't recognize that room...?" return current
current = castle.find_room(ui.load().name) elif (var[:4].lower() == 'look'): ui.look(current, var[5:]) elif (var[:4].lower() == 'open'): ui.open_(current, var[5:]) elif (var[:4].lower() == 'step'): current = ui.step(current, var[5:]) elif (var[:4].lower() == 'move'): current = ui.move(current, var[5:]) elif (var[:5].lower() == 'throw'): castle.throw_npc_exception(current, True) elif (var[:4].lower() == 'info'): ui.info() elif (var[:4].lower() == 'wave' or var[:7].lower() == 'shuffle'): ui.wave() elif (var[:5].lower() == 'hault'): ui.hault(var[6:]) elif (var[:7].lower() == 'release'): ui.release(var[8:]) elif (var[:4].lower() == 'kill'): ui.kill(var[5:])