Exemple #1
0
    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()
Exemple #2
0
    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()