diff --git a/docs/development.md b/docs/development.md index 469fdda..0b553a3 100644 --- a/docs/development.md +++ b/docs/development.md @@ -5,7 +5,7 @@ ArkLights(速通)是一个开源的,几乎没有任何限制的开源项 ## 须知 - 请尊重项目代码风格,即使你并不喜欢他,大面积的reformat对代码审阅是一种灾难! -- 请尽量避免改动已经存在的代码,除非这个是一个经过测试且确信的该进,请在commit中进行标注。 +- 请尽量避免改动已经存在的代码,除非这个是一个经过测试且确信的改进,请在commit中进行标注。 - 请不要重载已经存在的函数,本项目的底层含有大量耦合的代码,请不要重载他们。 - 任何pr前请先确保本地测试通过。 diff --git a/main.lua b/main.lua index 0003551..5a98260 100644 --- a/main.lua +++ b/main.lua @@ -1,111 +1,150 @@ --- predebug = true --- always_enable_log = true --- test_fight = true --- fake_fight = true --- prefer_bapp = true --- zl_disable_log = true --- enable_drug_24hour = true --- prefer_speed = true --- disable_dorm_shift=true --- disable_manu_shift=true --- disable_overview_shift=true --- disable_hotupdate = true --- disable_root_mode = true --- no_background_after_run = true --- fake_recruit = true --- debug_tag = true --- during_crisis_contract =true --- disable_communication_check=true --- speedrun=true --- debug = true --- disable_log = true --- unsafe_tap = true --- zl_disable_fight_drop = true -zl_enable_tap_before_drag = true -zero_wait_click = true -check_after_tap = true -crontab_enable = true --- enable_simultaneous_tap = true --- auto_clean_fight=true --- enable_dorm_check = true --- fake_transfer= true --- verbose_fca = true --- no_dorm = true --- test_some = true --- ok_time = 1000 --- ignore_jmfight_enough_check=true --- use_zhuzhu_game = true --- no_config_cache = true --- prefer_bapp_on_android7 = true --- debug0721 = true --- longest_tag = true --- very_slow_state_check = true -default_findcolor_confidence = 95 / 100 -default_auto_timeout_second = 300 --- default_max_drug_times = 9999 --- default_max_stone_times = 0 --- disable_game_up_check = true --- skip_snapshot_service_check = true --- need_show_console = true --- 设成10以下时,单核机作战导航失败率高,真机基建缩放也会有问题 --- 设成1000//30时,真机同时开着B服与官服时会出现点着点着脚本就停(从基建开始做邮件) -frame_milesecond = 1000 // 30 -milesecond_after_click = frame_milesecond -release_date = "08.01 20:32" -ui_submit_color = "#ff0d47a1" -ui_cancel_color = "#ff1976d2" -ui_warn_color = "#ff33ccff" -ui_page_width = -2 -ui_submit_width = -2 -ui_small_submit_width = -2 -ui_small_submit_height = -2 -network_timeout = 300 -matrixOcr = ocr - --- update_source = 'https://arklights.pages.dev' -update_source = 'https://gitee.com/bilabila/arknights/raw/master' -update_source_fallback = update_source - -require('util') -require("point") -require("path") -require("tag") -require('skill') -require("fight") -require("cloud") -require("ex") - + --predebug = true + --always_enable_log = true + -- test_fight = true + -- fake_fight = true + -- prefer_bapp = true + -- zl_disable_log = true + -- enable_drug_24hour = true + -- prefer_speed = true + -- disable_dorm_shift=true + -- disable_manu_shift=true + -- disable_overview_shift=true + -- disable_hotupdate = true + -- disable_root_mode = true + -- no_background_after_run = true + -- fake_recruit = true + -- debug_tag = true + -- during_crisis_contract =true + -- disable_communication_check=true + -- speedrun=true + -- debug = true + -- disable_log = true + -- unsafe_tap = true + -- zl_disable_fight_drop = true + zl_enable_tap_before_drag = true + zero_wait_click = true + check_after_tap = true + crontab_enable = true + -- enable_simultaneous_tap = true + -- auto_clean_fight=true + -- enable_dorm_check = true + -- fake_transfer= true + -- verbose_fca = true + -- no_dorm = true + -- test_some = true + -- ok_time = 1000 + -- ignore_jmfight_enough_check=true + -- use_zhuzhu_game = true + -- no_config_cache = true + -- prefer_bapp_on_android7 = true + -- debug0721 = true + -- longest_tag = true + -- very_slow_state_check = true + default_findcolor_confidence = 95 / 100 + default_auto_timeout_second = 300 + -- default_max_drug_times = 9999 + -- default_max_stone_times = 0 + -- disable_game_up_check = true + -- skip_snapshot_service_check = true + -- need_show_console = true + -- 设成10以下时,单核机作战导航失败率高,真机基建缩放也会有问题 + -- 设成1000//30时,真机同时开着B服与官服时会出现点着点着脚本就停(从基建开始做邮件) + frame_milesecond = 1000 // 30 + milesecond_after_click = frame_milesecond + release_date = "08.01 20:32" + ui_submit_color = "#ff0d47a1" + ui_cancel_color = "#ff1976d2" + ui_warn_color = "#ff33ccff" + ui_page_width = -2 + ui_submit_width = -2 + ui_small_submit_width = -2 + ui_small_submit_height = -2 + network_timeout = 300 + matrixOcr = ocr + + -- update_source = 'https://arklights.pages.dev' + update_source = 'https://gitee.com/bilabila/arknights/raw/master' + update_source_fallback = update_source + + require('util') + require("point") + require("path") + require("tag") + require('skill') + require("fight") + require("cloud") + require("ex") + load(after_require_hook or '')() -consoleInit() -showControlBar(true) -setEventCallback() +consoleInit()--调用控制台 +showControlBar(true)--显示悬浮窗 +setEventCallback()--设置脚本关闭和悬浮窗触控事件 hotUpdate() fetchSkillIcon() check_root_mode() -enable_accessibility_service() -enable_snapshot_service() +enable_accessibility_service()--无障碍权限 +enable_snapshot_service()--开启无障碍截图 remove_old_log() -detectServer() +detectServer()--查找游戏服务器对应的app predebug_hook() showUI() -loadUIConfig() +loadUIConfig()--读取ui配置 restart_mode_hook() update_state_from_debugui() check_crontab_on_start() -cloud.startHeartBeat() +cloud.startHeartBeat()--云控 + + --- debug_mode=true +log("抄作业:",copy_homework) +if copy_homework then + ip = pc_ipv4--本机ip + local adbPath = adb_adress--adb位置 + local host = simulator_host--模拟器地址 + local headers ="Content-Type: application/json"--post请求头 + simulator_id=""--maa返回的模拟器编号 + --get maa版本号 + local ret,time = httpGet("http://" .. ip .. ":8848/API/V1/getVersion") + log(ret) + if not ret then + log("未获取到maa版本号") + exit() + end + ssleep (1) + local t= { + adbPath=adbPath, + host=host, + detailJson="", + } + ssleep (3) + --请求maa连接模拟器并返回id,这之后ide会和模拟器断开,但是模拟器里面的脚本在继续,后面请用log,不要用print调试 + --asynHttpGet(callback,"http://" .. ip .. ":8848/API/V1/connect?adbPath="..adbPath .."&host="..host) + + local res ,code = httpPost("http://" .. ip .. ":8848/API/V1/connect",JsonEncode(t),30,headers) + --延时到端口返回json + --[===[while not resp ==true do + ssleep (1) + log (resp) + end + ssleep (10) + log (resp)]===] + + if res then simulator_id= JsonDecode(res)["data"]["id"] end + log("模拟器id",simulator_id) + if not simulator_id or #simulator_id ==0 then exit() end + end + +--debug_mode=true if debug_mode then log("debug_mode") - -- log(findOne("活动公告返回")) - -- log(findOne("framelayout_only")) - -- log(findOne("login")) - -- ssleep(1) - -- tap("login") - -- exit() + + + end + + load(before_account_hook or '')() no_extra_job = {} diff --git a/path.lua b/path.lua index a334ac8..3cdb753 100644 --- a/path.lua +++ b/path.lua @@ -132,13 +132,13 @@ path.base = { fight_start_time = fight_start_time or time() local elapsed = time() - fight_start_time local fight_type = get_fight_type(cur_fight) - + log("接管作战") -- 一般10分钟,剿灭40分钟 local fight_timeout = (table.includes({"剿灭"}, fight_type) and elapsed > 40 * 60 * 1000) or (not table.includes({"剿灭"}, fight_type) and elapsed > 10 * 60 * 1000) - + log(fight_timeout) -- 超时跳过当前关 if fight_timeout then local info = table.join(qqmessage, ' ') .. " [" .. cur_fight .. @@ -154,6 +154,7 @@ path.base = { if not wait(function() if not findOne("接管作战") then return true end -- log(126) + --if findOne("跳过剧情") then path.跳过剧情() end if findOne("暂停中") and not disappear("暂停中", 5) then tap("开包skip") disappear("暂停中") @@ -183,7 +184,7 @@ path.base = { -- 实测560秒,给两倍 if time() - first_time_see_zero_star > 1200 then zero_star = true end end - + if findOne("开始行动") and findOne("代理指挥开") then log(59) normal = true @@ -3120,11 +3121,13 @@ extrajianpin2name = { 当前委托 = "当期委托", } + + path.开始游戏 = function(x, disable_ptrs_check) -- 记录石头数量 save_run_state() - + local need_copy_homework =nil log("开始游戏", fight_tick, x) if not findOne("开始行动") then return end if x == "1-11" then return path["1-11"] end @@ -3137,14 +3140,20 @@ path.开始游戏 = function(x, disable_ptrs_check) -- log(findOne("报酬合成玉已满")) -- log(findOne("开始行动")) -- safeexit() - + print(copy_homework) + if not appear("代理指挥开", .5) then tap("代理指挥开1") if not appear("代理指挥开", .5) then - -- clean_fight(x) - fight_failed_times[cur_fight] = max_fight_failed_times - if not appear("主页") then back() end - return path.跳转("首页") + if copy_homework then + need_copy_homework = true + ssleep (6)--等待右上角提示消失 + else + -- clean_fight(x) + fight_failed_times[cur_fight] = max_fight_failed_times + if not appear("主页") then back() end + return path.跳转("首页") + end end -- if not wait(function() -- if findOne("代理指挥开") and not disappear("代理指挥开", .5) then @@ -3172,7 +3181,7 @@ path.开始游戏 = function(x, disable_ptrs_check) state = findAny({ "开始行动红", "源石恢复理智取消", "药剂恢复理智取消", "单选确认框", "源石恢复理智不足", "当期委托侧边栏", - "行动结束", + "行动结束" }) -- 剿灭后一直按开始行动导致开始行动界面消失,可能出现下面的界面 if state == "当前委托侧边栏" then @@ -3206,6 +3215,10 @@ path.开始游戏 = function(x, disable_ptrs_check) return path.base.接管作战() elseif state == "开始行动红" then no_success_one_loop = 0 + if need_copy_homework then + maa_copliot(x) + else + if fake_fight then log("debug0415", x) if not wait(function() @@ -3235,6 +3248,7 @@ path.开始游戏 = function(x, disable_ptrs_check) -- return -- end if findOne("单选确认框") then return end + end return path.base.接管作战() elseif stone_times < max_stone_times and state == "源石恢复理智取消" or drug_times < max_drug_times and state == "药剂恢复理智取消" then diff --git a/util.lua b/util.lua index 3b1d6e1..3d7c321 100644 --- a/util.lua +++ b/util.lua @@ -3111,7 +3111,32 @@ show_debug_ui = function() newRow(layout) addTextView(layout, "多账号仅传递线索账号(线索小号)") ui.addEditText(layout, "multi_account_disable_clue_unlock", '') - + + --抄作业相关 + newRow(layout) + ui.addCheckBox(layout, "copy_homework", + "使用MAA抄作业", false) + + newRow(layout) + addTextView(layout, "adb路径(从maa拷贝)") + ui.addEditText(layout, "adb_adress", "") + + newRow(layout) + addTextView(layout, "模拟器地址(从maa拷贝)") + ui.addEditText(layout, "simulator_host", "") + + newRow(layout) + addTextView(layout, "电脑ipv4地址") + ui.addEditText(layout, "pc_ipv4", "") + + newRow(layout) + addTextView(layout, "作业存放的文件夹(电脑地址)") + ui.addEditText(layout, "homework_folder", "") + + + + + -- newRow(layout) -- ui.addCheckBox(layout, "enable_keepalive", -- "保活模式(需关root通知与“X正在运行”通知)", @@ -3853,23 +3878,38 @@ test_fight_hook = function() exit() end +maa_copliot =function (x) + log ("开始抄作业",x) + local headers ="Content-Type: application/json"--post请求头 + --[===[local resp ]===] + log (homework_folder.."\\" .. x..".json") + --通过接口调用抄作业 + local t2={id=simulator_id,type="Copilot",params={enable=true,filename= homework_folder.."\\" .. x..".json" ,formation=true}} + log (JsonEncode(t2)) + log ("post作业,唤起抄作业流程") + function callback(response,code) + print(response) + resp=response + end + --[===[asynHttpPost(callback,"http://" .. pc_ipv4 .. ":8848/API/V1/appendTaskAndStart",JsonEncode(t2),30,headers) + while not resp ==true do + ssleep (1) + end]===] + local res ,code = httpPost("http://" .. ip .. ":8848/API/V1/appendTaskAndStart",JsonEncode(t2),100,headers) + log ("post结束") + log ("延时100s防止乱点") + ssleep(100)--延时100s防止乱点 +end + predebug_hook = function() if not predebug then return end tap_interval = -1 findOne_interval = -1 zl_skill_times = 100 - - disable_game_up_check = true - swip("HD-2") - -- tap("作战列表HD-8") - - log(findOne("就这么决定了")) - -- local p = findOne("同意协议") - -- if p ~= nil then - -- local left, top = p.bounds.l, p.bounds.t - -- tap({left - scale(10), top + scale(10)}) - -- end - findTap({text="下一步"}) + copy_homework = true + + --立即结束脚本会跳出来日志窗口影响maa编队,这里计划加个检测 剧情/行动结束/失败 的循环截图判断 + path.开始游戏("HD-6") exit() end