Преглед на файлове

feat(FallenSun): Add "日蚀" #1013

ryland преди 1 година
родител
ревизия
b320208739
променени са 6 файла, в които са добавени 73 реда и са изтрити 30 реда
  1. 3 1
      tasks/Duel/assets.py
  2. 2 2
      tasks/FallenSun/assets.py
  3. 3 0
      tasks/FallenSun/config.py
  4. 6 2
      tasks/FallenSun/res/list.json
  5. 58 23
      tasks/FallenSun/script_task.py
  6. 1 2
      tasks/Orochi/script_task.py

+ 3 - 1
tasks/Duel/assets.py

@@ -88,9 +88,10 @@ class DuelAssets:
 	I_D_BATTLE2 = RuleImage(roi_front=(1171,592,69,78), roi_back=(1119,566,154,143), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle2.png")
 	I_D_BATTLE2 = RuleImage(roi_front=(1171,592,69,78), roi_back=(1119,566,154,143), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle2.png")
 	# 禁用 
 	# 禁用 
 	I_BAN = RuleImage(roi_front=(1112,537,100,100), roi_back=(1112,537,100,100), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_ban.png")
 	I_BAN = RuleImage(roi_front=(1112,537,100,100), roi_back=(1112,537,100,100), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_ban.png")
-	# 左上角的退出
+	# 左上角的退出 
 	I_DUEL_EXIT = RuleImage(roi_front=(14,12,43,41), roi_back=(14,12,43,41), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/gb_exit.png")
 	I_DUEL_EXIT = RuleImage(roi_front=(14,12,43,41), roi_back=(14,12,43,41), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/gb_exit.png")
 
 
+
 	# Ocr Rule Assets
 	# Ocr Rule Assets
 	# 荣誉 
 	# 荣誉 
 	O_D_HONOR = RuleOcr(roi=(699,562,131,31), area=(699,562,131,31), mode="DigitCounter", method="Default", keyword="", name="d_honor")
 	O_D_HONOR = RuleOcr(roi=(699,562,131,31), area=(699,562,131,31), mode="DigitCounter", method="Default", keyword="", name="d_honor")
@@ -105,3 +106,4 @@ class DuelAssets:
 	# 被办式神名称 
 	# 被办式神名称 
 	O_D_BAN_NAME = RuleOcr(roi=(92,97,82,25), area=(92,97,82,25), mode="Single", method="Default", keyword="", name="d_ban_name")
 	O_D_BAN_NAME = RuleOcr(roi=(92,97,82,25), area=(92,97,82,25), mode="Single", method="Default", keyword="", name="d_ban_name")
 
 
+

+ 2 - 2
tasks/FallenSun/assets.py

@@ -27,8 +27,8 @@ class FallenSunAssets:
 
 
 	# List Rule Assets
 	# List Rule Assets
 	# 这个是御魂界面选择不同层数的 
 	# 这个是御魂界面选择不同层数的 
-	L_LAYER_LIST = RuleList(folder="./tasks/FallenSun/res", direction="vertical", mode="ocr", roi_back=(138,130,359,500), size=(40, 93), 
-					 array=["壹", "贰", "叁"])
+	L_LAYER_LIST = RuleList(folder="./tasks/FallenSun/res", direction="vertical", mode="ocr", roi_back=(138,130,359,500), size=(43, 87), 
+					 array=["壹", "贰", "叁", "日"])
 
 
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets

+ 3 - 0
tasks/FallenSun/config.py

@@ -18,10 +18,13 @@ class UserStatus(str, Enum):
     ALONE = 'alone'
     ALONE = 'alone'
     WILD = 'wild'  # 还不打算实现
     WILD = 'wild'  # 还不打算实现
 
 
+
 class Layer(str, Enum):
 class Layer(str, Enum):
     ONE = '壹层'
     ONE = '壹层'
     TWO = '贰层'
     TWO = '贰层'
     THREE = '叁层'
     THREE = '叁层'
+    FOUR = '日蚀'
+
 
 
 class FallenSunConfig(ConfigBase):
 class FallenSunConfig(ConfigBase):
     # 身份
     # 身份

+ 6 - 2
tasks/FallenSun/res/list.json

@@ -11,11 +11,15 @@
     },
     },
     {
     {
       "itemName": "贰",
       "itemName": "贰",
-      "roiFront": "283,293,39,85"
+      "roiFront": "283,254,39,85"
     },
     },
     {
     {
       "itemName": "叁",
       "itemName": "叁",
-      "roiFront": "281,439,43,93"
+      "roiFront": "282,360,43,93"
+    },
+    {
+      "itemName": "日",
+      "roiFront": "271,473,54,69"
     }
     }
   ]
   ]
 }
 }

+ 58 - 23
tasks/FallenSun/script_task.py

@@ -1,6 +1,7 @@
 # This Python file uses the following encoding: utf-8
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
+import random
 from time import sleep
 from time import sleep
 from datetime import time, datetime, timedelta
 from datetime import time, datetime, timedelta
 
 
@@ -58,8 +59,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
 
         raise TaskEnd
         raise TaskEnd
 
 
-
-
     def fallen_sun_enter(self) -> bool:
     def fallen_sun_enter(self) -> bool:
         logger.info('Enter fallen_sun')
         logger.info('Enter fallen_sun')
         while True:
         while True:
@@ -101,7 +100,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
                 if self.appear_then_click(self.I_FALLEN_SUN_LOCK, interval=1):
                 if self.appear_then_click(self.I_FALLEN_SUN_LOCK, interval=1):
                     continue
                     continue
 
 
-
     def run_leader(self):
     def run_leader(self):
         logger.info('Start run leader')
         logger.info('Start run leader')
         self.ui_get_current_page()
         self.ui_get_current_page()
@@ -148,8 +146,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
                     logger.info('FallenSun time limit out')
                     logger.info('FallenSun time limit out')
                     break
                     break
 
 
-
-
             # 如果没有进入房间那就不需要后面的邀请
             # 如果没有进入房间那就不需要后面的邀请
             if not self.is_in_room():
             if not self.is_in_room():
                 # 如果在探索界面或者是出现在组队界面, 那就是可能房间死了
                 # 如果在探索界面或者是出现在组队界面, 那就是可能房间死了
@@ -302,40 +298,79 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
         self.ui_current = page_soul_zones
         self.ui_current = page_soul_zones
         self.ui_goto(page_main)
         self.ui_goto(page_main)
 
 
-
-
     def run_wild(self):
     def run_wild(self):
         logger.error('Wild mode is not implemented')
         logger.error('Wild mode is not implemented')
         pass
         pass
 
 
+    def battle_wait(self, random_click_swipt_enable: bool) -> bool:
+        """
+        重写战斗等待
+        # https://github.com/runhey/OnmyojiAutoScript/issues/95
+        :param random_click_swipt_enable:
+        :return:
+        """
+        # 重写
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+        self.C_REWARD_1.name = 'C_REWARD'
+        self.C_REWARD_2.name = 'C_REWARD'
+        self.C_REWARD_3.name = 'C_REWARD'
+        # 战斗过程 随机点击和滑动 防封
+        logger.info("Start battle process")
+        while 1:
+            self.screenshot()
+            action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
+            if self.appear_then_click(self.I_WIN, action=action_click ,interval=0.8):
+                # 赢的那个鼓
+                continue
+            if self.appear(self.I_GREED_GHOST):
+                # 贪吃鬼
+                logger.info('Win battle')
+                self.wait_until_appear(self.I_REWARD, wait_time=1.5)
+                self.screenshot()
+                if not self.appear(self.I_GREED_GHOST):
+                    logger.warning('Greedy ghost disappear. Maybe it is a false battle')
+                    continue
+                while 1:
+                    self.screenshot()
+                    action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
+                    if not self.appear(self.I_GREED_GHOST):
+                        break
+                    if self.click(action_click, interval=1.5):
+                        continue
+                return True
+            if self.appear(self.I_REWARD):
+                # 魂
+                logger.info('Win battle')
+                while 1:
+                    self.screenshot()
+                    action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
+                    if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
+                        continue
+                    if not self.appear(self.I_REWARD):
+                        break
+                return True
 
 
+            if self.appear(self.I_FALSE):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
 
 
-
+            # 如果开启战斗过程随机滑动
+            if random_click_swipt_enable:
+                self.random_click_swipt()
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device
-    from memory_profiler import profile
     c = Config('oas1')
     c = Config('oas1')
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
 
 
-    # t.run()
-
-    # t.check_layer('悲')
-
-    from module.base.timer import timer
+    t.run()
+    # t.check_layer('日蚀')
 
 
-    @timer
-    @profile
-    def test_memory():
-        t.screenshot()
-        print(t.ocr_appear(t.O_O_TEST_OCR))
-        print(t.L_LAYER_LIST.image_appear(t.device.image, '叁'))
-    for i in range(4):
-        test_memory()
-        print('=====================')
 
 
 
 
 
 

+ 1 - 2
tasks/Orochi/script_task.py

@@ -17,6 +17,7 @@ from tasks.Orochi.config import Orochi, UserStatus, Layer
 from module.logger import logger
 from module.logger import logger
 from module.exception import TaskEnd
 from module.exception import TaskEnd
 
 
+
 class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi, SwitchSoul, OrochiAssets):
 class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi, SwitchSoul, OrochiAssets):
 
 
     def run(self) -> bool:
     def run(self) -> bool:
@@ -71,8 +72,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
 
         raise TaskEnd
         raise TaskEnd
 
 
-
-
     def orochi_enter(self) -> bool:
     def orochi_enter(self) -> bool:
         logger.info('Enter orochi')
         logger.info('Enter orochi')
         while True:
         while True: