Ejemplo n.º 1
0
    def find_transportation_arrow(self):
        run = 1
        # moves to north east area of mini map
        Mouse.randMove(680 - 20, 65 - 20, 680 + 20, 65 + 20, 1)
        time.sleep(5)
        while run:
            mini_map = Screenshot.shoot(571, 29, 718, 180, 'hsv')
            low = np.array([10, 101, 147])
            high = np.array([13, 255, 211])

            # applies mask
            mask = cv2.inRange(mini_map, low, high)
            # removes any noise
            kernel = np.ones((5, 5), np.uint8)
            dilation = cv2.dilate(mask, kernel, iterations=1)

            _, contours, _ = cv2.findContours(dilation.copy(),
                                              cv2.RETR_EXTERNAL,
                                              cv2.CHAIN_APPROX_SIMPLE)
            for c in contours:
                (x, y, w, h) = cv2.boundingRect(c)
                x += 568
                y += 36
                x2 = x + w
                y2 = y + h
                Mouse.randMove(x, y, x2, y2, 1)
                run = 0
            time.sleep(1)
            print('running again')
Ejemplo n.º 2
0
    def find_transportation_arrow(self):
        run = 1
        # moves to north east area of mini map
        Mouse.randMove(680-20,65-20,680+20,65+20,1)
        time.sleep(5)
        while run:
            mini_map = Screenshot.shoot(571,29,718,180,'hsv')
            low = np.array([10,101,147])
            high = np.array([13,255,211])

            # applies mask
            mask = cv2.inRange(mini_map, low, high)
            # removes any noise
            kernel = np.ones((5,5), np.uint8)
            dilation = cv2.dilate(mask, kernel, iterations = 1)

            _, contours, _ = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
            for c in contours:
                (x, y, w, h) = cv2.boundingRect(c)
                x += 568
                y += 36
                x2 = x + w
                y2 = y + h 
                Mouse.randMove(x,y,x2,y2,1)
                run = 0
            time.sleep(1)
            print('running again')
Ejemplo n.º 3
0
 def findCageOptionInBubbles(self):
     """Pass args from findFishBubbles meth. Finding cage option in fishing guild"""
     if self.findCageOption():
         Mouse.randMove(0,0,700,500, 1)
         return True
     else:
         return
Ejemplo n.º 4
0
    def findFishBubbles(self,click_n,func,*args):
        """Pass a function to do after it finds the fish bubbles"""

        # water bubbles
        #low = np.array([103,81,0])
        #high = np.array([111,255,255])
        play_screen = Screenshot.shoot(6,59,510,355,'hsv')

        low = np.array([220,50,100])
        high = np.array([255,255,255])
        mask = cv2.inRange(play_screen, low, high)

        #cv2.imshow('img', mask)
        #cv2.waitKey(0)

        kernel = np.ones((5,5), np.uint8)
        dilation = cv2.dilate(mask, kernel, iterations = 1)

        #cv2.imshow('dilation', dilation)
        #cv2.waitKey(0)

        _, contours, _ = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        for c in random.choice(contours):
            (x, y, w, h) = cv2.boundingRect(c)
            x += 6 
            y += 59
            x2 = x + w 
            y2 = y + h 
            Mouse.randMove(x,y,x2,y2,click_n)
            # pass args to fucntion doing the actions
            # fucn should return true if needs to continue loking  at other bubbles
            if func():
                continue
            else:
                return
Ejemplo n.º 5
0
 def doInMatched(self, *args, **kwargs):
     print("Found template")
     #unpacks args from Match.images
     img_pat,x,y,pt, w, h = args
     # combines pattern image w/ template coords
     x = pt[0]+x
     y = pt[1]+y
     # dimensions of pattern image
     img_pat_w, img_pat_h = img_pat.shape[::-1]
     # moves and clicks on the random passed coords
     Mouse.randMove(x,y,x+img_pat_w-10, y, 1)
Ejemplo n.º 6
0
    def findFishingIcon(self):
        #fish color
        low = np.array([93,119,84])
        high = np.array([121,255,255])
        mask, mm_x, mm_y = self.mini_map_mask(low, high)

        _, contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        for c in contours:
            (x, y, w, h) = cv2.boundingRect(c)
            x += mm_x 
            y += mm_y
            x2 = x + w 
            y2 = y + h 
            Mouse.randMove(x,y,x2,y2,1)
            run= 0 
            time.sleep(1)
            return 0
        return 1
Ejemplo n.º 7
0
    def findBankIcon(self):
        # bank colo
        low = np.array([26,160,176])
        high = np.array([27,244,228])
        mask, mm_x, mm_y = self.mini_map_mask(low, high)

        cv2.imshow('mask', mask)
        cv2.waitKey(0)

        _, contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

        for c in contours:
            (x, y, w, h) = cv2.boundingRect(c)
            x += 568 
            y += 36
            x2 = x + w 
            y2 = y + h 
            Mouse.randMove(x,y,x2,y2,1)
            run= 0 
            time.sleep(1)
            return
Ejemplo n.º 8
0
    def find_fairy_ring(self):
        run = 1
        while run:
            play_screen = Screenshot.shoot(6, 59, 510, 355, 'hsv')
            # finding white on fairy ring inner circle
            low = np.array([107, 92, 93])
            high = np.array([113, 255, 129])

            mask = cv2.inRange(play_screen, low, high)

            kernel = np.ones((10, 10), np.uint8)
            dilation = cv2.dilate(mask, kernel, iterations=1)
            #closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)

            #_,contours,_ = cv2,findContours(closing.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
            _, contours, _ = cv2.findContours(dilation, cv2.RETR_TREE,
                                              cv2.CHAIN_APPROX_SIMPLE)

            for con in contours:
                print("Area: {}".format(cv2.contourArea(con)))
                if cv2.contourArea(con) > 1.0:
                    (x, y, w, h) = cv2.boundingRect(con)
                    x += self.rs_x
                    y += self.rs_y
                    x1 = x
                    y1 = y
                    x2 = x + w
                    y2 = y + h
                    print("x1:{} y1:{} x2:{} y2:{}".format(x1, y1, x2, y2))
                    #print(cv2.contourArea(con))
                    #M = cv2.moments(con)
                    # finds centroid
                    #x,y = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
                    Mouse.randMove(x1, y1, x2, y2, 3)
                    time.sleep(5)
                    if RS.findOptionClick(x1, y1, 'cis'):
                        run = 0
                    time.sleep(2)
                    break
Ejemplo n.º 9
0
    def find_fairy_ring(self):
        run = 1
        while run:
            play_screen = Screenshot.shoot(6,59,510,355,'hsv')
            # finding white on fairy ring inner circle
            low = np.array([107,92,93])
            high = np.array([113,255,129])

            mask = cv2.inRange(play_screen, low, high)

            kernel = np.ones((10,10), np.uint8)
            dilation = cv2.dilate(mask, kernel, iterations = 1)
            #closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)

            #_,contours,_ = cv2,findContours(closing.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
            _,contours,_ = cv2.findContours(dilation, cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

            for con in contours:
                print("Area: {}".format(cv2.contourArea(con)))
                if cv2.contourArea(con) > 1.0:
                    (x, y, w, h) = cv2.boundingRect(con)
                    x += self.rs_x
                    y += self.rs_y
                    x1 = x
                    y1 = y
                    x2 = x + w
                    y2 = y + h
                    print("x1:{} y1:{} x2:{} y2:{}".format(x1,y1,x2,y2))
                    #print(cv2.contourArea(con))
                    #M = cv2.moments(con)
                    # finds centroid
                    #x,y = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
                    Mouse.randMove(x1,y1,x2,y2,3)
                    time.sleep(5)
                    if RS.findOptionClick(x1,y1,'cis'):
                        run = 0
                    time.sleep(2)
                    break
Ejemplo n.º 10
0
def findOptionClick(x,y,option_name):
    """Option name of in Image database only needs to be passed, x,y are obsoleate"""
    import Imgdb
    # Image DB
    idb = Imgdb.ImgDb()

    template = idb.pickled_dict[option_name]
    # turning template to graysacle
    if len(template.shape) == 3:
        template = cv2.cvtColor(template,cv2.COLOR_RGB2GRAY)

    w, h = template.shape[::-1]#Width, height of template image

    # coords of playing window
    x1 = 0 #5
    y1 = 25
    x2 = 767
    y2 = 524
    rs_window = Screenshot.shoot(x1,y1,x2,y2)

    # Finds all black lines
    ret,thresh1 = cv2.threshold(rs_window,0,255,cv2.THRESH_BINARY)
    # inverst to black to white
    ret,thresh1 = cv2.threshold(thresh1,0,255,cv2.THRESH_BINARY_INV)

    # looks for all squares
    _, contours,h = cv2.findContours(thresh1,1,2)

    for cnt in contours:
        # looks for biggest square
        if cv2.contourArea(cnt) <= 1695.0:
            continue
        # checks contour sides
        approx = cv2.approxPolyDP(cnt,0.01*cv2.arcLength(cnt,True),True)

        # Square found here vvvv
        if len(approx)==4:
            #print("square of {}".format(cv2.contourArea(cnt)))
            #cv2.drawContours(rs_window,[cnt],0,(255,255,255),-1)

            # get geometry of approx
            # add rs coords
            x,y,w,h = cv2.boundingRect(cnt)

            #combines with playing window
            x += x1
            y += y1

            # scrshot of option menu on play window
            img = Screenshot.shoot(x,y,x+w,y+h)
            ret,pattern = cv2.threshold(img,254,255,cv2.THRESH_BINARY)
            ###  DEBUG LINE
            #cv2.imshow('img',pattern)
            #cv2.waitKey(0)
            #return
            break
    else:
        Mouse.randMove(0,0,500,500,0)
        time.sleep(1)
        print("Else ran")

    res = cv2.matchTemplate(pattern,template,cv2.TM_CCOEFF_NORMED)
    threshold = .9
    loc = np.where( res >= threshold)

    # clicks on option here when found in pattern
    for pt in zip(*loc[::-1]):#goes through each found image
        rsx, rsy = position()
        x += pt[0] + rsx
        y += pt[1] + rsy
        y1 = y
        y2 = y+10
        img = Screenshot.shoot(x,y1,x+w,y2)
        # range of x and y to click on.
        # in the options
        Mouse.randMove(x,y1,x+(w/2),y2, 1)
        # autopy.mouse.click()#taking out since it does not delay the click
        RandTime.randTime(0,0,0,0,0,9)
Ejemplo n.º 11
0
 def telSalve(self):
     RS.press_button('magic')
     Mouse.randMove(568, 350, 586, 368, 1)
Ejemplo n.º 12
0
def back2bank():
    Mouse.randMove(709, 111, 714, 113, 1)
    RandTime.randTime(3, 0, 0, 3, 9, 9)
    Mouse.randMove(703, 119, 709, 121, 1)
    RandTime.randTime(4, 0, 0, 4, 9, 9)
    Mouse.randMove(394, 174, 480, 201, 1)
Ejemplo n.º 13
0
 def telSalve(self):
     RS.press_button('magic')
     Mouse.randMove(568,350,586,368,1)
Ejemplo n.º 14
0
def back2bank():
    Mouse.randMove(709,111,714,113,1)
    RandTime.randTime(3,0,0,3,9,9)
    Mouse.randMove(703,119,709,121,1)
    RandTime.randTime(4,0,0,4,9,9)
    Mouse.randMove(394,174,480,201,1)