def get_current_page(self, img): img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) area = crop_image(img, **self.predefined.page_area) area = mask_image([254], [255], area) height, width = area.shape current_page = 0 for x in range(4): box = crop_image(area, (x * width / 4), 0, ((x + 1) * width / 4), height) if cv2.countNonZero(box) > 0: current_page = x break return current_page + 1
def check_battle(self, info, img): img = crop_image(img, **self.provider.predefined.duelist_name_area) name = self.provider.img_to_string(img, alpha_numeric).lower() if 'vagabond' in name or 'vaga' in name: info.name = name.replace('the', '').strip() return True return False
def is_street_replay(self): img = self.get_img_from_screen_shot() street_replay = self.predefined.street_replay img = crop_image(img, **street_replay) word = self.img_to_string(img, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") if 'street' in word or 'replay' in word.lower(): return True return False
def check_if_battle(self, img): img = np.array(img) img = crop_image(img, **self.predefined.page_area) blue_min = np.array([250, 250, 250], np.uint8) blue_max = np.array([255, 255, 255], np.uint8) amount = cv2.inRange(img, blue_min, blue_max) if cv2.countNonZero(amount) > (50 * 200): return True return False
def verify_battle(self, ori_img=None, log=True): if log: self.root.info("Verifying battle") if ori_img is None: ori_img = self.get_img_from_screen_shot() img = crop_image(ori_img, **self.predefined.auto_duel_location_pre) img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) word = self.img_to_string(img, alpha_numeric).lower() if word.startswith("auto") or 'auto' in word: pointer = self.predefined.duel_variant_version('v2-autoduel') return pointer, 2 img = crop_image(ori_img, **self.predefined.duel_location_pre) word = self.img_to_string(img, alpha_numeric).lower() if word.startswith("due") or word == "duel": pointer = self.predefined.duel_variant_version('v1') return pointer, 1 if log: self.root.debug("No Auto-Duel button or Button Found") self.root.critical("Cannot find the auto-duel button") raise DuelError("Auto Duel Button failed comparison test")
def is_occurrence(self, img=None): if img is None: img = self.provider.get_img_from_screen_shot() quick_ranked_area = self.provider.predefined.quick_rankduel_area img = crop_image(img, **quick_ranked_area) word = self.provider.img_to_string(img, self.alphabet_set, mask_area=([200], [255])) matched = list( set(word.lower().split(' ')) & set(self.looking_for.lower().split(' '))) if len(matched) > 0: return True return False
def wait_for(self, word, try_scanning=False): self.root.info("WAITING FOR {} BUTTON TO APPEAR".format(word)) ok = '' word = word.lower() while ok != word and not self.run_time.stop: img = self.get_img_from_screen_shot() img = crop_image(img, **self.predefined.ok_button_duel) try: if try_scanning: self.scan_for_ok(LOW_CORR) ok = self.img_to_string(img, alphabet).lower() except: self.wait_for_ui(1) continue if ok == word: break self.wait_for_ui(2)
def check_battle(self, info, img): """Will Always return true since this is the last possible battle mode available""" img = crop_image(img, **self.provider.predefined.duelist_name_area) name = self.provider.img_to_string(img, alpha_numeric).lower() info.name = name return True
def test_wait_for(self): location = os.path.join(self.provider.assets, "steam", "ok_button_duel.png") img = cv2.imread(location) img = crop_image(img, **self.provider.predefined.ok_button_duel) word = self.provider.img_to_string(img, alphabet).lower() self.assertTrue(word == 'ok')