js: 七圣召唤七日历练: 支持使用指定的队伍 (#874)
* js: 七圣召唤七日历练: 支持使用指定的队伍 * js: 七圣召唤七日历练: 细微改进脚本格式
This commit is contained in:
@@ -1,8 +1,44 @@
|
|||||||
(async function () {
|
// 切换到指定的队伍
|
||||||
|
async function switchCardTeam(Name) {
|
||||||
|
let captureRegion = captureGameRegion();
|
||||||
|
let teamName = captureRegion.find(RecognitionObject.ocr(1305, 793, 206, 46));
|
||||||
|
log.info("当前队伍名称: {text}", teamName.text);
|
||||||
|
if (teamName.text != Name) {
|
||||||
|
click(1312, 812); //点击队伍名称的糟糕UI
|
||||||
|
await sleep(1000);
|
||||||
|
|
||||||
|
moveMouseTo(100, 200);
|
||||||
|
leftButtonDown();
|
||||||
|
// 不能一次移动太多,否则会丢拖动
|
||||||
|
for (let i = 1; i <= 9; i++) {
|
||||||
|
await sleep(50);
|
||||||
|
moveMouseTo(200 * i, 200);
|
||||||
|
}
|
||||||
|
await sleep(200);
|
||||||
|
leftButtonUp();
|
||||||
|
await sleep(1000);
|
||||||
|
|
||||||
|
captureRegion = captureGameRegion();
|
||||||
|
for (let i = 0; i < 4; i++) {
|
||||||
|
let x = 135 + 463 * i;
|
||||||
|
let res = captureRegion.find(RecognitionObject.ocr(x, 762, 230, 46));
|
||||||
|
if (res.text == Name) {
|
||||||
|
log.info("切换至队伍: {text}", res.text);
|
||||||
|
res.click();
|
||||||
|
await sleep(500);
|
||||||
|
click(1164, 1016); // 选择
|
||||||
|
await sleep(4000); // 等待"出战牌组"的强制延时框消失
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(async function () {
|
||||||
// 存储挑战玩家信息
|
// 存储挑战玩家信息
|
||||||
let textArray = [];
|
let textArray = [];
|
||||||
let skipNum = 0;
|
let skipNum = 0;
|
||||||
|
|
||||||
//检查挑战结果 await checkChallengeResults();
|
//检查挑战结果 await checkChallengeResults();
|
||||||
async function checkChallengeResults() {
|
async function checkChallengeResults() {
|
||||||
const region1 = RecognitionObject.ocr(785, 890, 340, 82); // 对话区域
|
const region1 = RecognitionObject.ocr(785, 890, 340, 82); // 对话区域
|
||||||
@@ -23,8 +59,7 @@ async function checkChallengeResults() {
|
|||||||
await autoConversation();
|
await autoConversation();
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
click(754, 915); //退出挑战
|
click(754, 915); //退出挑战
|
||||||
await sleep(4000);
|
await sleep(4000);
|
||||||
@@ -32,7 +67,6 @@ async function checkChallengeResults() {
|
|||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//自动对话,直到出现选项框 await autoConversation();
|
//自动对话,直到出现选项框 await autoConversation();
|
||||||
@@ -52,14 +86,12 @@ async function autoConversation() {
|
|||||||
await sleep(500);
|
await sleep(500);
|
||||||
keyPress("VK_SPACE");
|
keyPress("VK_SPACE");
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
}
|
} else if (!res1.isEmpty() && !res2.isEmpty()) {
|
||||||
else if(!res1.isEmpty() && !res2.isEmpty()){
|
|
||||||
keyPress("F");
|
keyPress("F");
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
log.info("已选择谈话内容");
|
log.info("已选择谈话内容");
|
||||||
return;
|
return;
|
||||||
}
|
} else if (res1.isEmpty() && !res2.isEmpty()) {
|
||||||
else if(res1.isEmpty() && !res2.isEmpty()){
|
|
||||||
log.info("谈话完成");
|
log.info("谈话完成");
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
return;
|
return;
|
||||||
@@ -67,7 +99,7 @@ async function autoConversation() {
|
|||||||
talkTime++;
|
talkTime++;
|
||||||
await sleep(1500);
|
await sleep(1500);
|
||||||
}
|
}
|
||||||
throw new Error('对话时间超时');
|
throw new Error("对话时间超时");
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测传送结束
|
//检测传送结束
|
||||||
@@ -87,11 +119,9 @@ async function tpEndDetection() {
|
|||||||
tpTime++;
|
tpTime++;
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
}
|
}
|
||||||
throw new Error('传送时间超时');
|
throw new Error("传送时间超时");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 打开地图,查看玩家位置,并前往相应位置
|
// 打开地图,查看玩家位置,并前往相应位置
|
||||||
const cardPlayerRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/cardPlayer.png"));
|
const cardPlayerRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/cardPlayer.png"));
|
||||||
const detectCardPlayer = async () => {
|
const detectCardPlayer = async () => {
|
||||||
@@ -104,10 +134,9 @@ let findNum = 0;
|
|||||||
{ x: 810, y: 600, action: async () => await gotoTable3() }, // 点位3
|
{ x: 810, y: 600, action: async () => await gotoTable3() }, // 点位3
|
||||||
{ x: 610, y: 360, action: async () => await gotoTable4() }, // 点位4
|
{ x: 610, y: 360, action: async () => await gotoTable4() }, // 点位4
|
||||||
{ x: 700, y: 5, action: async () => await gotoTable5() }, // 点位5
|
{ x: 700, y: 5, action: async () => await gotoTable5() }, // 点位5
|
||||||
{ x: 290, y: 530, action: async () => await gotoTable6() } // 点位6
|
{ x: 290, y: 530, action: async () => await gotoTable6() }, // 点位6
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
keyPress("M");
|
keyPress("M");
|
||||||
await sleep(1200);
|
await sleep(1200);
|
||||||
click(48, 441); //放大地图
|
click(48, 441); //放大地图
|
||||||
@@ -119,25 +148,22 @@ await sleep(300);
|
|||||||
|
|
||||||
//地图拖动到指定位置
|
//地图拖动到指定位置
|
||||||
moveMouseTo(200, 200);
|
moveMouseTo(200, 200);
|
||||||
leftButtonDown(); await sleep(500);
|
leftButtonDown();
|
||||||
moveMouseTo(170,288 );await sleep(500);
|
await sleep(500);
|
||||||
moveMouseTo(104,1000 );await sleep(500);
|
moveMouseTo(170, 288);
|
||||||
leftButtonUp();await sleep(500);
|
await sleep(500);
|
||||||
|
moveMouseTo(104, 1000);
|
||||||
|
await sleep(500);
|
||||||
|
leftButtonUp();
|
||||||
|
await sleep(500);
|
||||||
|
|
||||||
// 获取游戏区域截图
|
// 获取游戏区域截图
|
||||||
const captureRegion = captureGameRegion();
|
const captureRegion = captureGameRegion();
|
||||||
|
|
||||||
|
|
||||||
for (const point of checkPoints) {
|
for (const point of checkPoints) {
|
||||||
i++;
|
i++;
|
||||||
// 遍历所有检测点位
|
// 遍历所有检测点位
|
||||||
const cropRegion = captureRegion.DeriveCrop(
|
const cropRegion = captureRegion.DeriveCrop(point.x, point.y, 160, 160);
|
||||||
point.x ,
|
|
||||||
point.y ,
|
|
||||||
160,
|
|
||||||
160
|
|
||||||
);
|
|
||||||
|
|
||||||
// 在裁剪区域中查找卡片
|
// 在裁剪区域中查找卡片
|
||||||
const result = cropRegion.Find(cardPlayerRo);
|
const result = cropRegion.Find(cardPlayerRo);
|
||||||
@@ -154,15 +180,13 @@ const cropRegion = captureRegion.DeriveCrop(
|
|||||||
return true; // 返回true表示已找到并处理
|
return true; // 返回true表示已找到并处理
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 所有点位都未找到
|
// 所有点位都未找到
|
||||||
log.info("未在任何检测点找到玩家");
|
log.info("未在任何检测点找到玩家");
|
||||||
textArray.length = 0;
|
textArray.length = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
//获取挑战对象名称
|
//获取挑战对象名称
|
||||||
async function captureAndStoreTexts() {
|
async function captureAndStoreTexts() {
|
||||||
@@ -173,14 +197,14 @@ async function captureAndStoreTexts() {
|
|||||||
{ x: 450, y: 620 },
|
{ x: 450, y: 620 },
|
||||||
{ x: 760, y: 620 },
|
{ x: 760, y: 620 },
|
||||||
{ x: 1070, y: 620 },
|
{ x: 1070, y: 620 },
|
||||||
{x: 1380, y: 620}
|
{ x: 1380, y: 620 },
|
||||||
];
|
];
|
||||||
|
|
||||||
// 截取区域大小
|
// 截取区域大小
|
||||||
const width = 240;
|
const width = 240;
|
||||||
const height = 100;
|
const height = 100;
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
keyPress("F6")
|
keyPress("F6");
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
click(300, 370); //点击七日历练
|
click(300, 370); //点击七日历练
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
@@ -202,10 +226,9 @@ async function captureAndStoreTexts() {
|
|||||||
textArray.push({
|
textArray.push({
|
||||||
text: result.text.trim(),
|
text: result.text.trim(),
|
||||||
x: pos.x + width / 2, // 点击中心位置
|
x: pos.x + width / 2, // 点击中心位置
|
||||||
y: pos.y + height / 2
|
y: pos.y + height / 2,
|
||||||
});}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.warn(`位置 (${pos.x}, ${pos.y}) 未识别到文本`);
|
log.warn(`位置 (${pos.x}, ${pos.y}) 未识别到文本`);
|
||||||
}
|
}
|
||||||
@@ -214,7 +237,6 @@ async function captureAndStoreTexts() {
|
|||||||
log.info(`剩余挑战人数:${textArray.length}`);
|
log.info(`剩余挑战人数:${textArray.length}`);
|
||||||
keyPress("ESCAPE");
|
keyPress("ESCAPE");
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//检查是否有对应的挑战对手
|
//检查是否有对应的挑战对手
|
||||||
@@ -244,7 +266,7 @@ async function searchAndClickTexts() {
|
|||||||
const resText = res.text.trim();
|
const resText = res.text.trim();
|
||||||
|
|
||||||
// 在存储的文本数组中查找匹配项
|
// 在存储的文本数组中查找匹配项
|
||||||
const index = textArray.findIndex(item => item.text === resText);
|
const index = textArray.findIndex((item) => item.text === resText);
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
// 找到匹配项,点击对应位置
|
// 找到匹配项,点击对应位置
|
||||||
@@ -291,15 +313,15 @@ click(48, 441);//放大地图
|
|||||||
await sleep(400);
|
await sleep(400);
|
||||||
click(48, 441); //放大地图
|
click(48, 441); //放大地图
|
||||||
await sleep(400);
|
await sleep(400);
|
||||||
|
|
||||||
click(1000, 645); //猫尾酒馆
|
click(1000, 645); //猫尾酒馆
|
||||||
await sleep(600);
|
await sleep(600);
|
||||||
let tavern = captureGameRegion().find(tavernRo);
|
let tavern = captureGameRegion().find(tavernRo);
|
||||||
if (tavern.isExist()) {
|
if (tavern.isExist()) {
|
||||||
tavern.click();
|
tavern.click();
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
}
|
} else {
|
||||||
else{
|
throw new Error("未能找到猫尾酒馆");
|
||||||
throw new Error('未能找到猫尾酒馆');
|
|
||||||
}
|
}
|
||||||
click(1707, 1010); //确认传送
|
click(1707, 1010); //确认传送
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
@@ -314,6 +336,9 @@ await sleep(1000);
|
|||||||
await autoConversation();
|
await autoConversation();
|
||||||
log.info("对话完成");
|
log.info("对话完成");
|
||||||
await sleep(1500);
|
await sleep(1500);
|
||||||
|
if (settings.partyName != undefined) {
|
||||||
|
await switchCardTeam(settings.partyName);
|
||||||
|
}
|
||||||
click(1610, 900); //点击挑战
|
click(1610, 900); //点击挑战
|
||||||
await sleep(8000);
|
await sleep(8000);
|
||||||
await dispatcher.runTask(new SoloTask("AutoGeniusInvokation"));
|
await dispatcher.runTask(new SoloTask("AutoGeniusInvokation"));
|
||||||
@@ -436,7 +461,6 @@ keyPress("VK_SPACE");
|
|||||||
await sleep(700);
|
await sleep(700);
|
||||||
keyUp("s");
|
keyUp("s");
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openMap() {
|
async function openMap() {
|
||||||
@@ -451,7 +475,6 @@ await sleep(700);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//主流程
|
//主流程
|
||||||
log.info(`前往猫尾酒馆`);
|
log.info(`前往猫尾酒馆`);
|
||||||
await gotoTavern();
|
await gotoTavern();
|
||||||
@@ -460,7 +483,8 @@ if (textArray.length != 0){
|
|||||||
await detectCardPlayer();
|
await detectCardPlayer();
|
||||||
await searchAndClickTexts();
|
await searchAndClickTexts();
|
||||||
}
|
}
|
||||||
for (let i = 0;i < 20; i++) {//循环兜底,避免角色未到达指定位置
|
for (let i = 0; i < 20; i++) {
|
||||||
|
//循环兜底,避免角色未到达指定位置
|
||||||
if (textArray.length === 0) break;
|
if (textArray.length === 0) break;
|
||||||
await gotoTavern();
|
await gotoTavern();
|
||||||
await detectCardPlayer();
|
await detectCardPlayer();
|
||||||
@@ -468,7 +492,7 @@ await searchAndClickTexts();
|
|||||||
}
|
}
|
||||||
await genshin.returnMainUi();
|
await genshin.returnMainUi();
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
keyPress("F6")
|
keyPress("F6");
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
click(300, 370); //点击七日历练
|
click(300, 370); //点击七日历练
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 1,
|
"manifest_version": 1,
|
||||||
"name": "打牌一条龙",
|
"name": "打牌一条龙",
|
||||||
"version": "1.81",
|
"version": "1.9",
|
||||||
"description": "只靠一个牌组的话,胜率还是太低了,所以有没有既简单又强势的卡组推荐下呢?",
|
"description": "只靠一个牌组的话,胜率还是太低了,所以有没有既简单又强势的卡组推荐下呢?",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
|||||||
7
repo/js/七圣召唤七日历练全自动/settings.json
Normal file
7
repo/js/七圣召唤七日历练全自动/settings.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "partyName",
|
||||||
|
"type": "input-text",
|
||||||
|
"label": "设置要使用的七圣召唤队伍名称"
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user