Просмотр исходного кода

fix(SixRealms): A little problem

huangrunheng 2 лет назад
Родитель
Сommit
fb8f1514a3

+ 4 - 0
tasks/SixRealms/assets.py

@@ -34,6 +34,10 @@ class SixRealmsAssets:
 	I_BOSS_SHARE = RuleImage(roi_front=(1090,604,70,74), roi_back=(1074,587,100,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_share.png")
 	# 结算的椒图 
 	I_BOSS_SHUTU = RuleImage(roi_front=(435,46,388,46), roi_back=(338,1,573,166), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_shutu.png")
+	# description 
+	I_BOSS_BATTLE_AGAIN = RuleImage(roi_front=(435,403,173,64), roi_back=(409,390,212,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_battle_again.png")
+	# description 
+	I_BOSS_BATTLE_GIVEUP = RuleImage(roi_front=(671,399,175,59), roi_back=(649,381,219,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_battle_giveup.png")
 
 
 	# Click Rule Assets

+ 18 - 0
tasks/SixRealms/gate1/boss.json

@@ -70,5 +70,23 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "结算的椒图"
+  },
+  {
+    "itemName": "boss_battle_again",
+    "imageName": "gate1_boss_battle_again.png",
+    "roiFront": "435,403,173,64",
+    "roiBack": "409,390,212,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "boss_battle_giveup",
+    "imageName": "gate1_boss_battle_giveup.png",
+    "roiFront": "671,399,175,59",
+    "roiBack": "649,381,219,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
 ]

BIN
tasks/SixRealms/gate1/gate1_boss_battle_again.png


BIN
tasks/SixRealms/gate1/gate1_boss_battle_giveup.png


+ 3 - 3
tasks/SixRealms/moon_sea/l101.py

@@ -27,6 +27,7 @@ class MoonSeaL101(MoonSeaSkills):
         self.ui_click_until_disappear(self.I_UI_CONFIRM)
         self.wait_until_appear(self.I_STORE_EXIT)
         self.cnt_skill101 += 1
+        logger.info(f'Skill 101 level: {self.cnt_skill101}')
         logger.info('Buy skill 101 done')
         return True
 
@@ -49,9 +50,8 @@ class MoonSeaL101(MoonSeaSkills):
             if self.appear_then_click(self.I_STORE_REFRESH, interval=1.5):
                 cnt_refresh += 1
                 continue
-            if cnt_refresh >= 4:
-                logger.warning('Refresh store failed')
-                break
+            if cnt_refresh >= 1:
+                return False
         self.ui_click_until_disappear(self.I_UI_CONFIRM, interval=2)
         self.wait_until_appear(self.I_STORE_EXIT)
         logger.info('Refresh store done')

+ 3 - 1
tasks/SixRealms/moon_sea/l102.py

@@ -49,7 +49,7 @@ class MoonSeaL102(MoonSeaSkills):
                 continue
             if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
                 continue
-            if cnt_imitate >= 6:
+            if cnt_imitate >= 3:
                 logger.info('Finish Imitate Fail')
                 logger.info('The most possible reason is that the skill is max level')
                 while 1:
@@ -60,8 +60,10 @@ class MoonSeaL102(MoonSeaSkills):
                         continue
                 break
             if self.appear_then_click(self.I_IMITATE, interval=1):
+                cnt_imitate += 1
                 continue
         self.cnt_skill101 += 1
+        logger.info(f'Skill 101 level: {self.cnt_skill101}')
         logger.info('Finish Imitate')
 
 

+ 21 - 0
tasks/SixRealms/moon_sea/map.py

@@ -131,6 +131,27 @@ class MoonSeaMap(MoonSeaSkills):
                 cnt_act += 1
                 continue
 
+    def entry_island_random(self, area: list = None):
+        """
+
+        :param area: 搁置
+        :return:
+        """
+        # if not isinstance(area, list):
+        #     area = list(area)
+        logger.info('Entry island randomly')
+        while 1:
+            self.screenshot()
+            if not self.in_main() and self.appear(self.I_BACK_EXIT):
+                break
+            if self.click(self.C_ISLAND_ENTER_4, interval=2):
+                continue
+            if self.click(self.C_ISLAND_ENTER_5, interval=2):
+                continue
+            if self.click(self.C_ISLAND_ENTER_6, interval=2):
+                continue
+        return
+
 
 if __name__ == '__main__':
     from module.config.config import Config

+ 21 - 3
tasks/SixRealms/moon_sea/moon_sea.py

@@ -62,12 +62,21 @@ class MoonSea(MoonSeaMap, MoonSeaL101, MoonSeaL102, MoonSeaL103, MoonSeaL104, Mo
             # 如果前一个,召唤一次宁息
             if isl_num == 1 and isl_type != MoonSeaType.island106:
                 self.activate_store()
+                self.wait_animate_stable(self.C_MAIN_ANIMATE_KEEP, timeout=3)
                 isl_type, isl_num, isl_roi = self.decide()
+                # 文字检测不一定发现到宁息
+                if isl_type != MoonSeaType.island101:
+                    logger.warning('OCR not found island101')
+                    logger.warning('Try to entry the island in the right randomly order')
+                    self.entry_island_random()
+
             # 如果是boss
             if isl_type == MoonSeaType.island106:
                 self.boss_team_lock()
-                self.boss_battle()
-                break
+                if self.boss_battle():
+                    break
+                else:
+                    continue
 
             self.enter_island(isl_type=isl_type, isl_roi=isl_roi)
             isl_type = self.island_name()
@@ -165,7 +174,7 @@ class MoonSea(MoonSeaMap, MoonSeaL101, MoonSeaL102, MoonSeaL103, MoonSeaL104, Mo
                 logger.info('Click lock Boss Team')
                 continue
 
-    def boss_battle(self):
+    def boss_battle(self) -> bool:
         logger.hr('Boss Battle')
         self.ui_click_until_disappear(self.I_BOSS_FIRE, interval=1)
         self.device.stuck_record_clear()
@@ -174,6 +183,11 @@ class MoonSea(MoonSeaMap, MoonSeaL101, MoonSeaL102, MoonSeaL103, MoonSeaL104, Mo
             self.screenshot()
             if self.appear(self.I_BOSS_SHARE):
                 break
+            if self.appear(self.I_BOSS_BATTLE_AGAIN):
+                # 打boss失败了重新挑战
+                logger.warning('Boss battle again')
+                self.ui_click_until_disappear(self.I_BOSS_BATTLE_AGAIN, interval=1)
+                return False
 
             if self.appear(self.I_BOSS_USE_DOUBLE, interval=1):
                 # 双倍奖励
@@ -184,6 +198,9 @@ class MoonSea(MoonSeaMap, MoonSeaL101, MoonSeaL102, MoonSeaL103, MoonSeaL104, Mo
             if self.appear_then_click(self.I_BOSS_GET_EXP, interval=1):
                 logger.info('Get EXP')
                 continue
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                # 取消购买 万相赐福
+                continue
             if self.appear_then_click(self.I_BOSS_SKIP, interval=1):
                 # 第二个boss
                 self.device.stuck_record_clear()
@@ -191,6 +208,7 @@ class MoonSea(MoonSeaMap, MoonSeaL101, MoonSeaL102, MoonSeaL103, MoonSeaL104, Mo
                 continue
         logger.info('Boss battle end')
         self.ui_click(self.I_BOSS_SHUTU, stop=self.I_MSTART)
+        return True
 
 
 if __name__ == '__main__':

+ 2 - 3
tasks/SixRealms/moon_sea/skills.py

@@ -58,6 +58,7 @@ class MoonSeaSkills(BaseTask, SixRealmsAssets):
         # 只选柔风
         if button is None and self.appear(self.I_SKILL101):
             self.cnt_skill101 += 1
+            logger.info(f'Skill 101 level: {self.cnt_skill101}')
             button = self.I_SKILL101
         # elif button is None and self.appear(self.I_SKILL102):
         #     button = self.I_SKILL102
@@ -87,11 +88,9 @@ class MoonSeaSkills(BaseTask, SixRealmsAssets):
             if self.in_main():
                 break
 
-            if self.appear(self.I_SKILL_REFRESH):
+            if self.appear(self.I_SKILL_REFRESH) and self.appear(self.I_SELECT_3):
                 select = self._select_skill()
                 if self.appear_then_click(self.selects_button[select]):
-                    time.sleep(2)
-                    # TODO 两次选的间隔太短就直接跳过了,或者说动画没有显示中间的就跳过了
                     continue
             if self.appear_then_click(self.I_COIN, action=self.C_UI_REWARD, interval=1.5):
                 continue