示例#1
0
 def define_window(self):
     '''
     This method is used to acquire the location of the game window for
     the bot to be able to dynamically calculate the correct positions
     for various actions.
     '''
     #Read the game area dimensions from blitz_window.txt, quit if undefined
     try:
         blitz_window = open('blitz_window.txt', 'r')
     except IOError:
         print('blitz_window.txt not found. Define the game window now?')
         if raw_input('[y/N] ') in ['y', 'Y']:  # Define the window
             if utils.define_game_window(self.mouse):
                 #Parse the blitz_window.txt file
                 with open('blitz_window.txt', 'r') as blitz_window:
                     fl, sl = blitz_window.readlines()
                     self.upper_x, self.upper_y = [int(i) for i in fl.split(',')]
                     self.lower_x, self.lower_y = [int(i) for i in sl.split(',')]
             else:  # Quits if canceled
                 print('Aborting BlitzBot initialization...')
                 sys.exit(0)  # Quits
         else:  # Do not define the window
             print('Aborting BlitzBot initialization...')
             sys.exit(0)  # Quits
     else:
         #Parse the blitz_window.txt file
         fl, sl = blitz_window.readlines()
         self.upper_x, self.upper_y = [int(i) for i in fl.split(',')]
         self.lower_x, self.lower_y = [int(i) for i in sl.split(',')]
         blitz_window.close()
示例#2
0
 def redefine_window(self):
     '''Like define_window except it assumes you want to overwrite it'''
     if utils.define_game_window(self.mouse):
         with open('blitz_window.txt', 'r') as blitz_window:
             fl, sl = blitz_window.readlines()
             self.upper_x, self.upper_y = [int(i) for i in fl.split(',')]
             self.lower_x, self.lower_y = [int(i) for i in sl.split(',')]
         self.define_keys()