diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/全部奇域.png b/repo/js/1000StarsLoop/assets/RecognitionObject/全部奇域.png new file mode 100644 index 000000000..af9087ae1 Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/全部奇域.png differ diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/前往大厅.png b/repo/js/1000StarsLoop/assets/RecognitionObject/前往大厅.png new file mode 100644 index 000000000..749b4ad26 Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/前往大厅.png differ diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/开始游戏.png b/repo/js/1000StarsLoop/assets/RecognitionObject/开始游戏.png new file mode 100644 index 000000000..e5f49e31d Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/开始游戏.png differ diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/搜索.png b/repo/js/1000StarsLoop/assets/RecognitionObject/搜索.png new file mode 100644 index 000000000..d5eba87b2 Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/搜索.png differ diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/搜索奇域.png b/repo/js/1000StarsLoop/assets/RecognitionObject/搜索奇域.png new file mode 100644 index 000000000..2c1c2faf9 Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/搜索奇域.png differ diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/确认返回.png b/repo/js/1000StarsLoop/assets/RecognitionObject/确认返回.png new file mode 100644 index 000000000..83dd32b7b Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/确认返回.png differ diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/返回大厅.png b/repo/js/1000StarsLoop/assets/RecognitionObject/返回大厅.png new file mode 100644 index 000000000..debef5c18 Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/返回大厅.png differ diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/返回提瓦特.png b/repo/js/1000StarsLoop/assets/RecognitionObject/返回提瓦特.png new file mode 100644 index 000000000..0064ad208 Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/返回提瓦特.png differ diff --git a/repo/js/1000StarsLoop/assets/RecognitionObject/进入.png b/repo/js/1000StarsLoop/assets/RecognitionObject/进入.png new file mode 100644 index 000000000..676bb8683 Binary files /dev/null and b/repo/js/1000StarsLoop/assets/RecognitionObject/进入.png differ diff --git a/repo/js/1000StarsLoop/main.js b/repo/js/1000StarsLoop/main.js new file mode 100644 index 000000000..9a24b3158 --- /dev/null +++ b/repo/js/1000StarsLoop/main.js @@ -0,0 +1,86 @@ +// 主逻辑 +let content = settings.content || "7108700065"; +let maxAttempts = (+settings.maxAttempts) || 15; +let delay = (+settings.delay) || 250; +let attempts = 0; +let entered = false; +(async function () { + + //循环指定次数 + while (attempts < maxAttempts) { + await genshin.returnMainUi(); + attempts++; + log.info(`开始第${attempts}次循环`); + await sleep(2000); + keyPress("F6"); + await sleep(250); + if (!await ClickPNG("全部奇域")) { + await sleep(250); + await genshin.returnMainUi(); + keyPress("F6"); + if (!await ClickPNG("全部奇域")) { + continue; + } + } + await sleep(250); + if (!await ClickPNG("搜索奇域")) continue; + await sleep(250); + log.info(`搜索${content}`); + await sleep(1000); + inputText(content); + await sleep(500); + if (!await ClickPNG("搜索")) continue; + await sleep(250); + const result = await ClickPNG("进入"); + await sleep(250); + //log.info(`结果是${result}`); + if (!result) { + log.warn("未找到标识,尝试点击固定位置"); + click(400, 300); + } + await sleep(250); + if (!entered) { + entered = await ClickPNG("前往大厅"); + if (!await ClickPNG("开始游戏", 600)) { + continue; + } else { + entered = true; + } + } else { + await sleep(250); + await ClickPNG("开始游戏") + } + await sleep(250); + if (!await ClickPNG("返回大厅", 600)) continue; + await sleep(250); + } + if (settings.returnGenshin) { + log.info("勾选了返回提瓦特,开始返回"); + await genshin.returnMainUi(); + await sleep(1000); + keyPress("F2"); + await ClickPNG("返回提瓦特"); + await ClickPNG("确认返回"); + } +})(); + +async function ClickPNG(png, maxAttempts = 40) { + log.info(`尝试找到并点击${png},等待至多${maxAttempts * 50}毫秒`); + moveMouseTo(1920, 1080); + const pngRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/${png}.png`)); + pngRo.Threshold = 0.95; + pngRo.InitTemplate(); + return await findAndClick(pngRo, maxAttempts); +} + +async function findAndClick(target, maxAttempts = 5) { + for (let i = 0; i < maxAttempts; i++) { + const rg = captureGameRegion(); + try { + const res = rg.find(target); + if (res.isExist()) { await sleep(delay); res.click(); return true; } + } finally { rg.dispose(); } + if (i < maxAttempts - 1) await sleep(50); + } + return false; +} \ No newline at end of file diff --git a/repo/js/1000StarsLoop/manifest.json b/repo/js/1000StarsLoop/manifest.json new file mode 100644 index 000000000..f9b0c997a --- /dev/null +++ b/repo/js/1000StarsLoop/manifest.json @@ -0,0 +1,14 @@ +{ + "manifest_version": 1, + "name": "千星奇域循环", + "version": "1.0", + "description": "重复进入指定千星奇域关卡并循环一定次数", + "authors": [ + { + "name": "mno" + } + ], + "tags": "千星奇域", + "settings_ui": "settings.json", + "main": "main.js" +} \ No newline at end of file diff --git a/repo/js/1000StarsLoop/settings.json b/repo/js/1000StarsLoop/settings.json new file mode 100644 index 000000000..f4ba44322 --- /dev/null +++ b/repo/js/1000StarsLoop/settings.json @@ -0,0 +1,25 @@ +[ + { + "name": "content", + "type": "input-text", + "label": "输入搜索内容(名称或GUID)" + }, + { + "name": "maxAttempts", + "type": "input-text", + "label": "循环次数", + "default": 15 + }, + { + "name": "returnGenshin", + "type": "checkbox", + "label": "结束后是否返回提瓦特", + "default": true + }, + { + "name": "delay", + "type": "input-text", + "label": "按键延迟(毫秒),观察到卡住时适当调大", + "default": 250 + } +] \ No newline at end of file