예제 #1
0
    def _Move_good_IOS(self):
        goods = self._bd["gds"]
        for good in self.harvest_filter:
            img = UIMatcher.getLittleSquare(self._Sshot(),
                                            self._pos_good[good],
                                            scale=2)
            UIMatcher.saveScreen(img, good)

            for target in goods.keys():
                imageB = cv2.imread(target.value, 1)
                #msg("SSIM: {}  Target {}".format(score,str(target)))
                result = UIMatcher.find(img,
                                        imageB,
                                        criteria=diff_situation(good, target))

                if result:
                    msg(str(target) + " move to " + str(goods[target]))
                    position = self.pos[goods[target]]
                    #Pout(sx,sy,ex,ey)
                    self._move_good_by_id(good, position, times=4)
                    #self._drag(sx, sy, ex , ey,0.5)
                    break

            if not self._DEBUG:
                os.remove("s" + str(good) + ".png")
예제 #2
0
    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)
예제 #3
0
    def start(self):
        NomoreTrain = False
        n = random.randint(95, 105)
        n2 = 1
        Start_Time = time.time()

        # Initial Building pos and their level
        self._Initial_Building()
        self._AssignGoodsPosition()

        # Test crop the goods
        if self._DEBUG:
            #self._Test()
            UIMatcher.saveScreen(self._Sshot())
            pass

        while True:
            if n2 % n == 0:
                print(self)
                # 升级建筑
                self._upgrade_building()

            # Check if it is in the game
            self._runApp()

            # Swipe the screen to get the gold
            self._swipe()

            # Harvest the goods
            if not NomoreTrain:
                now = datetime.datetime.now().hour
                #识别到没有火车的标志 或者 五分钟内 没有搬运货物 就不再检测
                if self._No_more_train() or (
                        round(time.time() - Start_Time) >= 300
                        and self._count["harvest"] == 0):
                    msg("No more Train, Turn off harvest, set NomoreTrain" +
                        str(NomoreTrain))
                    NomoreTrain = True

            if NomoreTrain and datetime.datetime.now().hour == 9:
                NomoreTrain = False
                msg("Reset NomoreTrain " + str(NomoreTrain))

            self._harvest(NomoreTrain)

            # 判断是否可升级政策
            #self.check_policy()

            # 判断是否可完成任务
            self._check_task()

            # 判断是否有可点商品
            self._red_packet()

            # 简单粗暴的方式,处理 “XX之光” 的荣誉显示。
            # 不管它出不出现,每次都点一下
            self._cross_out()

            n2 += 1
예제 #4
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
예제 #5
0
 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
예제 #6
0
    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
예제 #7
0
 def _Test(self):
     for good in self.harvest_filter:
         img = UIMatcher.getLittleSquare(self._Sshot(),
                                         self._pos_good[good])
         UIMatcher.saveScreen(img, good)