Skip to content

Commit

Permalink
尝试修复自动作战无法识别退出+修复信用作战界面不进行任务失败识别导致的循环任务 (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyn101 authored Jul 10, 2024
1 parent 56c501d commit ae50a57
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Binary file added arknights_mower/resources/fight/failed_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 15 additions & 2 deletions arknights_mower/solvers/auto_fight.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def in_fight(self) -> bool:
tpl = loadres("fight/enemy", True)
result = cv2.matchTemplate(img, tpl, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
logger.debug(min_val)
logger.debug(f"是否在战斗:{min_val}")
return min_val < 0.4

def battle_complete(self) -> bool:
Expand All @@ -123,8 +123,18 @@ def battle_complete(self) -> bool:
tpl = loadres("fight/complete", True)
result = cv2.matchTemplate(img, tpl, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
logger.debug(f"行动结束:{min_val}")
return min_val < 0.4

def battle_fail(self) -> bool:
"识别行动是否失败"
img = cropimg(self.recog.gray, ((1129, 455), (1626, 531)))
tpl = loadres("fight/failed_text", True)
result = cv2.matchTemplate(img, tpl, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
logger.debug(f"行动失败:{min_val}")
return min_val < 0.05 # 测试时数值很低,基本为0,或有其他方法

def update_operators(self):
"识别可部署的干员"
self.recog.update()
Expand Down Expand Up @@ -277,7 +287,10 @@ def transition(self):
self.recog.update()

if not self.in_fight():
if self.battle_complete():
if self.battle_fail():
logger.info("行动失败,请检查干员/练度")
return True
elif self.battle_complete():
logger.info("行动结束")
return True
else:
Expand Down
3 changes: 3 additions & 0 deletions arknights_mower/solvers/credit_fight.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def transition(self):
self.tap_element("fight/use")
elif scene == Scene.OPERATOR_FINISH:
return True
elif scene == Scene.OPERATOR_FAILED:
logger.info("OF-1失败,请检查干员,*今天*不会继续进行信用作战")
return True
elif scene in self.waiting_scene:
self.waiting_solver()
else:
Expand Down

0 comments on commit ae50a57

Please sign in to comment.