def _wait_loading(self, emulator_position=0, lag_check=True): loading_reg = (543 if emulator_position == 0 else 1226, 341, 48, 29) screen_reg = (0, 0, 665, 390) loading = True last_screen_hash = None while loading: time.sleep(2.5) loading_ss = pyautogui.screenshot(region=loading_reg) # PIL Menggunakan ARGB Sedangkan OpenCv Menggunakan BGRA loading_ss = img_hash.calc_image_hash( numpy.array(loading_ss)[:, :, ::-1]) # Margin of errornya cuma 2 walaupun harusnya 1 if img_hash.comp_hash(loading_ss, self.loading_hash) > 2: if lag_check: screen_ss = pyautogui.screenshot(region=screen_reg) screen_ss = img_hash.calc_image_hash( numpy.array(screen_ss)[:, :, ::-1]) if last_screen_hash: if img_hash.comp_hash(last_screen_hash, screen_ss) > 0: loading = False time.sleep(4) last_screen_hash = screen_ss else: loading = False time.sleep(4)
def _is_tutorial(self): ss = pyautogui.screenshot(region=self.next_btn_reg) ss = img_hash.calc_image_hash(numpy.array(ss)[:, :, ::-1]) return True if img_hash.comp_hash(ss, self.next_btn_hash) < 2 else False
def identify_summon(self, img): hash_ = img_hash.calc_image_hash(img) for i in self.summon_list: if img_hash.comp_hash(i.hash_, hash_) < 3: return i
def acc_reroll(self, times: int, banner_to_summon: list, is_modded: bool): for x in range(times): summoned_list: list = [] summoned_folder: list = [] self._del_config() time.sleep(2) pyautogui.click(self.icon_pos) if is_modded: i = 0 while i <= 15: time.sleep(2) ss = pyautogui.screenshot(region=self.cls_mod_reg) ss = img_hash.calc_image_hash(numpy.array(ss)[:, :, ::-1]) if img_hash.comp_hash(ss, self.black_hash) < 2: continue elif img_hash.comp_hash(ss, self.cls_mod_hash) < 2: i += 1 else: time.sleep(7) pyautogui.click(self.skip_ad) time.sleep(1.5) pyautogui.click(self.cls_ad) pyautogui.click(self.cls_mod_reg) else: while True: time.sleep(2) ss = pyautogui.screenshot(region=self.cls_mod_reg) ss = img_hash.calc_image_hash(numpy.array(ss)[:, :, ::-1]) if img_hash.comp_hash(ss, self.black_hash) > 2: pyautogui.click(self.ok_btn) break time.sleep(3) pyautogui.click(self.ok_btn) self._wait_loading(lag_check=False) pyautogui.click(self.tos_box1) time.sleep(2) pyautogui.click(self.tos_box2) time.sleep(2) pyautogui.click(self.ok_btn) self._wait_loading() self._wait_loading(lag_check=False) pyautogui.click(self.ok_btn) time.sleep(6) pyautogui.click(self.skip_btn) time.sleep(3) pyautogui.click(self.ok_btn) time.sleep(10) pyautogui.click(self.ok_btn) while True: time.sleep(2) ss = pyautogui.screenshot(region=self.input_nick_reg) ss = img_hash.calc_image_hash(numpy.array(ss)[:, :, ::-1]) if img_hash.comp_hash(ss, self.input_nick_hash) < 2: time.sleep(2) break pyautogui.click(self.input_nick_reg) time.sleep(4) pyautogui.write("Reroll", interval=0.6) pyautogui.doubleClick(self.ok_btn, interval=2) pyautogui.moveTo(5, 5) time.sleep(10) while True: time.sleep(2) if self._is_tutorial(): time.sleep(4) pyautogui.click(self.next_btn_reg, interval=2, clicks=4) break i = 0 while i < 2: pyautogui.moveTo(5, 5) time.sleep(3) ss = pyautogui.screenshot(region=self.confirm_btn_reg) ss = img_hash.calc_image_hash(numpy.array(ss)[:, :, ::-1]) if img_hash.comp_hash(ss, self.confirm_btn_hash) < 2: pyautogui.click(self.confirm_btn_reg) time.sleep(8) if i == 1: self._wait_loading() i += 1 elif i == 1: time.sleep(2) break else: pyautogui.click(self.ok_btn) pyautogui.click(self.box_btn) self._wait_loading(lag_check=False) pyautogui.click(self.receive_btn) self._wait_loading(lag_check=False) pyautogui.click(self.ok_btn) self._wait_loading(lag_check=False) pyautogui.click(self.menu_btn) time.sleep(2) pyautogui.click(self.menu_summon_btn) self._wait_loading() for i in banner_to_summon: pyautogui.mouseDown(90, 300) pyautogui.moveTo(90, 190, duration=3) pyautogui.mouseUp() time.sleep(2) if i == 1: pyautogui.click(self.summon_1_btn) elif i == 2: pyautogui.click(self.summon_2_btn) elif i == 3: pyautogui.click(self.summon_3_btn) elif i == 4: pyautogui.click(self.summon_4_btn) elif i == 5: pyautogui.click(self.summon_5_btn) elif i == 6: pyautogui.mouseDown(90, 300) pyautogui.moveTo(90, 90, duration=1) pyautogui.mouseUp() time.sleep(3) pyautogui.click(self.summon_1_btn) elif i == 7: pyautogui.mouseDown(90, 300) pyautogui.moveTo(90, 90, duration=1) pyautogui.mouseUp() time.sleep(3) pyautogui.click(self.summon_2_btn) elif i == 8: pyautogui.mouseDown(90, 300) pyautogui.moveTo(90, 90, duration=1) pyautogui.mouseUp() time.sleep(3) pyautogui.click(self.summon_3_btn) elif i == 9: pyautogui.mouseDown(90, 300) pyautogui.moveTo(90, 90, duration=1) pyautogui.mouseUp() time.sleep(3) pyautogui.click(self.summon_4_btn) elif i == 10: pyautogui.mouseDown(90, 300) pyautogui.moveTo(90, 90, duration=1) pyautogui.mouseUp() time.sleep(3) pyautogui.click(self.summon_5_btn) else: return False time.sleep(2) pyautogui.click(self.summon_banner) time.sleep(3) pyautogui.click(self.ok_btn) self._wait_loading(lag_check=False) pyautogui.doubleClick(self.skip_btn, interval=2) while True: time.sleep(2) ss = pyautogui.screenshot(region=self.summon_back_reg) ss = img_hash.calc_image_hash(numpy.array(ss)[:, :, ::-1]) if self._is_tutorial(): time.sleep(2) pyautogui.click(self.next_btn_reg, interval=2, clicks=3) time.sleep(5) elif img_hash.comp_hash(ss, self.summon_back_hash) < 2: folder_name = "Bluestacks/Result/" + \ ''.join(random.choice(string.ascii_letters) for _ in range(10)) os.mkdir(f"{folder_name}") pyautogui.screenshot("{}/ori.png".format(folder_name)) summon_reg = ((51, 118, 40, 40), (167, 118, 40, 40), (283, 118, 40, 40), (400, 118, 40, 40), (516, 118, 40, 40), (51, 226, 40, 40), (167, 226, 40, 40), (283, 226, 40, 40), (400, 226, 40, 40), (516, 226, 40, 40)) for j in range(10): ss = pyautogui.screenshot("{}/{}.png".format( folder_name, j + 1), region=summon_reg[j]) summoned = self.identify_summon( numpy.array(ss)[:, :, ::-1]) if summoned: summoned_list.append(summoned) summoned_folder.append([folder_name]) time.sleep(5) pyautogui.click(self.summon_back_reg) break else: pyautogui.click(self.summon_skip) self._wait_loading() pyautogui.mouseDown(90, 110) pyautogui.moveTo(90, 450, duration=1) pyautogui.mouseUp() time.sleep(2) pyautogui.mouseDown(90, 110) pyautogui.moveTo(90, 450, duration=1) pyautogui.mouseUp() time.sleep(3) pyautogui.click(self.summon_1_btn) time.sleep(2) pyautogui.moveTo(self.close_tab) time.sleep(1) pyautogui.click(self.close_tab) print(x) print(summoned_folder) print(summoned_list)
elif summon_type == "r": summon_type = "Relic" else: print("Input Invalid") exit() try: summon_star = int(input("Input The Summon Star : ")) summon_score = int( input("Input The Summon Score (Personal Preferences) : ")) except ValueError: print("Input Invalid") exit() if os.path.exists("Bluestacks/summon_list.csv"): with open("Bluestacks/summon_list.csv", "a", newline='') as csv_file: csv_writer = csv.writer(csv_file, delimiter=";") hash_ = img_hash.calc_image_hash(cv2.imread(file_location)) csv_writer.writerow( [hash_, summon_name, summon_type, summon_star, summon_score]) else: if not os.path.exists("Bluestacks/"): os.mkdir("Bluestacks/") with open("Bluestacks/summon_list.csv", "w", newline='') as csv_file: csv_writer = csv.writer(csv_file, delimiter=";") csv_writer.writerow(["Hash", "Name", "Type", "Star", "Weight"]) print("summon_list.csv not found, populate the created csv first") exit(0) exit_input = input("Exit (Y/N)?").casefold() if exit_input == "y": exit()