ICe 3 月之前
父節點
當前提交
470386d437

+ 1 - 0
Readme.md

@@ -7,6 +7,7 @@
 - [X] 每日徽章勾选修改
 - [X] 组织小怪进不去问题
 - [ ] 活动页签待实现
+- [ ] 任务界面有可能卡主
 
 # 应用程序说明文档
 

+ 33 - 21
src/main/java/com/sencorsta/rabs/obj/ai/AiManage.java

@@ -58,6 +58,7 @@ public class AiManage {
     double checkPoint = 0.85;
 
     boolean isRunning = false;
+
     public void run() {
         //加载所有Scene
         fillSceneMap();
@@ -75,35 +76,27 @@ public class AiManage {
 
                 if (curScene == null) {
                     //检查当前界面是否为非主场景
-                    curScene = sceneMap.values().stream().filter(o -> {
-                        try {
-                            boolean check = o.check();
-                            if (check) {
-                                System.out.println("找到当前场景:" + o.getClass().getSimpleName());
-                            }
-                            return check;
-                        } catch (AWTException e) {
-                            e.printStackTrace();
-                        }
-                        return false;
-                    }).findFirst().orElse(null);
-                    if (curScene == null) {
-                        System.out.println("没有找到当前场景默认使用主场景:" + rootScene.getClass().getSimpleName());
-                        curScene = rootScene;
-                    }
+                    scanScene();
                 }
                 if (curScene.isDone()) {
                     Scene parent = curScene.getParent();
                     if (parent == null) {
                         System.out.println("当前没有任何事件。。。。。。。。");
                     } else {
+                        int tempCount = 0;
                         do {
+                            ThreadUtil.sleep(2000);
                             System.out.println("进入 back = " + curScene.getClass().getSimpleName());
                             curScene.back();
                             ThreadUtil.sleep(2000);
+                            tempCount++;
+                        }
+                        while (!parent.check() && isRunning && tempCount < 30);
+                        if (tempCount >= 30) {
+                            scanScene();
+                        } else {
+                            curScene = parent;
                         }
-                        while (!parent.check()&&isRunning);
-                        curScene = parent;
                     }
                 } else {
                     System.out.println("进入 think = " + curScene.getClass().getSimpleName());
@@ -118,8 +111,27 @@ public class AiManage {
             } catch (Exception e) {
                 e.printStackTrace();
             }
-        }, 1000, 1000, TimeUnit.MILLISECONDS);
-        isRunning=true;
+        }, 1000, 3000, TimeUnit.MILLISECONDS);
+        isRunning = true;
+    }
+
+    private void scanScene() {
+        curScene = sceneMap.values().stream().filter(o -> {
+            try {
+                boolean check = o.check();
+                if (check) {
+                    System.out.println("找到当前场景:" + o.getClass().getSimpleName());
+                }
+                return check;
+            } catch (AWTException e) {
+                e.printStackTrace();
+            }
+            return false;
+        }).findFirst().orElse(null);
+        if (curScene == null) {
+            System.out.println("没有找到当前场景默认使用主场景:" + rootScene.getClass().getSimpleName());
+            curScene = rootScene;
+        }
     }
 
     public void updateWindow() throws AWTException {
@@ -201,6 +213,6 @@ public class AiManage {
         thinkPoll.shutdown();
         thinkPoll.shutdownNow();
         AppConfig.getInstance().saveAll();
-        isRunning=false;
+        isRunning = false;
     }
 }

+ 4 - 1
src/main/java/com/sencorsta/rabs/obj/ai/scene/emblem/SceneMain_Emblem.java

@@ -134,11 +134,14 @@ public class SceneMain_Emblem extends BaseScene implements Scene {
         ThreadUtil.sleep(2000);
         randomToClick();
         ThreadUtil.sleep(2000);
+
+        getRecord().getData().setCount(count);
+
     }
 
     @Override
     public boolean isDone() {
-        return getRecord().getData().getCount() > maxTimes;
+        return getRecord().getData().getCount() >= maxTimes;
     }
 
 

+ 14 - 11
src/main/java/com/sencorsta/rabs/obj/ai/scene/qiyi/SceneMain_Qiyu_quest.java

@@ -68,15 +68,18 @@ public class SceneMain_Qiyu_quest extends BaseScene implements Scene {
 
         for (int i = 0; i < 4; i++) {
             ThreadUtil.sleep(1234);
-            moveToClick(PathEnter, AiManage.getInstance().getCheckPoint(), new org.opencv.core.Point(-5, 20));
-            ThreadUtil.sleep(3000);
-            randomToClick();
-            ThreadUtil.sleep(2000);
-
-            moveToClick(PathFinish, AiManage.getInstance().getCheckPoint(), new org.opencv.core.Point(-5, 20));
-            ThreadUtil.sleep(3000);
-            randomToClick();
-            ThreadUtil.sleep(2000);
+            if (checkHas(PathEnter, AiManage.getInstance().getCheckPoint())) {
+                moveToClick(PathEnter, AiManage.getInstance().getCheckPoint(), new org.opencv.core.Point(-5, 20));
+                ThreadUtil.sleep(3000);
+                randomToClick();
+                ThreadUtil.sleep(2000);
+            }
+            if (checkHas(PathFinish, AiManage.getInstance().getCheckPoint())) {
+                moveToClick(PathFinish, AiManage.getInstance().getCheckPoint(), new org.opencv.core.Point(-5, 20));
+                ThreadUtil.sleep(3000);
+                randomToClick();
+                ThreadUtil.sleep(2000);
+            }
         }
         if (checkHas(PathDailyJob, AiManage.getInstance().getCheckPoint())) {
             moveToClick(PathDailyJob, AiManage.getInstance().getCheckPoint());
@@ -91,7 +94,7 @@ public class SceneMain_Qiyu_quest extends BaseScene implements Scene {
             for (int i = 0; i < 4; i++) {
                 if (checkHas(PathTake, AiManage.getInstance().getCheckPoint())) {
                     moveToClick(PathTake, AiManage.getInstance().getCheckPoint());
-                }else {
+                } else {
                     moveToClick(PathRefersh, AiManage.getInstance().getCheckPoint());
                 }
                 ThreadUtil.sleep(2000);
@@ -112,7 +115,7 @@ public class SceneMain_Qiyu_quest extends BaseScene implements Scene {
      * 重置
      */
     @Override
-    public ResettableData.ResetType getType(){
+    public ResettableData.ResetType getType() {
         return ResettableData.ResetType.SPECIAL_RULES;
     }
 }