mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-20 04:10:00 +08:00
改进周本一条龙合养成一条龙的体力识别函数、改进七圣召唤七日历练的对局结果检测函数 (#1736)
* Update main.js * Update manifest.json * Update utils.js * Update manifest.json * Update manifest.json * Update main.js
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "周本一条龙",
|
||||
"version": "3.1",
|
||||
"version": "3.1.1",
|
||||
"description": "https://www.bilibili.com/video/BV1F2uvz3E4K/?vd_source=9dfaf88af48ecc0ff95a41f1145af7a2",
|
||||
"authors": [
|
||||
{
|
||||
|
||||
@@ -331,7 +331,6 @@ async function autoFightAsync() {
|
||||
}
|
||||
}
|
||||
|
||||
//返回当前体力值
|
||||
async function queryStaminaValue() {
|
||||
try {
|
||||
await genshin.returnMainUi();
|
||||
@@ -341,26 +340,20 @@ async function queryStaminaValue() {
|
||||
click(300, 540);
|
||||
await sleep(1000);
|
||||
click(1570, 203);
|
||||
await sleep(1000);
|
||||
await sleep(1500);
|
||||
let captureRegion = captureGameRegion();
|
||||
let stamina = captureRegion.find(RecognitionObject.ocr(1580, 20, 210, 55));
|
||||
|
||||
// 改进的分割方法
|
||||
log.info(`OCR原始文本:${stamina.text}`);
|
||||
const staminaText = stamina.text.replace(/\s/g, ''); // 移除所有空格
|
||||
// 使用正则表达式匹配数字部分(包括/或可能被误识别为其他字符的情况)
|
||||
const matches = staminaText.match(/(\d+)[^\d]+(\d+)/);
|
||||
|
||||
if (!matches || matches.length < 3) {
|
||||
throw new Error("无法解析体力值格式");
|
||||
}
|
||||
const currentValue = matches[1]; // 第一个数字是当前体力值
|
||||
let validatedStamina = positiveIntegerJudgment(currentValue);
|
||||
log.info(`剩余体力为:${validatedStamina}`);
|
||||
await genshin.returnMainUi();
|
||||
return validatedStamina;
|
||||
|
||||
const standardMatch = staminaText.match(/(\d+)/);
|
||||
if (standardMatch) {
|
||||
const currentValue = standardMatch[1];
|
||||
let validatedStamina = positiveIntegerJudgment(currentValue);
|
||||
if (validatedStamina > 11200) validatedStamina = (validatedStamina-1200)/10000;
|
||||
return validatedStamina;
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`体力识别失败,默认为零`);
|
||||
log.error(`体力识别失败:${error.message},默认为零`);
|
||||
await genshin.returnMainUi();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -203,31 +203,46 @@ async function isTaskRefreshed(filePath, options = {}) {
|
||||
|
||||
//检查挑战结果 await checkChallengeResults();
|
||||
async function checkChallengeResults() {
|
||||
const region1 = RecognitionObject.ocr(785, 890, 340, 82); // 对话区域
|
||||
const region1 = RecognitionObject.ocr(785, 200, 380, 270); // 结果区域
|
||||
let capture = captureGameRegion();
|
||||
let res1 = capture.find(region1);
|
||||
if (res1.isEmpty()) {
|
||||
log.info(`结果识别:${res1.text}`);
|
||||
if (res1.text.includes("对局失败")) {
|
||||
log.info("对局失败");
|
||||
await sleep(1000);
|
||||
click(960, 540);
|
||||
await sleep(500);
|
||||
click(1860, 50); //避免失败卡死
|
||||
await sleep(1000);
|
||||
click(1600, 260);
|
||||
await sleep(1000);
|
||||
click(1180, 756);
|
||||
await sleep(6000);
|
||||
click(754, 915); //退出挑战
|
||||
await sleep(4000);
|
||||
await autoConversation();
|
||||
await sleep(1000);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else if (res1.text.includes("对局胜利")) {
|
||||
log.info("对局胜利");
|
||||
await sleep(1000);
|
||||
click(754, 915); //退出挑战
|
||||
await sleep(4000);
|
||||
await autoConversation();
|
||||
await sleep(1000);
|
||||
return;
|
||||
|
||||
} else {
|
||||
log.info("挑战异常中断,对局失败");
|
||||
await sleep(1000);
|
||||
click(960, 540);
|
||||
await sleep(500);
|
||||
click(960, 540);
|
||||
await sleep(500);
|
||||
click(1860,50); //点击齿轮图标
|
||||
await sleep(1000);
|
||||
click(1600, 200);//点击退出选项
|
||||
await sleep(1000);
|
||||
click(1180, 756);//点击确认
|
||||
await sleep(6000);
|
||||
click(754, 915); //退出挑战
|
||||
await sleep(4000);
|
||||
await autoConversation();
|
||||
await sleep(1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,3 +715,4 @@ await main();
|
||||
|
||||
|
||||
})();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "打牌一条龙",
|
||||
"version": "2.0",
|
||||
"version": "2.1",
|
||||
"description": "详见README.md",
|
||||
"tags": [
|
||||
"七圣召唤"
|
||||
@@ -14,4 +14,4 @@
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
"main": "main.js"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +245,6 @@ function positiveIntegerJudgment(testNumber) {
|
||||
return testNumber;
|
||||
}
|
||||
|
||||
//返回当前体力值await queryStaminaValue();
|
||||
async function queryStaminaValue() {
|
||||
try {
|
||||
await genshin.returnMainUi();
|
||||
@@ -255,26 +254,20 @@ async function queryStaminaValue() {
|
||||
click(300, 540);
|
||||
await sleep(1000);
|
||||
click(1570, 203);
|
||||
await sleep(1000);
|
||||
await sleep(1500);
|
||||
let captureRegion = captureGameRegion();
|
||||
let stamina = captureRegion.find(RecognitionObject.ocr(1580, 20, 210, 55));
|
||||
|
||||
// 改进的分割方法
|
||||
log.info(`OCR原始文本:${stamina.text}`);
|
||||
const staminaText = stamina.text.replace(/\s/g, ''); // 移除所有空格
|
||||
// 使用正则表达式匹配数字部分(包括/或可能被误识别为其他字符的情况)
|
||||
const matches = staminaText.match(/(\d+)[^\d]+(\d+)/);
|
||||
|
||||
if (!matches || matches.length < 3) {
|
||||
throw new Error("无法解析体力值格式");
|
||||
}
|
||||
const currentValue = matches[1]; // 第一个数字是当前体力值
|
||||
let validatedStamina = positiveIntegerJudgment(currentValue);
|
||||
log.info(`剩余体力为:${validatedStamina}`);
|
||||
await genshin.returnMainUi();
|
||||
return validatedStamina;
|
||||
|
||||
const standardMatch = staminaText.match(/(\d+)/);
|
||||
if (standardMatch) {
|
||||
const currentValue = standardMatch[1];
|
||||
let validatedStamina = positiveIntegerJudgment(currentValue);
|
||||
if (validatedStamina > 11200) validatedStamina = (validatedStamina-1200)/10000;
|
||||
return validatedStamina;
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`体力识别失败,默认为零`);
|
||||
log.error(`体力识别失败:${error.message},默认为零`);
|
||||
await genshin.returnMainUi();
|
||||
return 0;
|
||||
}
|
||||
@@ -948,3 +941,4 @@ else log.info(`没有选择挑战首领,跳过执行`);
|
||||
|
||||
|
||||
})();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "角色养成一条龙",
|
||||
"version": "1.2",
|
||||
"version": "1.2.1",
|
||||
"description": "详见readme.md",
|
||||
"authors": [
|
||||
{
|
||||
@@ -11,4 +11,4 @@
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
"main": "main.js"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user