Ejemplo n.º 1
0
def __try_close():
    quick_close_cnt = 0
    while quick_close_cnt < 2:
        ar2 = ['close']
        player.find_touch_any(ar2)
        quick_close_cnt += 1
        _random_sleep(wmin=1, wmax=1)
Ejemplo n.º 2
0
def auto_play_explore(round=10):
    count = 0
    while count < round:
        ar1 = ['tansuo', 'exp_attack', 'exp_going', 'exp_continue']
        re = player.find_touch_any(ar1)
        if re == 'tansuo':
            print('开始新一轮...')
            count += 1
            #time.sleep(10)
        elif re == 'exp_attack':
            print('开始战斗...')
            ar2 = [
                'exp_attack',
            ]
            re = player.find_touch_any(ar2, False)
            if re == 'exp_attack':
                print('战斗中...')
                time.sleep(5)
        elif re == 'exp_continue':
            print('点击继续...')
            ar2 = [
                'exp_continue',
            ]
            re = player.find_touch_any(ar2, False)
            if re == 'exp_continue':
                print('继续...')
                time.sleep(5)
        elif re is None:
            ar2 = [
                'going_yys',
            ]
            re = player.find_touch_any(ar2, False)
            if re == 'ging_yys':
                print('托管中...')
                time.sleep(5)
Ejemplo n.º 3
0
def auto_play_fy(round=100):
    count = 0
    is_waiting = False
    while count < round:
        ar1 = [
            'fy_matching', 'fy_ready', 'fy_next', 'fy_open_box', 'fy_queue',
            'fy_start'
        ]
        re = player.find_touch_any(ar1)
        if re == 'fy_start':
            print('开始新一轮...')
            count += 1
            _random_sleep(wmin=1, wmax=3)
        elif re == 'fy_matching':
            print('开始匹配...')
            _random_sleep(wmin=4, wmax=7)
        elif re == 'fy_queue':
            print('排队中...')
            ar2 = [
                'fy_matching', 'fy_ready', 'fy_next', 'fy_open_box', 'fy_queue'
            ]
            while (True):
                re2 = player.find_touch_any(ar2, False)
                if re2 == 'fy_queue':
                    print('继续等待...')
                    _random_sleep(wmin=2, wmax=5)
                elif re2 == 'fy_ready' or re2 == 'fy_matching' or re2 == 'fy_next' or re2 == 'fy_open_box':
                    print('准备战斗...')
                    break
        elif re == 'fy_ready':
            print('开始匹配...')
            ar2 = [
                'fy_ready',
            ]
            re = player.find_touch_any(ar2, False)
            if re == 'fy_ready':
                print('开始战斗...')
                _random_sleep(wmax=4, wmin=1)
        elif re == 'fy_next':
            print('点击继续...')
            ar2 = [
                'fy_next',
            ]
            re = player.find_touch_any(ar2, False)
            if re == 'fy_next':
                print('点击继续...')
                _random_sleep(wmax=2, wmin=1)
        elif re == 'fy_open_box':
            print('开箱继续...')
            ar2 = [
                'fy_open_box',
            ]
            re = player.find_touch_any(ar2, False)
            if re == 'fy_open_box':
                print('开箱继续...')
                _random_sleep(wmax=2, wmin=1)
        elif re is None:
            print('不知所措...')
            _random_sleep(wmax=5, wmin=1)
        print('已经刷了' + str(count) + '次。。。')
Ejemplo n.º 4
0
def _friend_update():
    count = 0
    seqs = [{
        'name': ['friend_receive'],
        'id': 1,
        'sleep': 1,
        'response': '接受友情点...'
    }, {
        'name': ['friend_receive2'],
        'id': 2,
        'actions': None,
        'sleep': 1,
        'response': '接受要好友情点...'
    }, {
        'name': ['good_friend_send'],
        'id': 3,
        'actions': None,
        'sleep': 1,
        'response': '发出好友友情点',
        'tick': True
    }, {
        'name': ['friend_send'],
        'id': 4,
        'actions': None,
        'sleep': 1,
        'response': '发出友情点',
        'tick': True
    }, {
        'name': ['friend_switch'],
        'id': 5,
        'actions': None,
        'sleep': 1,
        'response': '切换友情界面',
        'next': [1, 2, 3, 4]
    }, {
        'name': ['friend_panel'],
        'id': 6,
        'actions': None,
        'sleep': 1,
        'response': '进入友情窗口',
        'next': [5]
    }]
    perform_touch_loop(seq=seqs, limits=10, full_seq=seqs)
    print('友情界面处理完毕,退出....')
    quick_close_cnt = 0
    while quick_close_cnt < 2:
        ar2 = ['close']
        player.find_touch_any(ar2)
        quick_close_cnt += 1
        _random_sleep(wmin=1, wmax=1)
Ejemplo n.º 5
0
def _daily_misc(rounds=3):
    count = 0
    while count < rounds:
        ar1 = [
            'yard_serve_food',
        ]
        re = player.find_touch_any(ar1)
        if re == 'yard_serve_food':
            print('搜集食物')
            _random_sleep(wmin=2, wmax=2)
            ar1 = [
                'yard_serve_confirm',
            ]
            r2 = player.find_touch_any(ar1)
            break
        count += 1
Ejemplo n.º 6
0
def entry_enchantment():
    while True:
        ar1 = ['explore_entry', 'tupo_entry', 'jj_tupo', 'jj_tupo_refresh']
        re = player.find_touch_any(ar1)
        _random_sleep(wmin=1, wmax=1)
        if re == 'jj_tupo':
            break
        elif re == 'jj_tupo_refresh':
            break
Ejemplo n.º 7
0
def auto_play_yuhun(round=50):
    count = 0
    while count < round:
        ar1 = [
            'start_yys',
            'exp_yys',
        ]
        re = player.find_touch_any(ar1)
        if re == 'start_yys':
            print('开始新一轮...')
            count += 1
            #time.sleep(10)
        elif re == 'exp_yys':
            print('领取奖励...')
        elif re is None:
            ar2 = [
                'going_yys',
            ]
            re = player.find_touch_any(ar2, False)
            if re == 'goging_yys':
                print('托管中...')
                time.sleep(5)
Ejemplo n.º 8
0
def auto_play_tower(round=500):
    count = 0
    while count < round:
        ar1 = ['tmp_start', 'tmp_finish', 'fy_open_box']
        re = player.find_touch_any(ar1)
        if re == 'tmp_start':
            print('开始新一轮...')
            count += 1
            #time.sleep(10)
        elif re == 'fy_open_box':
            print('领取奖励...')
        elif re == 'tmp_finish':
            print('结束本轮...')
        _random_sleep(wmax=100, wmin=1, factor=100)
Ejemplo n.º 9
0
* 功能:截屏,查找target_list列表图标在截屏上的位置,找到任意一个就会中断查找并点击所在位置。就是上面那个的批量处理版本,一次截屏查找多个目标。
* 传入参数target_list:string list,查找的图标文件名列表, 比如target=['start', 'end'], 则会查找wanted文件夹里的start.jpg图标和end.jpg图标所在位置,按顺序查找,只会点击最先找到的那个。
* 传入参数tap:同上
* 返回参数:找到了则返回找到的图标名称, 未找到返回None

### 代码示例:
    import auto_player as player
    
    #在当前屏幕寻找start.jpg图标的位置并点击
    player.find_touch("start") 
    
    #判断当前屏幕是否有start.jpg图标,只返回判断结果但不点击
    player.find_touch("start", tap=False) 
    
    #在当前屏幕寻找start.jpg图标或end.jpg,找到其中任意一个就会点击并返回
    player.find_touch_any(["start", "end"]) 
    
    #判断当前屏幕是否有start.jpg图标或end.jpg,只返回第一个找到的图标名,未找到则返回None
    player.find_touch_any(["start", "end"], tap=False) 
    
    #以上代码需要你先把开始按键、结算按键保存wanted文件夹并命名为start.jpg、end.jpg,否则会出现keyError错误
    

## 常见问题
* 注意文件路径不要有中文,否则会导致opencv读取图片失败,出现无法读取NoneType的Shape之类的错误
* 桌面版本是是截屏识别所以游戏窗口需要在前台不能被遮挡。
* 桌面版本如果找到了目标且鼠标移动了,却没有点击,大概率是权限问题。用管理员权限打开CMD来运行程序即可。
* ADB版本可以后台控制不怕遮挡,但是需要等手机截屏传输到电脑,传文件过程较慢且有极小概率出错卡死
* 果运行没有提示错误,但是一直匹配失败找不到,多半是图标精度问题,重新截取要找的图标
* ADB版本效率稍低但可以后台运行,不影响用电脑正常使用,我自己平常用的比较多。桌面版效率高,据反馈有概率被抓,可能是速度太快了或者游戏客户端带了检测。
* 脚本纯属爱好与分享,欢迎一起交流,但不提供售后服务
Ejemplo n.º 10
0
def auto_play_enchantment(round=30):
    count = 0
    quit_count = 0
    seqs = [{
        'name': ['jj_attack', 'tupo_attack2'],
        'id': 1,
        'actions': None,
        'sleep': 1,
        'response': '进攻选择....',
        'next': [2]
    }, {
        'name': ['fy_ready', 'jj_ready'],
        'id': 2,
        'actions': None,
        'sleep': 1,
        'response': '准备战斗...',
        'next': [3, 4]
    }, {
        'name': ['jj_fail_continue'],
        'id': 3,
        'actions': None,
        'sleep': 1,
        'response': '(失败)结束清算...',
        'next': [5, 6]
    }, {
        'name': ['jj_success_continue', 'jj_success_continue2'],
        'id': 4,
        'actions': None,
        'sleep': 1,
        'tick': True,
        'response': '(成功)结束清算...',
        'next': [5, 6]
    }, {
        'name': ['jj_tupo'],
        'id': 5,
        'actions': None,
        'sleep': 1,
        'response': '突破中...',
        'next': [1]
    }, {
        'name': ['jj_tupo_refresh', 'jj_tupo_refresh2'],
        'id': 6,
        'actions': None,
        'sleep': 1,
        'response': '刷完界面更新...',
        'next': [7]
    }, {
        'name': ['jj_tupo_confirm_refresh'],
        'id': 7,
        'actions': None,
        'sleep': 1,
        'response': '刷新确认...',
        'next': [5]
    }]

    perform_touch_loop(seq=seqs,
                       limits=30,
                       none_handler=__none_handler,
                       full_seq=seqs)
    print('友情界面处理完毕,退出....')
    quick_close_cnt = 0
    while quick_close_cnt < 2:
        ar2 = ['close']
        player.find_touch_any(ar2)
        quick_close_cnt += 1
        _random_sleep(wmin=1, wmax=1)
Ejemplo n.º 11
0
def _parties_update(wait_rounds=4):
    count = 0
    is_waiting = False
    while True:
        ar1 = [
            'party',
            'party_jj',
        ]
        re = player.find_touch_any(ar1)
        if re == 'party':
            print('进入阴阳寮')
            _random_sleep(wmin=1, wmax=1)
        elif re == 'party_jj':
            print('进入自己结界')
            _random_sleep(wmin=1, wmax=1)
            break

    ar1 = [
        'zero_out',
        'health_collect',
        'health_click_col',
    ]
    health_count = 0
    while health_count < wait_rounds:
        re = player.find_touch_any(ar1)
        if re == 'health_collect':
            _random_sleep(wmin=1, wmax=1)
        elif re == 'health_click_clo':
            print('收集体力...')
            _random_sleep(wmin=1, wmax=1)
        elif re == 'zero_out':
            print('体力已收集...')
            _random_sleep(wmin=1, wmax=1)
            __try_close()
            break
        else:
            health_count += 1

    ar1 = ['zero_out', 'ex_collect', 'ex_click_col']
    ex_count = 0
    while ex_count < wait_rounds:
        re = player.find_touch_any(ar1)
        if re == 'ex_collect':
            _random_sleep(wmin=1, wmax=1)
        elif re == 'ex_click_col':
            print('收集经验...')
            _random_sleep(wmin=1, wmax=1)
        elif re == 'zero_out':
            print('经验已收集...')
            _random_sleep(wmin=1, wmax=1)
            __try_close()
            break
        else:
            ex_count += 1

    print('结界界面处理完毕,退出....')
    quick_close_cnt = 0
    while quick_close_cnt < 2:
        ar2 = ['back']
        player.find_touch_any(ar2)
        quick_close_cnt += 1
        _random_sleep(wmin=1, wmax=1)

    print('阴阳寮界面处理完毕,退出....')
    quick_close_cnt = 0
    while quick_close_cnt < 2:
        ar2 = ['back_from_party']
        player.find_touch_any(ar2)
        quick_close_cnt += 1
        _random_sleep(wmin=1, wmax=1)