Jelajahi Sumber

Merge pull request #134 from runhey/dev

Dev
huangrunheng 3 tahun lalu
induk
melakukan
859399e001

+ 1 - 1
README.md

@@ -64,7 +64,7 @@ This project is licensed under the GNU General Public License v3.0.
 - 你必须拥有一个 Github 账户来点一个 **Star** (这并不影响你入群后取消Star),同样的要求注册时间过半年。
 - 入群验证填入你的 Github 账号名,无需在意问题是什么。
 
-#### 开发群: 207613181
+#### QQ开发群: 207613181
 
 - 发展规划:[#54](https://github.com/runhey/OnmyojiAutoScript/issues/54)
 - OAS 继承了 Alas 的设计思路,这使得极大简便了开发,欢迎提交 Pull Requests,挑选你感兴趣的部分进行开发即可。

+ 3 - 3
config/template.json

@@ -3,10 +3,10 @@
   "script": {
     "device": {
       "serial": "auto",
-      "handle": "auto",
+      "handle": "",
       "package_name": "auto",
-      "screenshot_method": "window_background",
-      "control_method": "window_message",
+      "screenshot_method": "auto",
+      "control_method": "minitouch",
       "adb_restart": false
     },
     "error": {

+ 3 - 1
module/daemon/benchmark.py

@@ -199,7 +199,7 @@ class Benchmark(DaemonBase):
 
     def run(self):
         try:
-            self.config.override(script.device.screenshot_method='ADB')
+            self.config.override(self.device.screenshot_method == 'ADB')
             self.device.uninstall_minicap()
 
         except RequestHumanTakeover:
@@ -227,6 +227,8 @@ class Benchmark(DaemonBase):
             screenshot = remove('aScreenCap', 'aScreenCap_nc')
         if self.device.is_chinac_phone_cloud:
             screenshot = remove('ADB_nc', 'aScreenCap_nc')
+        if self.config.script.device.handle == '':
+            screenshot = remove('window_background')
         screenshot = tuple(screenshot)
 
         self.TEST_TOTAL = 3

+ 1 - 1
tasks/Component/ReplaceShikigami/replace_shikigami.py

@@ -48,7 +48,7 @@ class ReplaceShikigami(BaseTask, ReplaceShikigamiAssets):
 
             if self.appear(check_selected):
                 break
-            if self.appear_then_click(check_click, interval=0.5):
+            if self.appear_then_click(check_click, interval=1):
                 continue
             if self.click(self.C_SHIKIGAMI_SWITCH_1, interval=3):
                 continue

+ 15 - 9
tasks/DailyTrifles/script_task.py

@@ -13,6 +13,7 @@ from tasks.Component.Summon.summon import Summon
 
 from module.logger import logger
 from module.exception import TaskEnd
+from module.base.timer import Timer
 
 
 
@@ -49,15 +50,20 @@ class ScriptTask(GameUi, Summon, DailyTriflesAssets):
                 break
             if self.appear_then_click(self.I_L_FRIENDS, interval=1):
                 continue
-        logger.info('Friend love')
-        sleep(0.5)
-        self.screenshot()
-        if not self.appear(self.I_L_COLLECT):
-            logger.warning('There is no any love')
-            self.ui_click(self.I_UI_BACK_RED, self.I_CHECK_MAIN)
-            return
-        if self.ui_get_reward(self.I_L_COLLECT):
-            logger.info('Get reward of friend love')
+        logger.info('Start friend love')
+        check_timer = Timer(2)
+        check_timer.start()
+        while 1:
+            self.screenshot()
+
+            if self.appear_then_click(self.I_L_COLLECT, interval=1):
+                continue
+            if self.ui_reward_appear_click():
+                logger.info('Get reward of friend love')
+                break
+            if check_timer.reached():
+                logger.warning('There is no any love')
+                break
 
         self.ui_click(self.I_UI_BACK_RED, self.I_CHECK_MAIN)
 

+ 1 - 1
tasks/EvoZone/assets.py

@@ -14,7 +14,7 @@ class EvoZoneAssets:
 	# 火麒麟进入 
 	I_FIRE_KIRIN = RuleImage(roi_front=(84,126,217,406), roi_back=(84,126,217,406), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_fire_kirin.png")
 	# 组队 
-	I_FORM_TEAM = RuleImage(roi_front=(937,591,100,100), roi_back=(937,591,100,100), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_form_team.png")
+	I_FORM_TEAM = RuleImage(roi_front=(934,585,100,100), roi_back=(916,572,156,130), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_form_team.png")
 	# description 
 	I_EVOZONE_LOCK = RuleImage(roi_front=(558,565,31,32), roi_back=(548,554,53,54), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_evozone_lock.png")
 	# description 

+ 2 - 2
tasks/EvoZone/o/image.json

@@ -11,8 +11,8 @@
   {
     "itemName": "form_team",
     "imageName": "o_form_team.png",
-    "roiFront": "937,591,100,100",
-    "roiBack": "937,591,100,100",
+    "roiFront": "934,585,100,100",
+    "roiBack": "916,572,156,130",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "组队"

+ 14 - 23
tasks/Exploration/script_task.py

@@ -182,37 +182,28 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
     def do_battle(self):
         while 1:
             self.screenshot()
+            # 战后奖励
+            self.appear_then_click(self.I_BATTLE_REWARD)
             # boss 战
             if self.appear_then_click(self.I_BOSS_BATTLE_BUTTON):
-                self.run_general_battle(self.config.exploration.general_battle_config)
+                time.sleep(0.5)
                 self.screenshot()
-                if self.wait_until_appear(self.I_E_SETTINGS_BUTTON):
-                    while 1:
-                        self.screenshot()
-                        if self.appear_then_click(self.I_BATTLE_REWARD):
-                            self.screenshot()
-                            self.click(self.C_CLICK_ROTATE_1)
-                            time.sleep(0.5)
-                        if self.appear(self.I_EXPLORATION_TITLE):
-                            break
-                        if self.appear(self.I_E_EXPLORATION_CLICK):
-                            break
-                if self.appear(self.I_E_EXPLORATION_CLICK) or self.appear(self.I_EXPLORATION_TITLE):
-                    break
+                if self.appear(self.I_BOSS_BATTLE_BUTTON):
+                    continue
+                self.run_general_battle(self.config.exploration.general_battle_config)
             # 小怪 战
             if self.appear_then_click(self.I_NORMAL_BATTLE_BUTTON):
+                time.sleep(0.5)
                 self.screenshot()
-                if self.appear_then_click(self.I_NORMAL_BATTLE_BUTTON):
-                    self.run_general_battle(self.config.exploration.general_battle_config)
-                else:
-                    self.run_general_battle(self.config.exploration.general_battle_config)
+                if self.appear(self.I_NORMAL_BATTLE_BUTTON):
+                    continue
+                self.run_general_battle(self.config.exploration.general_battle_config)
                 self.screenshot()
-                while self.appear(self.I_BATTLE_REWARD):
-                    self.screenshot()
-                    self.appear_then_click(self.I_BATTLE_REWARD)
-                    self.screenshot()
-            else:
+            elif self.appear(self.I_E_AUTO_ROTATE_ON) and not self.appear(self.I_BATTLE_REWARD):
                 self.swipe(self.S_SWIPE_BACKGROUND_RIGHT)
+            # 结束流程
+            if self.appear(self.I_E_EXPLORATION_CLICK) or self.appear(self.I_EXPLORATION_TITLE):
+                break
 
     # 战斗流程
     def battle_process(self):

+ 3 - 3
tasks/GameUi/assets.py

@@ -37,9 +37,9 @@ class GameUiAssets:
 	# description 
 	I_CHECK_EXPLORATION = RuleImage(roi_front=(1146,175,21,22), roi_back=(1146,175,21,22), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_exploration.png")
 	# description 
-	I_EXPLORATION_GOTO_AWAKE_ZONE = RuleImage(roi_front=(50,637,57,61), roi_back=(50,637,57,61), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_awake_zone.png")
+	I_EXPLORATION_GOTO_AWAKE_ZONE = RuleImage(roi_front=(57,628,57,61), roi_back=(33,619,113,79), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_awake_zone.png")
 	# description 
-	I_EXPLORATION_GOTO_SOUL_ZONE = RuleImage(roi_front=(151,637,55,55), roi_back=(151,637,55,55), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_soul_zone.png")
+	I_EXPLORATION_GOTO_SOUL_ZONE = RuleImage(roi_front=(159,633,55,55), roi_back=(138,620,89,75), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_soul_zone.png")
 	# description 
 	I_EXPLORATION_GOTO_REALM_RAID = RuleImage(roi_front=(248,636,67,48), roi_back=(229,612,102,87), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_realm_raid.png")
 	# 前往御灵 
@@ -129,7 +129,7 @@ class GameUiAssets:
 	# description 
 	I_MAIN_GOTO_DAILY = RuleImage(roi_front=(778,612,52,54), roi_back=(759,595,84,84), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_daily.png")
 	# description 
-	I_MAIN_GOTO_MALL = RuleImage(roi_front=(657,624,47,52), roi_back=(657,624,47,52), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_mall.png")
+	I_MAIN_GOTO_MALL = RuleImage(roi_front=(663,661,41,22), roi_back=(644,613,81,78), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_mall.png")
 	# description 
 	I_MAIN_GOTO_GUILD = RuleImage(roi_front=(540,611,50,54), roi_back=(540,611,50,54), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_guild.png")
 	# description 

+ 4 - 4
tasks/GameUi/page/page_img.json

@@ -29,8 +29,8 @@
   {
     "itemName": "exploration_goto_awake_zone",
     "imageName": "page_exploration_goto_awake_zone.png",
-    "roiFront": "50,637,57,61",
-    "roiBack": "50,637,57,61",
+    "roiFront": "57,628,57,61",
+    "roiBack": "33,619,113,79",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -38,8 +38,8 @@
   {
     "itemName": "exploration_goto_soul_zone",
     "imageName": "page_exploration_goto_soul_zone.png",
-    "roiFront": "151,637,55,55",
-    "roiBack": "151,637,55,55",
+    "roiFront": "159,633,55,55",
+    "roiBack": "138,620,89,75",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

+ 3 - 3
tasks/GameUi/page/page_img_3.json

@@ -38,10 +38,10 @@
   {
     "itemName": "main_goto_mall",
     "imageName": "page_main_goto_mall.png",
-    "roiFront": "657,624,47,52",
-    "roiBack": "657,624,47,52",
+    "roiFront": "663,661,41,22",
+    "roiBack": "644,613,81,78",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "description"
   },
   {

TEMPAT SAMPAH
tasks/GameUi/page/page_main_goto_mall.png


+ 12 - 0
tasks/Hyakkiyakou/assets.py

@@ -0,0 +1,12 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+from module.atom.ocr import RuleOcr
+from module.atom.list import RuleList
+
+# This file was automatically generated by ./dev_tools/assets_extract.py.
+# Don't modify it manually.
+class HyakkiyakouAssets: 
+	pass
+

TEMPAT SAMPAH
tasks/MysteryShop/ms/ms_ms_share.png


+ 2 - 2
tasks/MysteryShop/script_task.py

@@ -230,6 +230,6 @@ if __name__ == '__main__':
     t = ScriptTask(c, d)
     t.screenshot()
 
-    t.run_shop(t.config.mystery_shop.shop_config)
-    # t.shop_reward()
+    # t.run_shop(t.config.mystery_shop.shop_config)
+    t.run()
 

+ 3 - 3
tasks/RichMan/assets.py

@@ -318,11 +318,11 @@ class RichManAssets:
 	# description 
 	I_S_BUY_WHITE_FOUR = RuleImage(roi_front=(779,507,173,64), roi_back=(779,507,173,64), threshold=0.8, method="Template matching", file="./tasks/RichMan/shrine/shrine_s_buy_white_four.png")
 	# description 
-	I_S_CONFIRM_WHITE_FIVE = RuleImage(roi_front=(554,438,174,61), roi_back=(554,438,174,61), threshold=0.8, method="Template matching", file="./tasks/RichMan/shrine/shrine_s_confirm_white_five.png")
+	I_S_CONFIRM_WHITE_FIVE = RuleImage(roi_front=(554,522,174,61), roi_back=(520,416,220,193), threshold=0.8, method="Template matching", file="./tasks/RichMan/shrine/shrine_s_confirm_white_five.png")
 	# description 
-	I_S_CONFIRM_WHITE_FOUR = RuleImage(roi_front=(552,509,176,62), roi_back=(552,509,176,62), threshold=0.8, method="Template matching", file="./tasks/RichMan/shrine/shrine_s_confirm_white_four.png")
+	I_S_CONFIRM_WHITE_FOUR = RuleImage(roi_front=(548,486,176,62), roi_back=(509,404,252,231), threshold=0.8, method="Template matching", file="./tasks/RichMan/shrine/shrine_s_confirm_white_four.png")
 	# description 
-	I_S_CONFIRM_BLACK = RuleImage(roi_front=(552,439,180,62), roi_back=(552,439,180,62), threshold=0.8, method="Template matching", file="./tasks/RichMan/shrine/shrine_s_confirm_black.png")
+	I_S_CONFIRM_BLACK = RuleImage(roi_front=(547,496,180,62), roi_back=(532,426,214,184), threshold=0.8, method="Template matching", file="./tasks/RichMan/shrine/shrine_s_confirm_black.png")
 	# description 
 	I_S_BUY_UP = RuleImage(roi_front=(762,412,56,54), roi_back=(762,412,56,54), threshold=0.8, method="Template matching", file="./tasks/RichMan/shrine/shrine_s_buy_up.png")
 	# description 

+ 6 - 6
tasks/RichMan/shrine/image.json

@@ -65,8 +65,8 @@
   {
     "itemName": "s_confirm_white_five",
     "imageName": "shrine_s_confirm_white_five.png",
-    "roiFront": "554,438,174,61",
-    "roiBack": "554,438,174,61",
+    "roiFront": "554,522,174,61",
+    "roiBack": "520,416,220,193",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -74,8 +74,8 @@
   {
     "itemName": "s_confirm_white_four",
     "imageName": "shrine_s_confirm_white_four.png",
-    "roiFront": "552,509,176,62",
-    "roiBack": "552,509,176,62",
+    "roiFront": "548,486,176,62",
+    "roiBack": "509,404,252,231",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -83,8 +83,8 @@
   {
     "itemName": "s_confirm_black",
     "imageName": "shrine_s_confirm_black.png",
-    "roiFront": "552,439,180,62",
-    "roiBack": "552,439,180,62",
+    "roiFront": "547,496,180,62",
+    "roiBack": "532,426,214,184",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

+ 3 - 3
tasks/Script/config_device.py

@@ -32,14 +32,14 @@ class ControlMethod(str, Enum):
 class Device(BaseModel):
     serial: str = Field(default="auto",
                         description='serial_help')
-    handle: str = Field(default='auto',
+    handle: str = Field(default='',
                         description='handle_help')
     package_name: PackageName = Field(title='Package Name',
                                       default=PackageName.AUTO,
                                       description='package_name_help')
-    screenshot_method: ScreenshotMethod = Field(default=ScreenshotMethod.WINDOW_BACKGROUND,
+    screenshot_method: ScreenshotMethod = Field(default=ScreenshotMethod.AUTO,
                                                 description='screenshot_method_help')
-    control_method: ControlMethod = Field(default=ControlMethod.WINDOW_MESSAGE,
+    control_method: ControlMethod = Field(default=ControlMethod.MINITOUCH,
                                           description='control_method_help')
     adb_restart: bool = Field(default=False,
                               description='adb_restart_help')

+ 1 - 1
tasks/Secret/script_task.py

@@ -178,7 +178,7 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
             if jade_num < 7:
                 # 第一个的时候可能是没有检测到
                 gold_number = self.O_SE_GOLD.ocr(self.device.image)
-                if isinstance(gold_number, int) and gold_number == 10000:
+                if isinstance(gold_number, int) and (gold_number == 10000 or gold_number == 18000):
                     logger.info(f'No find jade number, but find gold number {gold_number}')
                     return 1
                 return None