Adjusted sleep durations and loop conditions for improved performance.
This commit is contained in:
Sahik authored and GitHub committed 2026-03-04 04:42:28 +08:00
1 parent b589f00a80
commit a5e7e83d70
1 file changed
+7 -6
+7 -6
View File
@@ -66,8 +66,9 @@ while (true) {
app.launchPackage("com.hidea.cat"); app.launchPackage("com.hidea.cat");
toast("嘗試開啟遊戲..."); toast("嘗試開啟遊戲...");
var img = captureScreen(); var img = captureScreen();
while(!images.detectsColor(img, "#F4ECD3", 685, 1095)){ while(!images.detectsColor(img, "#F4ECD3", 685, 1095) && pkg == "com.hidea.cat"){
sleep(5000); sleep(5000);
var pkg = currentPackage();
var img = captureScreen(); var img = captureScreen();
} }
continue; continue;
@@ -168,16 +169,16 @@ while (true) {
var img = captureScreen(); var img = captureScreen();
while(images.detectsColor(img, "#F2B1B1", 527, 846) && !isPaused){ while(images.detectsColor(img, "#F2B1B1", 527, 846) && !isPaused){
swipe(360, 800, 360, 200, 500); // up swipe(360, 800, 360, 200, 500); // up
sleep(50); sleep(100);
swipe(360, 300, 360, 900, 500); // down swipe(360, 300, 360, 900, 500); // down
sleep(50); sleep(100);
img = captureScreen(); img = captureScreen();
var firstY = -1; var firstY = -1;
var lastY = -1; var lastY = -1;
// 從上往下 // 從上往下
for (var y = 400; y <= 700; y += 10) { for (var y = 300; y <= 800; y += 5) {
if (images.detectsColor(img, "#F9DBDC", 360, y)) { if (images.detectsColor(img, "#F9DBDC", 360, y)) {
firstY = y; firstY = y;
break; break;
@@ -185,7 +186,7 @@ while (true) {
} }
// 從下往上 // 從下往上
for (var y = 700; y >= 400; y -= 10) { for (var y = 800; y >= 300; y -= 5) {
if (images.detectsColor(img, "#F9DBDC", 360, y)) { if (images.detectsColor(img, "#F9DBDC", 360, y)) {
lastY = y; lastY = y;
break; break;
@@ -193,7 +194,7 @@ while (true) {
} }
if (firstY !== -1 && lastY !== -1) { if (firstY !== -1 && lastY !== -1) {
var avgY = (firstY + lastY) / 2; var avgY = (firstY + lastY) / 2;
swipe(360, avgY, 360, 900, 300); swipe(360, avgY, 360, 900, 500);
sleep(50); sleep(50);
} }