ICe 2 months ago
parent
commit
0f3569300d

BIN
opencv/scene/family/battle/back.png


BIN
opencv/scene/family/battle/check.png


BIN
opencv/scene/family/battle/enter.png


BIN
opencv/scene/family/battle/goLeft.png


BIN
opencv/scene/family/battle/img.png


BIN
opencv/scene/family/battle/rightDoor.png


BIN
opencv/scene/family/battle/start.png


BIN
opencv/scene/family/battle/start2.png


BIN
opencv/scene/glory/match/notOpen.png


BIN
opencv/scene/ip2.png


+ 4 - 0
src/main/java/com/sencorsta/rabs/obj/ai/AiManage.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
 import com.sencorsta.rabs.annotation.SceneAnnotation;
 import com.sencorsta.rabs.config.AppConfig;
 import com.sencorsta.rabs.obj.ai.api.Scene;
+import com.sencorsta.rabs.obj.ai.scene.SceneMain;
 import com.sencorsta.rabs.ui.robot.RobotUtil;
 import com.sencorsta.utils.object.Jsons;
 import com.sun.jna.platform.win32.User32;
@@ -103,6 +104,9 @@ public class AiManage {
                     curScene.think();
                     Scene undoneChildren = curScene.getChildren().stream().filter(o -> !o.isDone() && o.isOpen()).max(Comparator.comparingDouble(Scene::getPriority)).orElse(null);
                     if (ObjectUtil.isNotNull(undoneChildren)) {
+                        //通用检查
+                        curScene.checkBeforeEnter();
+
                         System.out.println("进入 open = " + undoneChildren.getClass().getSimpleName());
                         undoneChildren.open();
                         curScene = undoneChildren;

+ 12 - 0
src/main/java/com/sencorsta/rabs/obj/ai/api/BaseScene.java

@@ -4,6 +4,7 @@ import cn.hutool.core.thread.ThreadUtil;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.sencorsta.rabs.obj.ai.AiManage;
+import com.sencorsta.rabs.obj.ai.scene.SceneMain;
 import com.sencorsta.rabs.obj.ai.status.fight.BaseStatus;
 import com.sencorsta.rabs.ui.robot.RobotUtil;
 import com.sencorsta.rabs.util.ResettableData;
@@ -79,6 +80,7 @@ public class BaseScene {
     }
 
 
+
     protected void moveToClick(String filename, double similarityThreshold) throws AWTException {
         moveToClick(filename, similarityThreshold, new Point(0, 0));
     }
@@ -249,6 +251,16 @@ public class BaseScene {
         record.maybeReset();
     }
 
+    public void checkBeforeEnter() throws AWTException {
+        if (checkHas(SceneMain.getPathIp1(), AiManage.getInstance().getCheckPoint())) {
+            moveToClick(SceneMain.getPathIp1(),AiManage.getInstance().getCheckPoint());
+            ThreadUtil.sleep(2000);
+        }
+        if (checkHas(SceneMain.getPathIp2(), AiManage.getInstance().getCheckPoint())) {
+            moveToClick(SceneMain.getPathIp2(),AiManage.getInstance().getCheckPoint());
+            ThreadUtil.sleep(2000);
+        }
+    }
 
     //TODO ice 文字识别封装成一个方法 实现指定任意区域查找英文或者中文
 //    public static void main(String[] args) {

+ 5 - 0
src/main/java/com/sencorsta/rabs/obj/ai/api/Scene.java

@@ -86,4 +86,9 @@ public interface Scene {
      * 强制通过
      */
     void forcePass();
+
+    /**
+     * 进入前通用检查
+     */
+    void checkBeforeEnter() throws AWTException;
 }

+ 5 - 0
src/main/java/com/sencorsta/rabs/obj/ai/scene/SceneMain.java

@@ -4,6 +4,7 @@ import com.sencorsta.rabs.annotation.SceneAnnotation;
 import com.sencorsta.rabs.obj.ai.AiManage;
 import com.sencorsta.rabs.obj.ai.api.BaseScene;
 import com.sencorsta.rabs.obj.ai.api.Scene;
+import lombok.Getter;
 
 import java.awt.AWTException;
 
@@ -13,7 +14,11 @@ import java.awt.AWTException;
 @SceneAnnotation("")
 public class SceneMain extends BaseScene implements Scene {
     private static String PathCheck = System.getProperty("user.dir") + "\\opencv\\scene\\check.png";
+    @Getter
     private static String PathIp1 = System.getProperty("user.dir") + "\\opencv\\scene\\ip1.png";
+    @Getter
+    private static String PathIp2 = System.getProperty("user.dir") + "\\opencv\\scene\\ip2.png";
+
     @Override
     public void back() {
     }

+ 92 - 0
src/main/java/com/sencorsta/rabs/obj/ai/scene/family/SceneMain_Family_Battle.java

@@ -0,0 +1,92 @@
+package com.sencorsta.rabs.obj.ai.scene.family;
+
+import cn.hutool.core.thread.ThreadUtil;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.sencorsta.rabs.annotation.SceneAnnotation;
+import com.sencorsta.rabs.obj.ai.AiManage;
+import com.sencorsta.rabs.obj.ai.api.BaseScene;
+import com.sencorsta.rabs.obj.ai.api.Scene;
+import org.opencv.core.Point;
+
+import java.awt.AWTException;
+
+/**
+ * 组织-争霸
+ */
+@SceneAnnotation("SceneMain_Family")
+public class SceneMain_Family_Battle extends BaseScene implements Scene {
+    @JsonIgnore
+    @Override
+    public float getPriority() {
+        return 5f;
+    }
+
+    private static String PathEnter = System.getProperty("user.dir") + "\\opencv\\scene\\family\\battle\\enter.png";
+    private static String PathCheck = System.getProperty("user.dir") + "\\opencv\\scene\\family\\battle\\check.png";
+    private static String PathBack = System.getProperty("user.dir") + "\\opencv\\scene\\family\\battle\\back.png";
+
+    private static String PathStart = System.getProperty("user.dir") + "\\opencv\\scene\\family\\battle\\start.png";
+    private static String PathStart2 = System.getProperty("user.dir") + "\\opencv\\scene\\family\\battle\\start2.png";
+
+    private static String PathRightdoor = System.getProperty("user.dir") + "\\opencv\\scene\\family\\battle\\rightDoor.png";
+    private static String PathGoLeft = System.getProperty("user.dir") + "\\opencv\\scene\\family\\battle\\goLeft.png";
+
+
+    @Override
+    public void back() throws AWTException {
+        moveToClick(PathBack, AiManage.getInstance().getCheckPoint());
+    }
+
+    @Override
+    public void open() throws AWTException {
+        while (AiManage.getInstance().isRunning() && !check()) {
+            AiManage.getInstance().updateWindow();
+            ThreadUtil.sleep(2000);
+            if (checkHas(PathEnter, AiManage.getInstance().getCheckPoint())) {
+                moveToClick(PathEnter, AiManage.getInstance().getCheckPoint(),new Point(80, 0));
+                ThreadUtil.sleep(5000);
+                continue;
+            }
+
+            if (checkHas(PathRightdoor, AiManage.getInstance().getCheckPoint())) {
+                moveToClick(PathGoLeft, AiManage.getInstance().getCheckPoint(), new Point(-100, -70));
+                ThreadUtil.sleep(5000);
+            }else {
+                moveToClick(PathGoLeft, AiManage.getInstance().getCheckPoint(), new Point(430, -70));
+                ThreadUtil.sleep(5000);
+            }
+        }
+    }
+
+    @Override
+    public boolean check() throws AWTException {
+        if (checkHas(PathCheck, AiManage.getInstance().getCheckPoint())) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public void think() throws AWTException {
+        if (checkHas(PathStart, AiManage.getInstance().getCheckPoint())) {
+            moveToClick(PathStart, AiManage.getInstance().getCheckPoint());
+            ThreadUtil.sleep(2000);
+
+            if (checkHas(PathStart2, AiManage.getInstance().getCheckPoint())) {
+                moveToClick(PathStart2, AiManage.getInstance().getCheckPoint());
+                ThreadUtil.sleep(2000);
+            }
+            //TODO ice 补充逻辑
+            getRecord().getData().setDone(true);
+        }else {
+            //今天没有比赛
+            getRecord().getData().setDone(true);
+        }
+    }
+
+    @Override
+    public boolean isDone() {
+        return getRecord().getData().isDone()&&hasChildDone();
+    }
+
+}

+ 1 - 1
src/main/java/com/sencorsta/rabs/obj/ai/scene/family/SceneMain_Family_Info.java

@@ -18,7 +18,7 @@ public class SceneMain_Family_Info extends BaseScene implements Scene {
     @JsonIgnore
     @Override
     public float getPriority() {
-        return 2.0f;
+        return 2f;
     }
 
     private static String PathEnter = System.getProperty("user.dir") + "\\opencv\\scene\\family\\info\\enter.png";

+ 1 - 1
src/main/java/com/sencorsta/rabs/obj/ai/scene/family/SceneMain_Family_Out.java

@@ -18,7 +18,7 @@ public class SceneMain_Family_Out extends BaseScene implements Scene {
     @JsonIgnore
     @Override
     public float getPriority() {
-        return 2.0f;
+        return 4.0f;
     }
 
     private static String PathEnter = System.getProperty("user.dir") + "\\opencv\\scene\\family\\out\\enter.png";

+ 7 - 0
src/main/java/com/sencorsta/rabs/obj/ai/scene/glory/SceneMain_Glory_Match.java

@@ -37,6 +37,7 @@ public class SceneMain_Glory_Match extends SceneWhitSubRecord implements Scene {
     private static String PathReward = System.getProperty("user.dir") + "\\opencv\\scene\\glory\\match\\reward.png";
     private static String PathOb = System.getProperty("user.dir") + "\\opencv\\scene\\glory\\match\\ob.png";
     private static String PathLv = System.getProperty("user.dir") + "\\opencv\\scene\\glory\\match\\lv.png";
+    private static String PathNotOpen = System.getProperty("user.dir") + "\\opencv\\scene\\glory\\match\\notOpen.png";
     private int maxTime = 99;
 
     @Override
@@ -73,6 +74,12 @@ public class SceneMain_Glory_Match extends SceneWhitSubRecord implements Scene {
         int count = getRecord().getData().getCount();
         while (AiManage.getInstance().isRunning() && !isDone()) {
             ThreadUtil.sleep(3000);
+            if (checkHas(PathNotOpen,AiManage.getInstance().getCheckPoint())){
+                System.out.println("活动未开启!");
+                getRecordSub().getData().setDone(true);
+                break;
+            }
+
             if (checkHas(PathStart, AiManage.getInstance().getCheckPoint())) {
                 moveToClick(PathStart, AiManage.getInstance().getCheckPoint());
                 ThreadUtil.sleep(5000);

+ 6 - 2
src/main/java/com/sencorsta/rabs/obj/ai/scene/qiyi/SceneMain_Qiyu_helper.java

@@ -58,8 +58,10 @@ public class SceneMain_Qiyu_helper extends BaseScene implements Scene {
     public void think() throws AWTException {
         moveToClick(PathOneButton,AiManage.getInstance().getCheckPoint());
         ThreadUtil.sleep(2000);
-        while (AiManage.getInstance().isRunning() && !checkHas(PathOk,AiManage.getInstance().getCheckPoint())){
+        int countTemp=30;
+        while (countTemp>0&&AiManage.getInstance().isRunning() && !checkHas(PathOk,AiManage.getInstance().getCheckPoint())){
             ThreadUtil.sleep(2000);
+            countTemp--;
         }
         ThreadUtil.sleep(5000);
         moveToClick(PathOk,AiManage.getInstance().getCheckPoint());
@@ -76,8 +78,10 @@ public class SceneMain_Qiyu_helper extends BaseScene implements Scene {
         moveToClick(PathOneButton,AiManage.getInstance().getCheckPoint());
         ThreadUtil.sleep(2000);
 
-        while (AiManage.getInstance().isRunning() && !checkHas(PathOk,AiManage.getInstance().getCheckPoint())){
+        countTemp=30;
+        while (countTemp>0&&AiManage.getInstance().isRunning() && !checkHas(PathOk,AiManage.getInstance().getCheckPoint())){
             ThreadUtil.sleep(2000);
+            countTemp--;
         }
         ThreadUtil.sleep(5000);
         moveToClick(PathOk,AiManage.getInstance().getCheckPoint());