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

fix(task): Cannot challenge the boss when the number of people is full in DemonEncounter task

runhey 3 лет назад
Родитель
Сommit
b285079426

+ 5 - 0
tasks/DemonEncounter/assets.py

@@ -44,6 +44,11 @@ class DemonEncounterAssets:
 	I_BOSS_BACK_WHITE = RuleImage(roi_front=(16,12,39,40), roi_back=(16,12,39,40), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/boss/boss_boss_back_white.png")
 
 
+	# Ocr Rule Assets
+	# 人数 
+	O_DE_BOSS_PEOPLE = RuleOcr(roi=(880,591,100,35), area=(880,591,100,35), mode="DigitCounter", method="Default", keyword="", name="de_boss_people")
+
+
 	# Click Rule Assets
 	# 从下开始数第一个 
 	C_DE_1 = RuleClick(roi_front=(1211,478,61,58), roi_back=(1211,478,61,58), name="de_1")

+ 11 - 0
tasks/DemonEncounter/boss/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "de_boss_people",
+    "roiFront": "880,591,100,35",
+    "roiBack": "880,591,100,35",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "人数"
+  }
+]

+ 13 - 1
tasks/DemonEncounter/script_task.py

@@ -47,7 +47,19 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
         while 1:
             self.screenshot()
             if self.appear(self.I_BOSS_FIRE):
-                break
+                current, remain, total = self.O_DE_BOSS_PEOPLE.ocr(self.device.image)
+                if total == 300 and current >= 290:
+                    logger.info('Boss battle people is full')
+                    if not self.appear(self.I_UI_BACK_RED):
+                        logger.warning('Boss battle people is full but no red back')
+                        continue
+                    self.ui_click_until_disappear(self.I_UI_BACK_RED)
+                    # 退出重新选一个没人慢的boss
+                    logger.info('Exit and reselect')
+                    continue
+                else:
+                    logger.info('Boss battle people is not full')
+                    break
 
             if self.appear_then_click(self.I_BOSS_NAMAZU, interval=1):
                 continue