Răsfoiți Sursa

feat(): test list

runhey 3 ani în urmă
părinte
comite
a8e9ef985a

+ 55 - 22
config/template.json

@@ -26,8 +26,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
   },
@@ -45,8 +45,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     },
     "general_battle": {
@@ -74,8 +74,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
   },
@@ -84,8 +84,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
   },
@@ -94,8 +94,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
   },
@@ -104,8 +104,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     },
     "raid_config": {
@@ -134,8 +134,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
   },
@@ -144,8 +144,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
   },
@@ -154,8 +154,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
   },
@@ -164,8 +164,8 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
   },
@@ -174,9 +174,42 @@
       "enable": false,
       "next_run": "2023-01-01 00:00:00",
       "priority": 5,
-      "success_interval": "1 day, 0:00:00",
-      "failure_interval": "1 day, 0:00:00",
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
       "server_update": "06:00:00"
     }
+  },
+  "activity_shikigami": {
+    "scheduler": {
+      "enable": false,
+      "next_run": "2023-01-01 00:00:00",
+      "priority": 5,
+      "success_interval": "01 00:00:00",
+      "failure_interval": "01 00:00:00",
+      "server_update": "06:00:00"
+    },
+    "general_climb": {
+      "limit_time": "00 01:00:00",
+      "limit_count": 50,
+      "ap_game_max": 300,
+      "ap_mode": "ap_activity",
+      "activity_toggle": false
+    },
+    "general_battle": {
+      "lock_team_enable": false,
+      "preset_enable": false,
+      "preset_group": 1,
+      "preset_team": 1,
+      "buff_enable": false,
+      "buff_awake_click": false,
+      "buff_soul_click": false,
+      "buff_gold_50_click": false,
+      "buff_gold_100_click": false,
+      "buff_exp_50_click": false,
+      "buff_exp_100_click": false,
+      "green_enable": false,
+      "green_mark": "green_left1",
+      "random_click_swipt_enable": false
+    }
   }
 }

+ 11 - 3
module/atom/list.py

@@ -77,7 +77,7 @@ class RuleList:
 
         if x1 is None or y1 is None or x2 is None or y2 is None:
             raise Exception("滑动位置计算错误")
-        return x1, y1, x2, y2
+        return int(x1), int(y1), int(x2), int(y2)
 
     def target_check(self, name: str) -> bool:
         """
@@ -184,8 +184,9 @@ class RuleList:
                 break
         if box is not None:
             rec_x, rec_y, rec_w, rec_h = box[0, 0], box[0, 1], box[1, 0] - box[0, 0], box[2, 1] - box[0, 1]
-            x = rec_x + rec_w // 2
-            y = rec_y + rec_h // 2
+            x = rec_x + rec_w // 2 + self.roi_back[0]
+            y = rec_y + rec_h // 2 + self.roi_back[1]
+            logger.info(f'Ocr {name} appear in current screen, do not need to scroll')
             return x, y
 
         # if index_list and len(index_list) >= 1:
@@ -197,6 +198,13 @@ class RuleList:
         else:
             keyword_list: list = [item.ocr_text for item in boxed_results if item.score > RuleOcr.score]
 
+            # 判断识别处理的文字是否属于要验证识别的文字(array)
+            keyword_list = [keyword for keyword in keyword_list if keyword in self.array]
+            logger.info(f'After list: {keyword_list}')
+            if not keyword_list:
+                logger.warning(f'Not found {name} in {self.array}')
+                return 2
+
             start_index = self.array.index(keyword_list[0])
             end_index = self.array.index(keyword_list[-1])
             if name in keyword_list:

+ 1 - 0
module/config/config_manual.py

@@ -11,6 +11,7 @@ class ConfigManual:
         Restart
         > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > RealmRaid
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
+        > ActivityShikigami
         """
 
     DEVICE_OVER_HTTP = False

+ 8 - 1
module/device/control.py

@@ -167,9 +167,16 @@ class Control(Minitouch, Adb, Scrcpy, Window):
         else:
             # ADB needs to be slow, or swipe doesn't work
             duration *= 2.5
-            logger.info('Swipe %s -> %s, %s' % (point2str(*p1), point2str(*p2), duration))
+            logger.info('Swipe %s -> %s, %s ' % (point2str(*p1), point2str(*p2), duration))
 
         if distance_check:
+            if p1[0] == p2[0]:
+                logger.info('Swipe x distance is 0')
+                p1[0] += 1
+            if p1[1] == p2[1]:
+                logger.info('Swipe y distance is 0')
+                p1[1] += 1
+
             if np.linalg.norm(np.subtract(p1, p2)) < 10:
                 # Should swipe a certain distance, otherwise AL will treat it as click.
                 # uiautomator2 should >= 6px, minitouch should >= 5px

+ 1 - 1
module/device/method/minitouch.py

@@ -75,7 +75,7 @@ def insert_swipe(p0, p3, speed=15, min_distance=10):
     prev = (-100, -100)
     for t in ts:
         point = p0 * (1 - t) ** 3 + 3 * p1 * t * (1 - t) ** 2 + 3 * p2 * t ** 2 * (1 - t) + p3 * t ** 3
-        point = point.astype(np.int).tolist()
+        point = point.astype(int).tolist()
         if np.linalg.norm(np.subtract(point, prev)) < min_distance:
             continue
 

+ 10 - 3
module/device/method/window.py

@@ -234,13 +234,20 @@ class Window(Handle):
         SendMessage(handleNum, WM_SETCURSOR, handleNum, MAKELONG(HTCLIENT, WM_LBUTTONDOWN))
         PostMessage(handleNum, WM_LBUTTONDOWN, MK_LBUTTON, tmpPos)
         # 一点一点移动鼠标
-        for pos in trace:
+        for pos in trace[:-3]:
             tmpPos = MAKELONG(pos[0], pos[1])
             PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, tmpPos)
             time.sleep((interval + random.randint(-2, 2)) / 1000.0)
         # 最后释放鼠标
-        tmpPos = MAKELONG(trace[-1][0], trace[-1][1])
-        PostMessage(handleNum, WM_LBUTTONUP, 0, tmpPos)
+        end_pos_3 = MAKELONG(trace[-3][0], trace[-3][1])
+        end_pos_2 = MAKELONG(trace[-2][0], trace[-2][1])
+        end_pos_1 = MAKELONG(trace[-1][0], trace[-1][1])
+        PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, end_pos_3)
+        time.sleep(0.08)
+        PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, end_pos_2)
+        time.sleep(0.08)
+        PostMessage(handleNum, WM_MOUSEMOVE, MK_LBUTTON, end_pos_1)
+        PostMessage(handleNum, WM_LBUTTONUP, 0, end_pos_1)
 
     def swipe_vector_window_message2(self, startPos: list, endPos: list) -> None:
         """

+ 2 - 2
tasks/ActivityShikigami/assets.py

@@ -41,9 +41,9 @@ class ActivityShikigamiAssets:
 
 	# Ocr Rule Assets
 	# 体力的数量检测 
-	O_REMAIN_AP = RuleOcr(roi=(1180,678,86,30), area=(1180,678,86,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
+	O_REMAIN_AP = RuleOcr(roi=(1180,678,82,30), area=(1180,678,86,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
 	# 活动体力的剩余检测 
-	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(722,23,96,34), area=(722,23,96,34), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
+	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(722,23,87,34), area=(722,23,96,34), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
 	# 还有多少次购买体力的机会 
 	O_REMAIN_BUY = RuleOcr(roi=(808,531,39,42), area=(808,531,39,42), mode="DigitCounter", method="Default", keyword="", name="remain_buy")
 

+ 2 - 2
tasks/Orochi/assets.py

@@ -12,7 +12,7 @@ class OrochiAssets:
 
 	# List Rule Assets
 	# 这个是御魂界面选择不同层数的 
-	L_N33AME = RuleList(folder="./tasks/Orochi/res", direction="vertical", mode="ocr", roi_back=(160,130,317,500), size=(301, 86), 
-					 array=["壹层", "贰层", "叁层", "肆层", "伍层", "陆层", "柒层", "捌层", "玖层", "拾层", "悲鸣", "神罚"])
+	L_LAYER_LIST = RuleList(folder="./tasks/Orochi/res", direction="vertical", mode="ocr", roi_back=(276,130,52,500), size=(45, 88), 
+					 array=["壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖", "拾", "悲", "神"])
 
 

+ 26 - 26
tasks/Orochi/res/list.json

@@ -1,57 +1,57 @@
 {
-  "name": "n33ame",
+  "name": "layer_list",
   "direction": "vertical",
   "type": "ocr",
-  "roiBack": "160,130,317,500",
+  "roiBack": "276,130,52,500",
   "description": "这个是御魂界面选择不同层数的",
   "list": [
     {
-      "itemName": "壹层",
-      "roiFront": "169,142,303,86"
+      "itemName": "壹",
+      "roiFront": "281,135,39,102"
     },
     {
-      "itemName": "贰层",
-      "roiFront": "168,253,300,85"
+      "itemName": "贰",
+      "roiFront": "280,253,39,85"
     },
     {
-      "itemName": "叁层",
-      "roiFront": "165,422,306,93"
+      "itemName": "叁",
+      "roiFront": "283,422,43,93"
     },
     {
-      "itemName": "肆层",
-      "roiFront": "167,312,304,90"
+      "itemName": "肆",
+      "roiFront": "280,312,44,90"
     },
     {
-      "itemName": "伍层",
-      "roiFront": "168,425,299,82"
+      "itemName": "伍",
+      "roiFront": "282,425,43,82"
     },
     {
-      "itemName": "陆层",
-      "roiFront": "166,316,298,89"
+      "itemName": "陆",
+      "roiFront": "275,316,47,89"
     },
     {
-      "itemName": "柒层",
-      "roiFront": "171,312,298,93"
+      "itemName": "柒",
+      "roiFront": "279,312,48,93"
     },
     {
-      "itemName": "捌层",
-      "roiFront": "169,203,302,89"
+      "itemName": "捌",
+      "roiFront": "275,203,51,89"
     },
     {
-      "itemName": "玖层",
-      "roiFront": "167,206,302,81"
+      "itemName": "玖",
+      "roiFront": "278,206,48,81"
     },
     {
-      "itemName": "拾层",
-      "roiFront": "166,315,298,84"
+      "itemName": "拾",
+      "roiFront": "282,315,45,84"
     },
     {
-      "itemName": "悲鸣",
-      "roiFront": "167,427,305,85"
+      "itemName": "悲",
+      "roiFront": "277,427,47,85"
     },
     {
-      "itemName": "神罚",
-      "roiFront": "165,534,305,86"
+      "itemName": "神",
+      "roiFront": "277,534,46,86"
     }
   ]
 }

+ 45 - 0
tasks/Orochi/script_task.py

@@ -0,0 +1,45 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+
+from tasks.base_task import BaseTask
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.GameUi.game_ui import GameUi
+from tasks.Orochi.assets import OrochiAssets
+from module.logger import logger
+
+class ScriptTask(GeneralBattle, GameUi, OrochiAssets):
+
+    def run(self) -> bool:
+        pass
+
+    def check_layer(self, layer: str) -> bool:
+        """
+        检查挑战的层数, 并选中挑战的层
+        :return:
+        """
+        pos = self.list_find(self.L_LAYER_LIST, layer)
+        if pos:
+            self.device.click(x=pos[0], y=pos[1])
+            return True
+
+
+
+
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    c = Config('oas1')
+    d = Device(c)
+    t = ScriptTask(c, d)
+    t.check_layer('陆')
+
+
+
+
+
+
+

+ 3 - 1
tasks/base_task.py

@@ -3,6 +3,7 @@
 # github https://github.com/runhey
 import numpy as np
 
+from time import sleep
 from datetime import datetime, timedelta, time
 from typing import Union
 
@@ -403,8 +404,9 @@ class BaseTask(GlobalGameAssets):
                 elif isinstance(result, int) and result < 0:
                     after = False
 
-                x1, y1, x2, y2 = target.swipe_pos(after=after)
+                x1, y1, x2, y2 = target.swipe_pos(number=1, after=after)
                 self.device.swipe(p1=(x1, y1), p2=(x2, y2))
+                sleep(1)  # 等待滑动完成, 还没想好如何优化
 
     def set_next_run(self, task: str, finish: bool = False,
                      success: bool=None, server: bool=None, target: timedelta=None) -> None: