def parse(self, path): if len(path) < 2: raise SyntaxErrorWrongNumberOfArguments(self.__class__.__name__, hints=CommandFactory().get_class_children( self.__class__.__name__)) url = path[0] next_step = CommandFactory().get_class(self.__class__.__name__, path[1], self.result_collector) path = path[2:] path.insert(0, url) return next_step.parse(path)
def parse(self, path): if len(path) < 2: raise SyntaxErrorWrongNumberOfArguments(self.__class__.__name__, 'At least 2 arguments expected. ' + self.pretty_name + ' is not valid command.', CommandFactory().get_class_children( self.__class__.__name__)) url = path[0] next_step = CommandFactory().get_class(self.__class__.__name__, path[1], self.result_collector) path = path[2:] path.insert(0, url) return next_step.parse(path)
def parse(self, path): if len(path) < 2: raise SyntaxErrorWrongNumberOfArguments( self.__class__.__name__, 'At least 2 arguments expected. ' + self.pretty_name + ' is not valid command.', CommandFactory().get_class_children(self.__class__.__name__)) url = path[0] next_step = CommandFactory().get_class(self.__class__.__name__, path[1], self.result_collector) path = path[2:] path.insert(0, url) return next_step.parse(path)
def parse(self, path): if len(path) < 2: raise SyntaxErrorWrongNumberOfArguments( self.__class__.__name__, hints=CommandFactory().get_class_children( self.__class__.__name__)) url = path[0] next_step = CommandFactory().get_class(self.__class__.__name__, path[1], self.result_collector) path = path[2:] path.insert(0, url) return next_step.parse(path)
def interact(self): ########################################################################### # Enter loop for this turn while (self._end_turns == 0): # Watch for pygame events. for event in pygame.event.get(): if (event.type == pygame.QUIT): engine().quit() break elif (event.type == pygame.MOUSEBUTTONDOWN): try: button1, button2, button3 = pygame.mouse.get_pressed() mouse_pos = pygame.mouse.get_pos() command_str = self.__drawer.clicked( mouse_pos, button1, button2, button3) if (command_str is not None): print command_str command = CommandFactory.parse_command(command_str) command.apply() self.__flush_spell_report_buffer() except UserError, error: self.__drawer.popup("Error", error) # Successful commands should redraw if (command_str is not None): self.draw()
def __init__(self, args): ########################################################################### self.__cmd = None self.__extra_args = None if (args): # Verify arg is a valid command name and get handle to cmd class from command_factory import CommandFactory self.__cmd = CommandFactory.get(args[0]) if (len(args) > 1): self.__extra_args = args[1:]
def interpreter(): '''Primary interaction method. Initialized Game state, sets player character.''' gsi.initialize(dungeon_map) test_char = char_test() gsi.add_character(test_char) gsi.player_character = test_char print(f"\nWelcome to {gsi.dungeon.title}") print(gsi.adventurers_current_room.describe()) command = prompt_user() action = CommandFactory(command) while action.command_string != "q": action.execute_command() command = prompt_user() action = CommandFactory(command) print("Logging off...")
def parse(self, path): if len(path) != 2: raise SyntaxErrorWrongNumberOfArguments( self.__class__.__name__, hints=CommandFactory().get_class_children( self.__class__.__name__)) parsed = ParsedValue(self, True, "PATH CONTAINS ANY") computed = False doc = self.result_collector.get_response_ElementTree() for e in doc.findall(path[0]): if e.text is not None: if type(e.text) is 'unicode': if path[1].decode('utf-8') in e.text.decode('utf-8'): computed = True break else: if path[1].decode('utf-8') in e.text: computed = True break return computed, parsed
def interact(self): ########################################################################### # Enter loop for this turn while (self._end_turns == 0): # Grab a line of text try: line = raw_input("% ") except KeyboardInterrupt: # User ctrl-d engine().quit() break # Add to history and process if not empty string if (line): try: command = CommandFactory.parse_command(line) command.apply() except UserError, error: print "ERROR:", error print "\nType: 'help [command]' for assistence" sys.stdout.flush()
def __init__(self, contact, pressure, base_position): self.contact = contact self.pressure = pressure self.base_position = base_position CommandFactory.__init__(self, contact, pressure)
def tap_sequence(self): return CommandFactory.tap_sequence(self, self.base_position)
def down_sequence(self): return CommandFactory.down_sequence(self, self.base_position)