def runmain(address, account, password):
    a = Automator(address, account)
    a.start()

    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<')
    t0 = time.time()

    need_auth = a.login(ac=account, pwd=password)
    if need_auth:
        auth_name, auth_id = random_name(), CreatIDnum()
        a.auth(auth_name=auth_name, auth_id=auth_id)

    # ========现在开始完成新手教程========
    '''
    最高优先级
    引导, 结束标志

    高优先级
    同意,跳过,登记,OK,扭蛋跳过

    复合点击
    长条菜单->跳过 (只使用两次)
    圆Menu->跳过->跳过

    低优先级
    未激活的加速战斗

    默认,点击(1,100)
    '''

    count = 0  # 记录跳过战斗的数量
    times = 0  # 记录主页出现的次数
    while True:
        screen = a.d.screenshot(format="opencv")
        num_of_white, x, y = UIMatcher.find_gaoliang(screen)
        if num_of_white < 70000:
            try:
                a.d.click(x * a.dWidth, y * a.dHeight + 20)
            except:
                pass
            time.sleep(1)
            continue

        template_paths = {
            'img/tongyi.jpg': (490, 459, 686, 496),
            'img/tiaoguo.jpg': None,
            'img/dengji.jpg': (382, 352, 578, 391),
            'img/ok.bmp': None,
            'img/niudan_jiasu.jpg': (700, 0, 960, 100)
        }
        for template in template_paths:
            if a.click(screen, template, at=template_paths[template]):
                break

        if count < 2 and (UIMatcher.img_where(
                screen, 'img/caidan.jpg',
                at=(861, 15, 940, 37))):  # 有两场战斗是可以跳过的
            count += 1
            a.d.click(900, 25)
            time.sleep(0.8)
            a.d.click(591, 370)
            time.sleep(0.5)
            continue
        if UIMatcher.img_where(screen,
                               'img/caidan_yuan.jpg',
                               at=(898, 23, 939, 62)):
            a.d.click(919, 45)
            time.sleep(0.8)
            a.d.click(806, 46)
            time.sleep(1)
            a.d.click(589, 370)
            time.sleep(0.5)
            continue
        if UIMatcher.img_where(screen,
                               'img/jingsaikaishi.bmp',
                               at=(755, 471, 922, 512)):
            a.d.click(786, 308)  # 选角色
            time.sleep(0.2)
            a.d.click(842, 491)  # 开始
            time.sleep(0.5)
            continue
        if UIMatcher.img_where(screen,
                               'img/kuaijin.jpg',
                               at=(891, 478, 936, 517)):
            a.d.click(911, 493)
            time.sleep(3)
            continue
        if UIMatcher.img_where(screen, 'img/liwu.bmp',
                               at=(891, 413, 930, 452)):
            if times == 2:
                break
            times += 1
            print('在主页的第', times, '次')
        # default
        a.d.click(1, 100)
        time.sleep(0.5)
    print('新手教程已完成')
    # ===========新手教程完成============
    # ===========开始前期准备============

    a.lockimg('img/liwu.jpg', elseclick=[(1, 100)], elsedelay=0.5, alldelay=2)
    a.shouqu()  # 拿一点钻石用于买扫荡券,理论上至少能拿到300钻
    a.goumaimana(1)  # 买扫荡券
    a.goumaitili(3)
    a.goumaijingyan()

    a.setting()  # 设置无动画、低帧率
    a.lockimg('img/zhuxianguanqia.jpg',
              elseclick=[(480, 513)],
              elsedelay=0.5,
              alldelay=1)
    a.lockimg('img/zhuxianguanqia.jpg',
              ifclick=[(562, 235)],
              ifdelay=3,
              alldelay=0)
    # ===========前期准备结束============
    # =============开始刷图==============
    # 如果执行了新手教程,应该已经开成两倍速了,否则直接
    a.shoushuazuobiao(313, 341)  # 1-3
    a.shoushuazuobiao(379, 240, 1)  # 1-4
    a.shoushuazuobiao(481, 286)  # 1-5
    a.shoushuazuobiao(545, 381, 1)  # 1-6
    a.shoushuazuobiao(607, 304)  # 1-7
    a.shoushuazuobiao(620, 209)  # 1-8
    a.shoushuazuobiao(747, 243)  # 1-9
    a.qianghua()
    a.shoushuazuobiao(824, 348, 1)  # 1-10 虽然没有繁琐教程,但解锁东西过多,还是去用函数
    a.shoushuazuobiao(129, 413, 1)  # 2-1
    a.shoushuazuobiao(255, 413, 1)  # 2-2
    a.qianghua()
    a.shoushuazuobiao(379, 379)  # 2-3
    a.shoushuazuobiao(332, 269)  # 2-4
    a.shoushuazuobiao(237, 206, 1)  # 2-5
    a.shoushuazuobiao(353, 161)  # 2-6
    a.shoushuazuobiao(453, 231)  # 2-7
    a.shoushuazuobiao(479, 316, 1)  # 2-8
    a.qianghua()
    a.d.drag(600, 270, 200, 270, 0.1)  # 拖拽到最右,固定后面的点击位置
    time.sleep(1)
    a.shoushuazuobiao(526, 372)  # 2-9 装备危险
    a.shoushuazuobiao(647, 375)  # 2-10
    a.shoushuazuobiao(756, 346)  # 2-11
    a.qianghua()
    a.d.drag(600, 270, 200, 270, 0.1)  # 拖拽到最右,固定后面的点击位置
    time.sleep(1)
    a.shoushuazuobiao(741, 228, 1)  # 2-12
    a.shoushuazuobiao(138, 188, 1)  # 3-1
    # 结束刷图
    # 开始探索
    a.lockimg('img/liwu.bmp', elseclick=[(131, 533)], elsedelay=1)  # 回首页
    # a.tansuo(mode=2) 还有问题,暂时关闭
    a.shouqurenwu()
    a.change_acc()  # 退出当前账号,切换下一个
    t = time.time()
    print('>>>>>>>账号:', account, '已刷完, 用时', t - t0, '秒<<<<<<<')
示例#2
0
def runmain(address, account, password):
    # 主功能体函数
    # 请在本函数中自定义需要的功能

    a = Automator(address)
    a.start()

    # #opencv识别可视化 无法在多线程中使用
    # plt.ion()
    # fig, ax = plt.subplots(1)
    # plt.show()

    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<', '\r\n')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao.txt内
    a.init_home()  # 初始化,确保进入首页
    a.sw_init()  # 初始化刷图

    a.gonghuizhijia()  # 家园一键领取
    a.goumaimana(1)  # 购买mana 10次
    a.mianfeiniudan()  # 免费扭蛋
    #a.mianfeishilian()  # 免费十连
    a.shouqu()  # 收取所有礼物
    a.dianzan()  # 公会点赞
    a.shouqu()  # 收取所有礼物
    a.hanghui()  # 行会捐赠
    a.dixiacheng()  # 地下城
    a.goumaitili(3)  # 购买3次体力
    a.shouqurenwu()  # 收取任务
    shuatu_auth(a, account)  # 刷图控制中心
    # a.shuajingyan(10) # 刷1-1经验(自带体力购买),10为主图
    a.shouqurenwu()  # 二次收取任务

    a.change_acc()  # 退出当前账号,切换下一个
示例#3
0
文件: main.py 项目: zh981008/zh-farm
import uiautomator2 as u2
import time
from utils import *
from cv import *
from Automator import *
import matplotlib.pylab as plt

# plt.ion()
# fig, ax = plt.subplots(1)
# plt.show()

a = Automator()
a.start()


def login_auth(ac, pwd):
    need_auth = a.login(ac=ac, pwd=pwd)
    if need_auth:
        auth_name, auth_id = random_name(), CreatIDnum()
        a.auth(auth_name=auth_name, auth_id=auth_id)


def init_acc():  #原作者的初始号初始化函数,不适用于农场号
    while True:

        screen_shot = a.d.screenshot(format="opencv")
        state_flag = a.get_screen_state(screen_shot)

        if state_flag == 'dark':
            print('画面变暗,尝试进入引导模式点击')
            screen_shot = a.d.screenshot(format="opencv")
示例#4
0
def runmain(address, account, password):
    # 主功能体函数
    # 请在本函数中自定义需要的功能

    a = Automator(address)
    a.start()
    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<', '\r\n')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao.txt内
    a.init_home_with_running()  # 初始化,确保进入首页
    a.sw_init()  # 初始化刷图

    #a.gonghuizhijia()  # 家园一键领取
    #a.goumaimana(0)  # 购买mana 1次
    #a.mianfeiniudan()  # 免费扭蛋
    #a.mianfeishilian()  # 免费十连
    #a.shouqu()  # 收取所有礼物
    #a.dixiacheng()  # 地下城
    #a.goumaitili(3)  # 购买3次体力
    #a.shouqurenwu()  # 收取任务
    #shuatu_auth(a, account)  # 刷图控制中心
    #a.hanghui()  # 行会捐赠
    #a.goumaitili(times=3)  # 购买times次体力
    #a.shuajingyan(map=3)  # 刷1-1经验,map为主图
    #a.shouqurenwu()  # 二次收取任务
    a.joinhanghui("勤劳的妖妖妖")
    #a.dianzan(1)  # 公会点赞,sortflag=1表示按战力排序
    a.dixiacheng(True)

    #input("Press Enter to continue...")
    a.change_acc()  # 退出当前账号,切换下一个
示例#5
0
def runmain(address,account,password):
    #主功能体函数
    #请在本函数中自定义需要的功能

    a = Automator(address)
    a.start()

    # #opencv识别可视化 无法在多线程中使用
    # plt.ion()
    # fig, ax = plt.subplots(1)
    # plt.show()

    print('>>>>>>>即将登陆的账号为:',account,'密码:',password,'<<<<<<<')
    a.login_auth(account, password)#注意!请把账号密码写在zhanghao2.txt内
    a.init_home()#初始化,确保进入首页
    

    a.tansuo()#探索
    a.dixiachengDuanya()#地下城,请把队伍列表里1队设置为打boss队,2队设置为aoe队
    a.shouqurenwu()#收取任务
    a.shouqu()#收取所有礼物


    a.change_acc()#退出当前账号,切换下一个
def runmain(address, account, password):
    # 主功能体函数
    # 请在本函数中自定义需要的功能

    a = Automator(address, account)
    a.start()

    # #opencv识别可视化 无法在多线程中使用
    # plt.ion()
    # fig, ax = plt.subplots(1)
    # plt.show()

    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao2.txt内
    a.init_home()  # 初始化,确保进入首页

    a.goumaimana()

    a.change_acc()  # 退出当前账号,切换下一个
示例#7
0
def runmain(address, account, password, clubname):
    # 主功能体函数
    # 请在本函数中自定义需要的功能

    a = Automator(address)
    a.start()
    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<', '\r\n')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao.txt内
    a.init_home()  # 初始化,确保进入首页

    a.joinhanghui(clubname)  #加入行会

    a.change_acc()  # 退出当前账号,切换下一个
示例#8
0
def acceptmain(address, account, password):
    # 接受入会邀请函数,请不要更改本函数中的功能
    a = Automator(address)
    a.start()
    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<', '\r\n')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao.txt内
    a.init_home()
    a.jieshouhanghui()
    a.change_acc()  # 退出当前账号,切换下一个
示例#9
0
def invitemain(address, account, password, inviteUID):
    # 邀请入会函数,请不要更改本函数中的功能
    a = Automator(address)
    a.start()
    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<', '\r\n')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao.txt内
    a.init_home()
    a.yaoqinghanghui(inviteUID)
    a.change_acc()  # 退出当前账号,切换下一个
示例#10
0
def runmain(address, account, password, fun, kickflag=0):
    # 主功能体函数
    # 请在本函数中自定义需要的功能

    a = Automator(address)
    a.start()
    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<', '\r\n')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao.txt内
    a.init_home()  # 初始化,确保进入首页
    a.sw_init()  # 初始化刷图

    a.gonghuizhijia()  # 家园一键领取
    # a.goumaimana(1)  # 购买mana 10次
    a.mianfeiniudan()  # 免费扭蛋
    # a.mianfeishilian()  # 免费十连
    a.dianzan(sortflag=1)  # 公会点赞
    # a.hanghui()  # 行会捐赠
    a.dixiacheng()  # 地下城 如果是首次使用需要跳过剧情,可以在括号中填入参数1
    # a.goumaitili(3)  # 购买3次体力
    a.shouqurenwu()  # 收取任务
    ok = shuatu_auth(a, account, fun)  # 刷图控制中心
    if ok:  # 仅当刷图被激活(即注明了刷图图号)的账号执行行会捐赠,不刷图的认为是mana号不执行行会捐赠。
        a.hanghui()  # 行会捐赠
    else:  # 刷图没有被激活的可以去刷经验
        # a.goumaitili(times=3)  # 购买times次体力
        # a.shuajingyan(map=3)  # 刷1-1经验,map为主图
        pass
    # a.shuajingyan(11) # 刷1-1经验(自带体力购买),11为当前所在主线图
    a.shouqu()  # 收取所有礼物

    if kickflag == 1:
        a.tichuhanghui()
    a.change_acc()  # 退出当前账号,切换下一个
示例#11
0
def runmain(address, account, password):
    # 主功能体函数
    # 请在本函数中自定义需要的功能

    a = Automator(address)
    a.start()

    # #opencv识别可视化 无法在多线程中使用
    # plt.ion()
    # fig, ax = plt.subplots(1)
    # plt.show()

    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao2.txt内
    #a.init_home()  # 初始化,确保进入首页

    a.init_home_with_running()
    #a.shouqu()
    #a.shouqurenwu()
    #a.goumaitili(times=2)  # 购买times次体力
    #a.shuajingyan(map=3)  # 刷1-1经验,map为主图
    #a.hanghui()  # 行会捐赠
    a.dixiacheng()

    a.change_acc()  # 退出当前账号,切换下一个
示例#12
0
def runmain(address, account, password):
    # 主功能体函数
    # 请在本函数中自定义需要的功能

    a = Automator(address)
    log = log_handler.LOG()#初始化日志
    a.start()
    print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<', '\r\n')
    a.login_auth(account, password)  # 注意!请把账号密码写在zhanghao.txt内
    log.Account_Login(account)
    a.init_home()  # 初始化,确保进入首页
    a.sw_init()  # 初始化刷图

    a.gonghuizhijia()  # 家园一键领取
    #a.goumaimana(1)  # 购买mana 10次
    a.mianfeiniudan()  # 免费扭蛋
    a.mianfeishilian()  # 免费十连
    a.shouqu()  # 收取所有礼物
    a.dianzan()  # 公会点赞,sortflag=1表示按战力排序
    a.dixiacheng()  # 地下城
    a.goumaitili(3)  # 购买3次体力
    a.shouqurenwu()  # 收取任务
    ok = shuatu_auth(a, account)  # 刷图控制中心
    if ok:  # 仅当刷图被激活(即注明了刷图图号)的账号执行行会捐赠,不刷图的认为是mana号不执行行会捐赠。
        a.hanghui()  # 行会捐赠
    else:  # 刷图没有被激活的可以去刷经验
        # a.goumaitili(times=3)  # 购买times次体力
        # a.shuajingyan(map=3)  # 刷1-1经验,map为主图
        pass
    a.shouqurenwu()  # 二次收取任务

    a.change_acc()  # 退出当前账号,切换下一个
    log.Account_Logout(account)