def _red_packet(self):
        if self._ar:
            x, y = self._btn["B_Store"]
            x2, y2 = self._btn["B_Build"]
            if r_color(UIMatcher.getPixel(self._Sshot(), x, y), RED_PACKET,
                       10):
                self._tap(x, y)

                ms()
                if r_color(UIMatcher.getPixel(self._Sshot(), x2, y2),
                           BLUE_MENU):
                    for px, py in self._btn["P_redpacket"]:
                        while r_color(
                                UIMatcher.getPixel(self._Sshot(), px, py),
                                RED_PACKET, 15):
                            self._tap(px, py)
                            ms()
                            self._cross_out(10)
                            self._count["red_packet"] += 1
                            msg("Detected RED_PACKET, TAPS")
                elif self._DEBUG:
                    msg("RED_PACKET " + str(x) + "," + str(y))

            elif self._DEBUG:
                UIMatcher.saveScreen(self._Sshot(), "RED_PACKET")
            ss()
            self._tap(x2, y2)
            ms()
            if r_color(UIMatcher.getPixel(self._Sshot(), x2, y2), BLUE_MENU):
                self._tap(x2, y2)
 def _Is_Btn_Upgrade(self):
     x, y = self._btn["B_Upgrade"]
     R, G, B = UIMatcher.getPixel(self._Sshot(), x, y)
     if B > R:
         return False
     elif B < R:
         return True
Beispiel #3
0
 def _have_redpocket_third(self):
     print("test_third")
     while True:
         screen = self.d.screenshot(format="opencv")
         R, G, B = UIMatcher.getPixel(screen, 480 / 533, 312 / 948)
         if R >= 180 and G < 110:
             self.d.click(480 / 533, 312 / 948)
             while True:
                 screen_1 = self.d.screenshot(format="opencv")
                 R_1, G_1, B_1 = UIMatcher.getPixel(screen_1, 0.487, 0.831)
                 if R_1 > G_1:
                     self.d.click(0.811, 0.263)
                 else:
                     break
         else:
             break
Beispiel #4
0
 def guess_good(self, good_id):
     '''
     按住货物,探测绿光出现的位置
     这一段应该用numpy来实现,奈何我对numpy不熟。。。
     '''
     diff_screen = self.get_screenshot_while_touching(
         GOODS_POSITIONS[good_id])
     pos_ID = 0
     for pos_ID in range(1, 10):
         # print('hhhh')
         x, y = GOODS_SAMPLE_POSITIONS[pos_ID]
         lineCount = 0
         for line in range(-2, 6):  #划8条线, 任意2条判定成功都算
             R, G, B = 0, 0, 0
             for i in range(-10, 10):  # 取一条线上20个点,取平均值
                 r, g, b = UIMatcher.getPixel(diff_screen,
                                              (x + 1.73 * i) / 540,
                                              (y + line + i) / 960)
                 R += r
                 G += g
                 B += b
             # 如果符合绿光的条件
             if R / 20 > 220 and G / 20 < 70:
                 lineCount += 1
         if lineCount > 1:
             return pos_ID
     return 0
 def _has_train(self):
     x, y = self._btn["P_Train"]
     screen = self._Sshot()
     R, G, B = UIMatcher.getPixel(screen, x, y)
     if r_color((R, G, B), TRAIN_COLOR_IOS, diff=10):
         return True
     if self._DEBUG:
         msg("No train (" + str(R) + "," + str(G) + "," + str(B) + ")")
         UIMatcher.saveScreen(self._Sshot(), "has_train")
     return False
Beispiel #6
0
 def _have_redpocket_first(self):
     # while True:
     #     self.d.click(84/533,688/940)
     print("test_first")
     while True:
         screen = self.d.screenshot(format="opencv")
         R, G, B = UIMatcher.getPixel(screen, 152 / 533, 312 / 948)
         print(R, G, B)
         if R >= 180 and G < 110:
             self.d.click(152 / 533, 312 / 948)
             while True:
                 screen_1 = self.d.screenshot(format="opencv")
                 R_1, G_1, B_1 = UIMatcher.getPixel(screen_1, 0.487, 0.831)
                 if R_1 > G_1:
                     self.d.click(0.184, 0.263)
                 else:
                     break
         else:
             break
 def _No_more_train(self):
     x, y = self._btn["P_NoMoreTrain"]
     R, G, B = UIMatcher.getPixel(self._Sshot(), x, y)
     if r_color((R, G, B), NO_MORE_TRAIN_IOS):
         self._tap(x, y)
         ms()
         x2, y2 = self._btn["B_NoMoreTrain"]
         self._tap(x2, y2)
         ms()
         return True
     if self._DEBUG:
         msg("No More train (" + str(R) + "," + str(G) + "," + str(B) + ")")
         UIMatcher.saveScreen(self._Sshot(), "No_more_train")
     return False
Beispiel #8
0
 def _detect_cross(self, screen, positon):
     x, y = positon
     # print(x,y)
     R, G, B = 0, 0, 0
     for i in range(-4, 4):  # 取一条45度线线上8个点,取平均值
         r, g, b = UIMatcher.getPixel(screen, x + i / self.dWidth,
                                      y + i / self.dHeight)
         R += r
         G += g
         B += b
     # 如果符合叉叉(白色)的条件
     if R / 8 > 250 and G / 8 > 250 and B / 8 > 250:
         return True
     return False
    def _check_task(self):
        if not self.auto_task:
            return
        x, y = self._btn["B_Task"]
        self._tap(x, y)
        s(2)
        x2, y2 = self._btn["B_Finish_Task"]
        R, G, B = UIMatcher.getPixel(self._Sshot(), x2, y2)
        if r_color((R, G, B), TASK_B_FINISH_IOS):
            self._tap(x2, y2)
            ss()
            if self._DEBUG:
                msg("Task Finished Color(" + str(R) + "," + str(G) + "," +
                    str(B) + ")")
                UIMatcher.saveScreen(self._Sshot(), "Finished")

        self._cross_out()
        return False
Beispiel #10
0
 def _close_upgrade_interface(self):
     screen = self.d.screenshot(format="opencv")
     # 判断升级按钮的颜色,蓝比红多就处于正常界面,反之在升级界面
     R, G, B = UIMatcher.getPixel(screen, 0.974, 0.615)
     if B < R:
         self.d.click(0.9, 0.57)