def prompt(player, room): """ Desc: Main game prompt. Called by: main game loop Notes: returns either a room or None. If returning None, all necessary actions are taken within the called function. """ command = None while not command: commandFull = raw_input(player.showHP() + ">") parts = commandFull.lower().split(' ') command = parts[0] args = parts[1:] if command in ('1','2','3','4','enter'): if command in ('1','2','3','4'): command = int(command) #this seems hacky, but actions are classes and must return themselves. Making the new room a variable of the action instance allows it to return a room. return actions.enter(command, room, player).newRoom elif command == "enter": try: args = int(args) return actions.enter(args, room, player).newRoom except: print "That is not a valid door." elif command == 'help': #need to extend this to look at other commands gamehelp = actions.ghelp() print gamehelp.helpTxt return None elif command in ('l', 'look'): action = actions.look(room) return None elif command in ('quit', 'exit'): action = actions.quit(player) return None elif command in ('stat','stats','status'): action = actions.status(player) return None else: return None
def prompt(player, room): """ Desc: Main game prompt. Called by: main game loop Notes: returns either a room or None. If returning None, all necessary actions are taken within the called function. """ command = None while not command: commandFull = raw_input(player.showHP() + ">") parts = commandFull.lower().split(' ') command = parts[0] args = parts[1:] if command in ('1', '2', '3', '4', 'enter'): if command in ('1', '2', '3', '4'): command = int(command) #this seems hacky, but actions are classes and must return themselves. Making the new room a variable of the action instance allows it to return a room. return actions.enter(command, room, player).newRoom elif command == "enter": try: args = int(args) return actions.enter(args, room, player).newRoom except: print "That is not a valid door." elif command == 'help': #need to extend this to look at other commands gamehelp = actions.ghelp() print gamehelp.helpTxt return None elif command in ('l', 'look'): action = actions.look(room) return None elif command in ('quit', 'exit'): action = actions.quit(player) return None elif command in ('stat', 'stats', 'status'): action = actions.status(player) return None else: return None
def basePrompt(player, room): """ Desc: Main game prompt. Called by: main game loop Notes: returns either a room or None. If returning None, all necessary actions are taken within the called function. """ command = None while not command: commandFull = raw_input(player.showHP() + ">") parts = commandFull.lower().split(" ") command = parts[0] args = parts[1:] if command in ("1","2","3","4","enter"): if command in ("1","2","3","4"): command = int(command) return actions.enter(command, room, player) elif command == "enter": try: args = int(args) return actions.enter(args, room, player) except: print "That is not a valid door." elif command == "help": #need to extend this to look at other commands if len(args) == 0: actions.ghelp() else: actions.ghelp(args[0]) return elif command in ("l", "look"): if len(args) == 0: actions.look(room) else: actions.examine(player, args[0]) return elif command in ("quit", "exit"): actions.quit(player) return elif command in ("stat","stats","status"): actions.status(player) return elif command == "use": if len(args) == 0: print "That command requires a target.\n" else: actions.use(player, args[0]) return elif command in ("i", "inv", "inven", "inventory"): actions.inventory(player) return elif command in ("e", "eq", "equip"): if len(args) == 0: actions.worn(player) else: actions.equipCommand(player, args[0]) return elif command == "worn": actions.worn(player) return elif command in ("un", "une", "uneq", "unequip"): if len(args) == 0: print "That command requires a target.\n" else: actions.unequipCommand(player, args[0]) return elif command == "get": if len(args) == 0: print "That command requires a target.\n" else: actions.get(player, room, args[0]) elif command == "drop": if len(args) == 0: print "That command requires a target.\n" else: actions.drop(player, room, args[0]) elif command in ("ex", "exam", "examine"): if len(args) == 0: print "That command requires a target.\n" else: actions.examine(player, args[0]) elif command == "set": if len(args) == 0: actions.set(player) elif len(args) == 1: print "Set command requires a hotkey and a skill.\n" elif len(args) == 2: actions.set(player, args[0], args[1]) else: actions.set(player, args[0], args[1], args[2]) else: return