예제 #1
0
def login():
    count = 0
    while True:
        s = match_until(['update', 'main', 'cross', 'notification', 'maintenance'])
        if s is not None:
            count = 0
        if s == 'update':
            loger.log("Need update..")
            tap(840, 557)
        elif s == 'cross':
            for i in range(10):
                tap(1242, 29, w=0)
        elif s == 'notification':
            tap(1181, 405)
        elif s == 'main':
            loger.log("Login successful")
            return 0
        elif s == 'maintenance':
            loger.log("Server under maintenance")
            return -1
        else:
            count += 1
            time.sleep(3)
            if count > 30:
                loger.log("Login failed")
                return -1
            
    return -1
예제 #2
0
def run_fgo():
    """fgo part"""
    loger.log("starting fgo...")
    utility.GAME = 'fgo'
    utility.start_game(
        'com.bilibili.fatego/jp.delightworks.Fgo.player.AndroidPlugin')
    while True:
        ret = login.login()
        if ret != 0:
            break
        ret = daliy.daliy_free_draw()
        if ret != 0:
            break
        break
    utility.stop_game('com.bilibili.fatego')
    loger.log("ending fgo...\n")
예제 #3
0
def fight_event(fight_time=15, use_stone=0):
    while True:
        flag = False
        fight_count = 0
        s, p = match_until([
            "next_fight", 'start_fight', 'start_fight_2', 'next', 'shop',
            'next_1', 'close', 'ap_out'
        ],
                           require_coor=True,
                           cof=0.85)
        if s == 'next_fight':
            tap(p[0], p[1] + 50)
            flag = True
        elif s == 'start_fight' or s == 'start_fight_2':
            tap(1114, 607, w=1)
            if flag:
                fight_count += 1
                flag = False
        elif s == 'next':
            tap(1107, 671, w=4)
        elif s == 'shop':
            tap(498, 492, w=1)
        elif s == 'next_1':
            tap(1107, 671, w=4)
        elif s == 'close':
            tap(p[0], p[1])
        elif s == 'ap_out':
            if use_stone > 0:
                tap(786, 494, w=1)
                tap(786, 494, w=1)
                use_stone -= 1
            else:
                log("体力完了")
                return 0

        if fight_count > fight_time:
            return 0
예제 #4
0
def connect_adb(emulator, port):
    # open emulator if not
    emulator_name = emulator.split('/')[-1].split('.')[-2]
    emulator_path = emulator[0:emulator.find(emulator_name)]
    process = [p.name() for p in psutil.process_iter()]
    if emulator_name + '.exe' in process:
        loger.log("emulator already opened")
    else:
        loger.log("try open emulator")
        cwd = os.getcwd()
        print(emulator, emulator_path, emulator_name)
        os.chdir(emulator_path)
        subprocess.run(['start', './{}.exe'.format(emulator_name)],
                       shell=True,
                       check=True)
        os.chdir(cwd)
        wait(60)

    # connect to adb
    subprocess.run('adb kill-server', check=True)
    subprocess.run('adb devices', check=True)
    if int(port) >= 5555 and int(port) <= 5585:
        return
    subprocess.run('adb connect 127.0.0.1:{}'.format(port), check=True)
예제 #5
0
def run_pcr_fight_dungeon(fight_time=10, use_stone=0):
    utility.GAME = 'pcr'
    loger.log("start fight")
    while True:
        #ret = fgo.daliy.daliy_free_draw()
        ret = fight.fight_dungeon(fight_time=fight_time, use_stone=use_stone)
        if ret != 0:
            loger.log("pcr Fight Failed...")
            break
        break
    loger.log("end fight")
예제 #6
0
def run_ark_light():
    """
    arkninghts, 只是自动刷单个图
    """
    utility.GAME = 'ark'
    loger.log("start fight")
    while True:
        ret = fight.fight(use_san=0)  # 设置使用理智液和石头的个数
        if ret != 0:
            loger.log("Arknights Fight Failed...")
            break
        break
    loger.log("end fight")
예제 #7
0
def run_fgo_fight(fight_time=100, use_white=0, use_gold=0, use_stone=0):
    utility.GAME = 'fgo'
    loger.log("start fight")
    while True:
        #ret = fgo.daliy.daliy_free_draw()
        ret = fight.fight(fight_time=fight_time,
                          use_white=use_white,
                          use_gold=use_gold,
                          use_stone=use_stone)
        if ret != 0:
            loger.log("FGO Fight Failed...")
            break
        break
    loger.log("end fight")
예제 #8
0
def run_ark(user='******', passwd='test', close=True):
    """
    arknights part
    """
    loger.log("starting arknights...")
    utility.GAME = 'ark'
    utility.start_game('com.hypergryph.arknights/com.u8.sdk.U8UnityContext')
    while True:
        ret = login.login(user, passwd)  # input your password here
        if ret != 0:
            loger.log("Arknights Login Failed, quiting...")
            break
        break
    if close:
        utility.stop_game('com.hypergryph.arknights')
        loger.log("ending arknights...\n")
예제 #9
0
def daliy_free_draw():
    is_drawed = False
    match_list = ['main', 'ten_draw', 'free_draw', 'free_draw_2', 'small_close', 'end_draw', 'free_draw_3', 'cross']
    count = 0
    while True:
        s, p = match_until(match_list, require_coor = True)
        if s is not None:
            count = 0
        if s == 'small_close' or s == 'draw_close' or s == 'cross':
            tap(p[0], p[1], w = 0)
        if s == 'main':
            if is_drawed:
                return 0
            tap(1184, 684, w = 0)
            tap(534, 642, w = 0)
        if s == 'ten_draw':
            tap(45, 355, w = 0)
        if s == 'free_draw':
            tap(638, 551)
        if s == 'free_draw_2':
            tap(836, 562, w = 0)
        if s == 'end_draw':
            loger.log("Daily free draw successed")
            is_drawed = True
            tap(100, 39, w = 0)
        if s == 'free_draw_3':
            is_drawed = True
            loger.log("Daily free draw finished")
            tap(100, 39, w = 0)
        else:
            count += 1
            if count > 30:
                loger.log("match_until time out")
                return -1
    return -1
            


        
        
예제 #10
0
def login(user="", passwd=""):
    count = 0
    while True:
        s = match_until([ 'login', 'cross', 'main', 'login_1'])
        if s == "loading":
            continue
        elif s == 'login_1':
            tap(644, 502, w=2)
            tap(645, 595, w=2)
        elif s == 'login':
            tap(421, 507)
            while True:
                x = match_until(['login_2', 'login_error'])
                if x == 'login_2':
                    tap(638, 425, w=0.5) # 用户名输入框
                    text(user, w=0.5)    # 输入用户名
                    tap(348, 409, w=0.5) # 确认输入
                    tap(640, 476, w=0.5) # 密码输入框
                    text(passwd, w=0.5)  # 输入密码
                    tap(345, 434, w=0)    # 确认输入
                    tap(640, 574)             # 点击登录
                elif x == 'login_error':
                    log("Username or password error...")
                    return -1
                else:
                    break
        elif s == 'cross':
            x, p = match_until(['cross'], require_coor=True)
            if x == 'cross':
                tap(p[0], p[1], r=5)
        elif s == 'main':
            log("Login successful")
            return 0
        else:
            count += 1
            if count >= 30:
                log("login in time out")
                return -1
    return -1
예제 #11
0
def fight(fight_time=100, use_white=0, use_gold=0, use_stone=0):
    fight_count = 0
    while True:
        if fight_count > fight_time:
            return 0
        s = match_until(['fight_1', 'assis_choice', 'start_fight', 'attack', 'attack_2', 'next', 'ap_out', 'story', 'data_update', 'data_update_2', 'inventory_full', 'mission_failed'])
        print(s)
        if s == 'story':
            tap(1192, 36, w=1)
            tap(826, 556)
        if s == 'data_update' or s == 'data_update_2':
            tap(437, 559)
        if s == 'fight_1':
            fight_count += 1
            log("Fight %d" % fight_count)
            tap(943, 217, w=1)
        if s == 'assis_choice':
            tap(667, 287, w=2)
        if s == 'start_fight':
            tap(1189, 670, w=0)
        if s == 'attack':
            tap(1136, 591, w=1)
        if s == 'attack_2':
            random.shuffle(POINTS_BIG)
            for ps in POINTS_BIG:
                tap(ps[0], ps[1])
            random.shuffle(POINTS_NORMAL)
            for i in range(3):
                tap(POINTS_NORMAL[i][0], POINTS_NORMAL[i][1])
        if s == 'next':
            tap(1112, 675)
        if s == 'ap_out':
            Flag = True
            if use_white > 0:
                tap(688, 475, w=0)
                x, xp = match_until(['ap_out_1'], require_coor=True, retry_count=2)
                if x == 'ap_out_1':
                    use_white -= 1
                    Flag = False
                    tap(xp[0], xp[1], w=1)
                    log("use one white apple")
                else:
                    log("white apple runs out")
                    use_white = 0
            if Flag and use_gold > 0:
                tap(688, 315, w=0)
                x, xp = match_until(['ap_out_1'], require_coor=True, retry_count=2)
                if x == 'ap_out_1':
                    use_white -= 1
                    Flag = False
                    tap(xp[0], xp[1], w=1)
                    log("use one gold apple")
                else:
                    log("gold apple runs out")
                    use_gold = 0
            if Flag and use_stone > 0:
                tap(688, 175, w=0)
                x, xp = match_until(['ap_out_1'], require_coor=True, retry_count=2)
                if x == 'ap_out_1':
                    use_white -= 1
                    Flag = False
                    tap(xp[0], xp[1], w=1)
                    log("use one stone")
                else:
                    log("stone runs out")
                    use_stone = 0
            if Flag:
                log("ap runs out, quit...")
                return 0
        if s == 'inventory_full' or s == 'mission_failed':
            if s == 'inventory_full':
                loger.log("inventory_full, quit...")
            elif s == 'mission_failed':
                loger.log("mission_failed, quit...")
            return 0






        
    return -1
예제 #12
0
import sys
import json

import utility.utility as utility
import utility.loger as loger
import fgo.control
import ark.control
import pcr.control

if __name__ == "__main__":
    config_file = open('./config.json')
    config = json.load(config_file)
    utility.connect_adb(config['emulator'], config['adb_port'])

    if len(sys.argv) < 2:
        loger.log('parameter error')
    elif sys.argv[1] == '-fgo':
        fgo.control.run_fgo()
    elif sys.argv[1] == '-fgofight':
        fgo.control.run_fgo_fight()
    elif sys.argv[1] == '-ark':
        ark.control.run_ark(user=config['arknight_username'],
                            passwd=config['arknight_password'])
    elif sys.argv[1] == '-arkfight':
        ark.control.run_ark_light()
    elif sys.argv[1] == '-pcrfightevent':
        pcr.control.run_pcr_fight_even()
    elif sys.argv[1] == '-pcrfightdungeon':
        pcr.control.run_pcr_fight_dungeon()
    else:
        loger.log("system parameter error")