Facebook
From Colorant Dormouse, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 50
  1. import pyautogui as py
  2. import time,os
  3. class Bot:
  4.     positions = {'enclos':(1320,220),'etable':(1320,430),'tout':(1180,65),'1stDd':(430,200),'amour':(260,267),'endurance':(140,267),'maturite':(140,310),'energie':(260,310),'serenite_maturite':(205,360),'serenite_endurance':(140,360),'serenite_amour':(270,360)}
  5.     def click(self,img,clicks = 1,interval = 0,confidence = .7):
  6.         try:
  7.             py.click(py.center(py.locateOnScreen('assets/filtres/'+img,confidence = confidence)),clicks = clicks,interval = interval)
  8.         except: pass
  9.     def move_delay(self):
  10.         while not py.locateOnScreen('assets/dofus2.png',grayscale =True,confidence = .6):
  11.                 time.sleep(.5)
  12.         while py.locateOnScreen('assets/dofus2.png',grayscale = True,confidence = .6):
  13.                 time.sleep(0.2)
  14.     def recogn(self):
  15.         pics = os.listdir('assets/panneaux')
  16.         for pic in pics:
  17.             if py.locateOnScreen('assets/panneaux/'+pic):
  18.                 return pic
  19.     def Up(self,times = 1):
  20.         for i in range(times):
  21.             im = py.screenshot(region = (80,68,60,25))
  22.             self.elevage(self.recogn())
  23.             py.hotkey('ctrl','up')
  24.             self.move_delay()
  25.             if py.locateOnScreen(im):
  26.                 Up()
  27.     def Down(self,times = 1):
  28.         for i in range(times):
  29.             im = py.screenshot(region = (80,68,60,25))
  30.             self.elevage(self.recogn())
  31.             py.hotkey('ctrl','down')
  32.             self.move_delay()
  33.             if py.locateOnScreen(im):
  34.                 Down()
  35.            
  36.     def Right(self,times = 1):
  37.         for i in range(times):
  38.             im = py.screenshot(region = (80,68,60,25))
  39.             self.elevage(self.recogn())
  40.             py.hotkey('ctrl','right')
  41.             self.move_delay()
  42.             if py.locateOnScreen(im):
  43.                 Right()
  44.            
  45.     def Left(self,times = 1):
  46.         for i in range(times):
  47.             im = py.screenshot(region = (80,68,60,25))
  48.             self.elevage(self.recogn())
  49.             py.hotkey('ctrl','left')
  50.             self.move_delay()
  51.             if py.locateOnScreen(im):
  52.                 Left()
  53.     def vider_enclos(self):
  54.             py.click(self.positions['enclos'],pause = .5) # click enclos button
  55.             py.click(self.positions['tout'],pause = .5) # click tout button
  56.             py.click(self.positions['1stDd'],pause = .5) # click 1stDd button
  57.             py.dragTo(self.positions['etable'],duration = 1.5) # drag Dds
  58.             self.wait_til('filtres/vide.png')
  59.     def wait_til(self,img):
  60.         # waiting until an image is detected
  61.         while not py.locateOnScreen('assets/'+img):
  62.             time.sleep(.4)
  63.         time.sleep(.5)
  64.     def start(self):
  65.         while True:
  66.             self.Right(3);self.Down();self.Left(3);self.Up()
  67.    
  68.     def get_in(self,Type):
  69.         py.click(self.positions['etable'],pause = .5) # click etable button
  70.         self.click('filtre_but.png');time.sleep(.9)
  71.         if Type in ['amour.png','endurance.png','maturite.png']:
  72.             print('filtrage')
  73.             py.click(self.positions[Type[:-4]],clicks =2,interval =.8) # filtre Type
  74.             py.click(self.positions['serenite_'+Type[:-4]])
  75.             py.click(self.positions['tout'],pause = .5) # click enclos button
  76.             py.click(self.positions['1stDd'],pause = .5) # click tout button
  77.             py.dragTo(self.positions['enclos'],pause = 1,duration = 1.5) # drag button
  78.             try: py.click(py.locateOnScreen('assets/filtres/oui_but.png',confidence = .8),pause = 1.5)
  79.             except:pass            
  80.  
  81.     def elevage(self,Type):
  82.         # recognize the door
  83.         for pic in os.listdir('assets/portes'):
  84.             try:
  85.                 py.click(py.center(py.locateOnScreen('assets/portes/'+pic,confidence = .8,grayscale = True)))
  86.             except: pass
  87.         # waiting ..
  88.         self.wait_til('filtres/filtre_but.png')
  89.         self.vider_enclos()
  90.         self.get_in(Type)
  91.         py.press('esc')
  92. s = Bot()
  93. # while True:
  94. s.start()