Ver Fonte

feat(SixRealms): Add boss battle

huangrunheng há 2 anos atrás
pai
commit
252640d49c

+ 1 - 0
module/device/device.py

@@ -110,6 +110,7 @@ class Device(Screenshot, Control, AppControl, EmulatorManager):
         :return:
         """
         self.detect_record.add(str(button))
+        logger.info(f'Add stuck record: {button}')
 
     def stuck_record_clear(self):
         self.detect_record = set()

+ 22 - 1
tasks/SixRealms/assets.py

@@ -10,6 +10,25 @@ from module.atom.list import RuleList
 class SixRealmsAssets: 
 
 
+	# Image Rule Assets
+	# 大boss挑战 
+	I_BOSS_FIRE = RuleImage(roi_front=(1128,576,100,100), roi_back=(1091,557,156,147), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_fire.png")
+	# description 
+	I_BOSS_TEAM_LOCK = RuleImage(roi_front=(1139,493,21,21), roi_back=(1130,487,38,43), threshold=0.95, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_team_lock.png")
+	# description 
+	I_BOSS_TEAM_UNLOCK = RuleImage(roi_front=(1138,497,22,21), roi_back=(1127,491,40,41), threshold=0.95, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_team_unlock.png")
+	# description 
+	I_BOSS_SKIP = RuleImage(roi_front=(1131,13,100,42), roi_back=(1113,5,136,62), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_skip.png")
+	# description 
+	I_BOSS_USE_DOUBLE = RuleImage(roi_front=(669,417,126,53), roi_back=(651,407,164,71), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_use_double.png")
+	# 御神获得经验 
+	I_BOSS_GET_EXP = RuleImage(roi_front=(561,109,171,45), roi_back=(492,86,281,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_get_exp.png")
+	# description 
+	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=(535,241,240,330), roi_back=(500,216,292,377), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_boss_shutu.png")
+
+
 	# Click Rule Assets
 	# 左边的 
 	C_NPC_FIRE_LEFT = RuleClick(roi_front=(423,203,153,193), roi_back=(423,203,153,193), name="npc_fire_left")
@@ -48,6 +67,8 @@ class SixRealmsAssets:
 	I_M_STORE = RuleImage(roi_front=(1124,594,61,57), roi_back=(1103,576,100,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_m_store.png")
 	# 左上角退出 
 	I_BACK_EXIT = RuleImage(roi_front=(11,18,51,47), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_back_exit.png")
+	# 可以购买的幻息 
+	I_M_STORE_ACTIVITY = RuleImage(roi_front=(1121,596,72,57), roi_back=(1107,573,100,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_m_store_activity.png")
 
 
 	# Ocr Rule Assets
@@ -63,7 +84,7 @@ class SixRealmsAssets:
 	# 柔风 
 	I_SKILL101 = RuleImage(roi_front=(440,181,100,69), roi_back=(139,167,722,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_skill101.png")
 	# description 
-	I_SKILL102 = RuleImage(roi_front=(0,0,100,100), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_skill102.png")
+	I_SKILL102 = RuleImage(roi_front=(456,186,76,63), roi_back=(136,151,709,128), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_skill102.png")
 	# description 
 	I_SKILL103 = RuleImage(roi_front=(0,0,100,100), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/SixRealms/gate1/gate1_skill103.png")
 	# description 

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

@@ -0,0 +1,74 @@
+[
+  {
+    "itemName": "boss_fire",
+    "imageName": "gate1_boss_fire.png",
+    "roiFront": "1128,576,100,100",
+    "roiBack": "1091,557,156,147",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "大boss挑战"
+  },
+  {
+    "itemName": "boss_team_lock",
+    "imageName": "gate1_boss_team_lock.png",
+    "roiFront": "1139,493,21,21",
+    "roiBack": "1130,487,38,43",
+    "method": "Template matching",
+    "threshold": 0.95,
+    "description": "description"
+  },
+  {
+    "itemName": "boss_team_unlock",
+    "imageName": "gate1_boss_team_unlock.png",
+    "roiFront": "1138,497,22,21",
+    "roiBack": "1127,491,40,41",
+    "method": "Template matching",
+    "threshold": 0.95,
+    "description": "description"
+  },
+  {
+    "itemName": "boss_skip",
+    "imageName": "gate1_boss_skip.png",
+    "roiFront": "1131,13,100,42",
+    "roiBack": "1113,5,136,62",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "boss_use_double",
+    "imageName": "gate1_boss_use_double.png",
+    "roiFront": "669,417,126,53",
+    "roiBack": "651,407,164,71",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "boss_get_exp",
+    "imageName": "gate1_boss_get_exp.png",
+    "roiFront": "561,109,171,45",
+    "roiBack": "492,86,281,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "御神获得经验"
+  },
+  {
+    "itemName": "boss_share",
+    "imageName": "gate1_boss_share.png",
+    "roiFront": "1090,604,70,74",
+    "roiBack": "1074,587,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "boss_shutu",
+    "imageName": "gate1_boss_shutu.png",
+    "roiFront": "535,241,240,330",
+    "roiBack": "500,216,292,377",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "结算的椒图"
+  }
+]

BIN
tasks/SixRealms/gate1/gate1_boss_fire.png


BIN
tasks/SixRealms/gate1/gate1_boss_get_exp.png


BIN
tasks/SixRealms/gate1/gate1_boss_share.png


BIN
tasks/SixRealms/gate1/gate1_boss_shutu.png


BIN
tasks/SixRealms/gate1/gate1_boss_skip.png


BIN
tasks/SixRealms/gate1/gate1_boss_team_lock.png


BIN
tasks/SixRealms/gate1/gate1_boss_team_unlock.png


BIN
tasks/SixRealms/gate1/gate1_boss_use_double.png


BIN
tasks/SixRealms/gate1/gate1_m_store_activity.png


BIN
tasks/SixRealms/gate1/gate1_skill101.png


BIN
tasks/SixRealms/gate1/gate1_skill102.png


+ 9 - 0
tasks/SixRealms/gate1/image.json

@@ -124,5 +124,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "左上角退出"
+  },
+  {
+    "itemName": "m_store_activity",
+    "imageName": "gate1_m_store_activity.png",
+    "roiFront": "1121,596,72,57",
+    "roiBack": "1107,573,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "可以购买的幻息"
   }
 ]

+ 2 - 2
tasks/SixRealms/gate1/skills.json

@@ -11,8 +11,8 @@
   {
     "itemName": "skill102",
     "imageName": "gate1_skill102.png",
-    "roiFront": "0,0,100,100",
-    "roiBack": "0,0,100,100",
+    "roiFront": "456,186,76,63",
+    "roiBack": "136,151,709,128",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

+ 14 - 2
tasks/SixRealms/moon_sea/l102.py

@@ -11,10 +11,10 @@ class MoonSeaL102(MoonSeaSkills):
         while 1:
             self.screenshot()
             if self.appear(self.I_COIN_RIGHT_TOP):
-                is_imitation = True
+                is_imitation = False
                 break
             if self.appear(self.I_IMITATE):
-                is_imitation = False
+                is_imitation = True
                 break
         if not is_imitation:
             logger.info('Transfer skill')
@@ -51,3 +51,15 @@ class MoonSeaL102(MoonSeaSkills):
             if self.appear_then_click(self.I_IMITATE, interval=2.5):
                 continue
         logger.info('Finish Imitate')
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+
+    c = Config('oas1')
+    d = Device(c)
+    t = MoonSeaL102(c, d)
+    t.screenshot()
+
+    t.run_l102()

+ 1 - 2
tasks/SixRealms/moon_sea/l103.py

@@ -50,5 +50,4 @@ if __name__ == '__main__':
     t = MoonSeaL103(c, d)
     t.screenshot()
 
-    # t.run_103()
-    t.island_battle()
+    t.run_103()

+ 9 - 0
tasks/SixRealms/moon_sea/l104.py

@@ -19,5 +19,14 @@ class MoonSeaL104(MoonSeaSkills):
         self.select_skill()
 
 
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
 
+    c = Config('oas1')
+    d = Device(c)
+    t = MoonSeaL104(c, d)
+    t.screenshot()
+
+    t.run_l104()
 

+ 36 - 1
tasks/SixRealms/moon_sea/moon_sea.py

@@ -71,6 +71,40 @@ class MoonSea(MoonSeaMap, MoonSeaL101, MoonSeaL102, MoonSeaL103, MoonSeaL104):
             if '宁息' in text:
                 return MoonSeaType.island101
 
+    def boss_team_lock(self):
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_BOSS_TEAM_LOCK):
+                break
+            if self.appear_then_click(self.I_BOSS_TEAM_UNLOCK, interval=2):
+                logger.info('Click lock Boss Team')
+                continue
+
+    def boss_battle(self):
+        logger.hr('Boss Battle')
+        self.ui_click_until_disappear(self.I_BOSS_FIRE, interval=1)
+        self.device.stuck_record_clear()
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_BOSS_SHARE):
+                break
+
+            if self.appear(self.I_BOSS_USE_DOUBLE, interval=1):
+                # 双倍奖励
+                logger.info('Double reward')
+                self.ui_get_reward(self.I_BOSS_USE_DOUBLE)
+            if self.appear_then_click(self.I_BOSS_GET_EXP, interval=1):
+                logger.info('Get EXP')
+                continue
+            if self.appear_then_click(self.I_BOSS_SKIP, interval=1):
+                # 第二个boss
+                self.device.stuck_record_clear()
+                self.device.stuck_record_add('BATTLE_STATUS_S')
+                continue
+        logger.info('Boss battle end')
+        self.ui_click(self.I_BOSS_SHUTU, stop=self.I_MSTART)
+
 
 if __name__ == '__main__':
     from module.config.config import Config
@@ -81,4 +115,5 @@ if __name__ == '__main__':
     t = MoonSea(c, d)
     t.screenshot()
 
-    t.run_moon_sea()
+    # t.run_moon_sea()
+    t.boss_team_lock()

+ 13 - 6
tasks/SixRealms/moon_sea/skills.py

@@ -11,7 +11,13 @@ class MoonSeaSkills(BaseTask, SixRealmsAssets):
     def in_main(self, screenshot: bool = False):
         if screenshot:
             self.screenshot()
-        return self.appear(self.I_M_STORE)
+        if self.appear(self.I_M_STORE):
+            return True
+        if self.appear(self.I_M_STORE_ACTIVITY):
+            return True
+        if self.appear(self.I_BOSS_FIRE):
+            return True
+        return False
 
     def battle_lock_team(self):
         self.ui_click(self.I_BATTLE_TEAM_UNLOCK, self.I_BATTLE_TEAM_LOCK)
@@ -20,7 +26,6 @@ class MoonSeaSkills(BaseTask, SixRealmsAssets):
     def island_battle(self):
         # 小怪战斗
         self.screenshot()
-        self.device.stuck_record_add('LOGIN_CHECK')
         while 1:
             self.screenshot()
             if self.appear(self.I_SKILL_REFRESH):
@@ -28,6 +33,8 @@ class MoonSeaSkills(BaseTask, SixRealmsAssets):
             if self.appear(self.I_COIN):
                 break
             if self.appear_then_click(self.I_NPC_FIRE, interval=1):
+                self.device.stuck_record_clear()
+                self.device.stuck_record_add('BATTLE_STATUS_S')
                 continue
         self.device.stuck_record_clear()
 
@@ -48,10 +55,10 @@ class MoonSeaSkills(BaseTask, SixRealmsAssets):
             button = self.I_SKILL101
         elif button is None and self.appear(self.I_SKILL102):
             button = self.I_SKILL102
-        elif button is None and self.appear(self.I_SKILL103):
-            button = self.I_SKILL103
-        elif button is None and self.appear(self.I_SKILL104):
-            button = self.I_SKILL104
+        # elif button is None and self.appear(self.I_SKILL103):
+        #     button = self.I_SKILL103
+        # elif button is None and self.appear(self.I_SKILL104):
+        #     button = self.I_SKILL104
         if button is not None:
             x, y = button.front_center()
             if x < 360: