def pypoint(): psn = PSN() path = './lib/func/pypoint' pyp = f'{path}/pypoint.png' # 友情点界面 callx10 = f'{path}/callx10.png' # 召唤 x10 按钮 call_notice = f'{path}/call_notice.png' # 召唤提示 call_confirm = f'{path}/call_confirm.png' # 召唤确认 call_next = f'{path}/call_next.png' # 继续十连召唤 full = f'{path}/full.png' # 召唤已经满了 num = 0 while 1: screenshot() if pic_in_sh(full): sys_log('PY POINT MUSTER FULL !') toast('PY POINT MUSTER FULL !') break elif pic_in_sh(call_confirm): num += 1 sys_log('PY POINT MUSTER CONFIRM @ %s' % num) picture_tap(call_confirm) elif pic_in_sh(call_next): sys_log('PY POINT MUSTER CONTINUE') picture_tap(call_next) elif pic_in_sh(pyp): sys_log('Current scene -> PY POINT') picture_tap(callx10) else: dbg_log('tap screen') psn.PYPONT() time.sleep(0.2)
def main(): dbg_shoot = int(bool(len(sys.argv) > 1)) script_path = os.path.abspath(sys.argv[0]) script_name = os.path.basename(sys.argv[0]).split('.')[0] + '.py' folder_path = script_path.replace(script_name, '') os.chdir(folder_path) init_env() sys_log('//-------------------------------------------------//') sys_log('//------------ S T A R T --------------------//') sys_log('//-------------------------------------------------//') if dbg_shoot: screenshot() exit() while rd_tmp_ini('run', 'flag') == 'True': screenshot() scene_operation() time.sleep(0.5) # @TODO:random 0.3-0.5s # exit() sys_log('//-------------------------------------------------//') sys_log('//------------ D O N E --------------------//') sys_log('//-------------------------------------------------//') toast('SCRIPT DONE !!!')
def infinity_pool(): psn = PSN() path = './lib/func/infinity_pool' psn.INFI_M1() time.sleep(1) lst = png_lst(path) while 1: screenshot() for file in lst: # thd = 0.85 flg = picture_tap(path + '/' + file) if flg == 1: print(file) break
from util.clean import clean_tmp times = recovery_times play = run_time f = open('log.txt', 'w') st = '[MAIN] MAX APPLES: ' + \ str(times) + '\r' + '[MAIN] MAX TIMES: ' + str(play) + '\r' f.write(st) f.close() clean_tmp() while times >= 0: time.sleep(0.2) screenshot() s = Major() end = s.recognize() if play == "inf": ap = recover_ap() if ap == 1 and times != 0: continue elif ap == 1 and times == 0: apa = '[MAIN] Out of AP!' output_log(apa) break elif ap == 2: times = times - 1 out = '[MAIN] Apples left: ' + str(times)
def judge_support(mode): set_rank = get_cfg('support', 'rank') if not set_rank: set_rank = '0' if mode == '1': factor_servant = 10 factor_craft = 1 elif mode == '2': factor_servant = 1 factor_craft = 10 elif mode == '3': factor_servant = 10 factor_craft = 10 set_refresh = int(get_cfg('support', 'refresh')) for i in range(set_refresh + 1): sup = [] # print(set_rank) for rank in set_rank: psn = PSN() eval('psn.ZHIJIE%s()' % rank) screenshot() while not pic_in_sh(support_path + '/lastlogin.png'): time.sleep(1) screenshot() index = 0 if pic_in_sh(support_path + '/top1.png') or pic_in_sh(support_path + '/top2.png'): # 存在助战数目 > 2 while not pic_in_sh(support_path + '/end.png'): sh = cv2.imread(screenshot_path, 0) for region in [support_sel_size_1, support_sel_size_2]: index += 1 x1, y1, x2, y2 = region tmp = get_support_item(sh[y1:y2, x1:x2]) # dbg_log([rank, index] + tmp) ########### dbg_log('rank=%s, index=%-2s, servant=%s, skill=%s, craft=%s, manpo=%s' % \ (rank, index, tmp[0], tmp[1], tmp[2], tmp[3])) sup.append([rank, index] + tmp) x0, y0, x1, y1, d0 = support_swipe_parm swipe(x0, y0, x1, y1, d0) screenshot() index = 90 sh = cv2.imread(screenshot_path, 0) for region in [support_sel_size_8, support_sel_size_9]: index += 1 x1, y1, x2, y2 = region tmp = get_support_item(sh[y1:y2, x1:x2]) # print([rank, index] + tmp) # dbg_log([rank, index] + tmp) ########### dbg_log('rank=%s, index=%-2s, servant=%s, skill=%s, craft=%s, manpo=%s' % \ (rank, index, tmp[0], tmp[1], tmp[2], tmp[3])) sup.append([rank, index] + tmp) screenshot() swipe(1860, 1045, 1860, 120, 1500) # 滑动到最上面 else: # 存在助战数目 <=2 sh = cv2.imread(screenshot_path, 0) for region in [support_sel_size_1, support_sel_size_2]: index += 1 x1, y1, x2, y2 = region tmp = get_support_item(sh[y1:y2, x1:x2]) # dbg_log([rank, index] + tmp) ########### dbg_log('rank=%s, index=%-2s, servant=%s, skill=%s, craft=%s, manpo=%s' % \ (rank, index, tmp[0], tmp[1], tmp[2], tmp[3])) sup.append([rank, index] + tmp) # screenshot() weight = [] for tmp in sup: weight.append(factor_servant * sum(tmp[2:4]) + factor_craft * sum(tmp[4:])) # 当前 rank 没有符合条件的助战 # 继续下一个 rank if max(weight) < 10: continue # 选出当前 rank 助战中最合适的一个 for i in range(len(weight)): if weight[i] == max(weight): rank, index = sup[i][:2] psn = PSN() eval('psn.ZHIJIE%s()' % rank) if index >= 90: swipe(1860, 280, 1860, 1060, 1500) # 滑动到最下面 tap_support(9 - (index % 2)) else: for i in range((index - 1) // 2): x0, y0, x1, y1, d0 = support_swipe_parm swipe(x0, y0, x1, y1, d0) tap_support(2 - (index % 2)) sys_log('select the support') sys_log('rank=%s, index=%-2s, servant=%s, skill=%s, craft=%s, manpo=%s' % \ (sup[i][0], sup[i][1], sup[i][2], sup[i][3], sup[i][4], sup[i][5])) return True # 如果所有 rank 都没有合适的助战 # 进行刷新操作 if max(weight) < 10 and i != set_refresh: sys_log('refresh support') picture_tap(support_path + '/refresh.png') screenshot() picture_tap(support_path + '/confirm.png') time.sleep(2) continue # 如果选择不到合适的助战,根据 keepgo 进行后续操作 if int(get_cfg('support', 'keepgo')): tap_support(1) else: toast('select support fail') exit()
def craftexp(): psn = PSN() path = './lib/func/craftexp' strscene = cv2.imread(f'{path}/strscene.png', 0) zoom2x2 = cv2.imread(f'{path}/zoom2x2.png', 0) zoom3x3 = cv2.imread(f'{path}/zoom3x3.png', 0) zoom4x4 = cv2.imread(f'{path}/zoom4x4.png', 0) decide = cv2.imread(f'{path}/decide.png', 0) confirm = cv2.imread(f'{path}/confirm.png', 0) strengthen = cv2.imread(f'{path}/strengthen.png', 0) cx, cy = [210, 380] # craft one all_pos = [] for row in range(3): for col in range(7): px = cx + col * 200 py = cy + row * 214 all_pos.append([px, py]) while 1: screenshot() sh = cv2.imread(screenshot_path, 0) thd = 0.85 # if analyze(sh, full, thd): # sys_log('PYPOINT FULL !') # break if analyze(sh, strscene, thd): sys_log('Current scene : strengthen') psn.STRSELECT() time.sleep(1) screenshot() if picture_tap(f'{path}/zoom2x2.png', thd=0.9): time.sleep(1) screenshot() time.sleep(1) screenshot() if picture_tap(f'{path}/zoom3x3.png', thd=0.9): time.sleep(1) screenshot() sh = cv2.imread(screenshot_path, 0) if analyze(sh, zoom4x4, thd): for tmp_pos in all_pos: px, py = tmp_pos tap(px, py, 20) time.sleep(0.1) time.sleep(1) screenshot() if picture_tap(f'{path}/decide.png'): time.sleep(3) screenshot() else: sys_log('ERROR - A1') ############################## if picture_tap(f'{path}/decide.png'): sys_log('END THIS AAAA') exit() ############################## tap(1655, 1020, 20) time.sleep(1) screenshot() if picture_tap(f'{path}/confirm.png'): time.sleep(3) screenshot() else: sys_log('ERROR - A3') for i in range(100): psn.PYPONT() screenshot() sh = cv2.imread(screenshot_path, 0) time.sleep(0.2) if analyze(sh, strscene, thd): time.sleep(1.5) break else: sys_log('DDDDDDONEEEEEE @@')
def addap0(): """ 使用[苹果]或者[圣晶石]增加体力 AP 数值 :return: """ # set_clr_lst # if rd_tmp_ini('run', 'parm') == 'apples': # config_num = int(get_cfg('run', rd_tmp_ini('run', 'parm')).split(',')[-1]) # else: # config_num = int(get_cfg('run', rd_tmp_ini('run', 'parm'))) current_num = int(rd_tmp_ini('run', 'num')) if rd_tmp_ini('run', 'parm') == 'apples': current_num += 1 wt_tmp_ini('run', 'num', str(current_num)) color = get_cfg('run', rd_tmp_ini('run', 'parm')).split(',')[0] if color != 'Cu': picture_tap(addap_path + f'/apple{color}.png') screenshot() if not pic_in_sh(addap_path + '/confirm.png'): sys_log('@@run out of apples/stones...1') exit() elif rd_tmp_ini('run', 'parm') == 'stones': current_num += 1 wt_tmp_ini('run', 'num', str(current_num)) picture_tap(addap_path + 'stone.png') screenshot() if not pic_in_sh(addap_path + '/confirm.png'): sys_log('@@run out of apples/stones...2') exit() elif int(get_cfg('addap', 'en_apple')) or int(get_cfg('addap', 'en_stone')): if int(get_cfg('addap', 'en_apple')): tmp0 = ['appleAg.png', 'appleAu.png'] else: tmp0 = [] if int(get_cfg('addap', 'en_stone')): tmp1 = ['stone.png'] else: tmp1 = [] auto_eat = tmp0 + tmp1 for item in auto_eat: picture_tap(addap_path + '/' + item) screenshot() if pic_in_sh(addap_path + '/confirm.png'): break if not pic_in_sh(addap_path + '/confirm.png'): sys_log('@@run out of apples/stones...3') exit() # thd = 0.85 if picture_tap(addap_path + '/confirm.png'): pass time.sleep(3) # just in case.... # thd = 0.85 if picture_tap(addap_path + '/close.png'): pass
def attack(): if not rd_tmp_ini('battle', 'round'): wt_tmp_ini('battle', 'round', 0) if not rd_tmp_ini('battle', 'turn'): wt_tmp_ini('battle', 'turn', 0) lst = png_lst(cfg_path) svt_priority = get_cfg('priority', 'servant') for file in lst: # name, ext = os.path.splitext(file) if 'servant' in file and not svt_priority: os.remove(cfg_path + '/' + file) # 获取 skill 和 final ..并转换为新的变量 if not rd_tmp_ini('battle', 'skill_list'): wt_tmp_ini('battle', 'skill_list', cfgstr2lst(skill_string_trans(get_cfg('skill', 'value')))) if not rd_tmp_ini('battle', 'ultimate_list'): wt_tmp_ini('battle', 'ultimate_list', cfgstr2lst(get_cfg('ultimate', 'value'))) psn = PSN() # 获取当前 round 数 round = curr_round() # 获取当前回合数,并更新, +=1 是因为文件内是从 0 开始计算的,需要转换一下 turn = int(rd_tmp_ini('battle', 'turn')) turn += 1 wt_tmp_ini('battle', 'turn', turn) sys_log('current @ round : %1d, turn : %-2d' % (round, turn)) # 获取 turn / round 参数 op_unit = get_cfg('skill', 'unit') # round / turn if op_unit == 'round': td_idx = round # turn_round_idx else: td_idx = turn # 获取设定某些回合技能输入 20201117 skill_lst = eval(rd_tmp_ini('battle', 'skill_list')) if td_idx <= len(skill_lst): turn_skill(skill_lst[td_idx - 1]) skill_lst[td_idx - 1] = '' wt_tmp_ini('battle', 'skill_list', skill_lst) # 点击 ATTACK 按钮,更新截图 psn.ATK() time.sleep(1) screenshot() # 获取指令卡属性 cards_attr = turn_attribute() cards_sort = turn_sorted(cards_attr) # 这里可以控制前面的输出来进行简化 ultimate_list = eval(rd_tmp_ini('battle', 'ultimate_list')) if td_idx <= len(ultimate_list): ins = ultimate_list[td_idx - 1].upper() else: ins = '' if td_idx <= len(ultimate_list) and ins != 'XXX' and ins != '': lst = tap_crd(cards_sort, 2) idx = 0 for char in ins: if char == 'X': crd = lst[idx] tap(crd.px, crd.py) time.sleep(1) idx += 1 else: eval('psn.E%s()' % char) ultimate_list[td_idx - 1] = '' wt_tmp_ini('battle', 'ultimate_list', ultimate_list) else: lst = tap_crd(cards_sort, 3) for crd in lst: tap(crd.px, crd.py) time.sleep(1)