@@ -25,15 +25,10 @@ async function scrollPage(totalDistance, stepDistance = 10, delayMs = 5) {
|
||||
[460, 538],
|
||||
[792, 538],
|
||||
[1130, 538],
|
||||
[1462, 538]
|
||||
[1462, 538],
|
||||
];
|
||||
|
||||
const positionSettings = [
|
||||
settings.position1,
|
||||
settings.position2,
|
||||
settings.position3,
|
||||
settings.position4
|
||||
];
|
||||
const positionSettings = [settings.position1, settings.position2, settings.position3, settings.position4];
|
||||
|
||||
// 识别对象定义
|
||||
const roTeamConfig = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`Assets/RecognitionObject/队伍配置.png`), 0, 0, 1920, 1080);
|
||||
@@ -43,6 +38,13 @@ async function scrollPage(totalDistance, stepDistance = 10, delayMs = 5) {
|
||||
let openPairingTries = 0;
|
||||
let totalOpenPairingTries = 0;
|
||||
|
||||
// 在进入角色切换逻辑前进行检测,如果所有角色设置均为空则直接退出
|
||||
if (positionSettings.every((item) => !item || item.trim() === "")) {
|
||||
log.info("未设置任何角色,跳过切换队伍步骤");
|
||||
await genshin.returnMainUi();
|
||||
return;
|
||||
}
|
||||
|
||||
async function openPairingInterface() {
|
||||
while (openPairingTries < 3) {
|
||||
keyPress("l");
|
||||
@@ -60,25 +62,27 @@ async function scrollPage(totalDistance, stepDistance = 10, delayMs = 5) {
|
||||
openPairingTries = 0;
|
||||
return openPairingInterface();
|
||||
} else {
|
||||
log.error('无法打开配对界面,任务结束');
|
||||
log.error("无法打开配对界面,任务结束");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!await openPairingInterface()) {
|
||||
if (!(await openPairingInterface())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 角色切换逻辑
|
||||
for (let i = 0; i < positionSettings.length; i++) {
|
||||
let rolenum = i+1;
|
||||
let rolenum = i + 1;
|
||||
const selectedCharacter = positionSettings[i];
|
||||
if (selectedCharacter === "") {
|
||||
if (!selectedCharacter || selectedCharacter.trim() === "") {
|
||||
log.info(`未设置${rolenum}号位角色,跳过`);
|
||||
continue;
|
||||
}
|
||||
const [x, y] = positionCoordinates[i];
|
||||
click(x, y);
|
||||
log.info(`开始设置${rolenum}号位角色`);
|
||||
|
||||
await sleep(1000);
|
||||
|
||||
let characterFound = false;
|
||||
@@ -88,12 +92,15 @@ async function scrollPage(totalDistance, stepDistance = 10, delayMs = 5) {
|
||||
while (pageTries < 20) {
|
||||
// 尝试识别所有可能的角色文件名
|
||||
for (let num = 1; ; num++) {
|
||||
const paddedNum = num.toString().padStart(2, '0');
|
||||
const paddedNum = num.toString().padStart(2, "0");
|
||||
const characterFileName = `${selectedCharacter}${paddedNum}`;
|
||||
try {
|
||||
const characterRo = RecognitionObject.TemplateMatch(
|
||||
file.ReadImageMatSync(`Assets/characterimage/${characterFileName}.png`),
|
||||
0, 0, 1920, 1080
|
||||
0,
|
||||
0,
|
||||
1920,
|
||||
1080
|
||||
);
|
||||
const characterResult = captureGameRegion().find(characterRo);
|
||||
if (characterResult.isExist()) {
|
||||
|
||||
Reference in New Issue
Block a user