Skip to content

Commit

Permalink
fix:编队内无干员时停止打OF-1关卡避免无限循环 (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyn101 authored Jul 25, 2024
1 parent 1f4f28d commit f4232ea
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion arknights_mower/data/scene.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,4 +555,4 @@
"label": "CONFIRM",
"comment": "确认对话框"
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions arknights_mower/solvers/auto_fight.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ 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(f"是否在战斗:{min_val}")
return min_val < 0.4
value = 0.4
logger.debug(f"{min_val}小于{value}则判定在战斗")
return min_val < value

def battle_complete(self) -> bool:
"识别行动是否结束"
Expand All @@ -117,17 +118,19 @@ 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
value = 0.4
logger.debug(f"{min_val}小于{value}则判定行动结束/胜利")
return min_val < value

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,或有其他方法
value = 0.05
logger.debug(f"{min_val}小于{value}则判定行动失败")
return min_val < value # 测试时数值很低,基本为0,或有其他方法

def update_operators(self):
"识别可部署的干员"
Expand Down Expand Up @@ -282,7 +285,7 @@ def transition(self):

if not self.in_fight():
if self.battle_fail():
logger.info("行动失败,请检查干员/练度")
logger.warning("行动失败,请检查干员/练度")
return True
elif self.battle_complete():
logger.info("行动结束")
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 @@ -58,6 +58,9 @@ def transition(self):
return
self.tap_element("ope_start", interval=2)
elif scene == Scene.OPERATOR_SELECT:
if self.find("ope_select_start_empty"):
logger.info("编队内没有编入干员,停止OF-1")
return True
squad = self.current_squad()
target = config.conf.credit_fight.squad
if squad != target:
Expand Down
1 change: 1 addition & 0 deletions arknights_mower/utils/recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ def find(
"ope_failed": (183, 465),
"ope_finish": (87, 265),
"ope_plan": (1278, 24),
"ope_select_start_empty": ((0, 0), (400, 400)),
"riic/assistants": ((1320, 400), (1600, 650)),
"riic/iron": ((1570, 230), (1630, 340)),
"riic/orundum": ((1500, 320), (1800, 550)),
Expand Down

0 comments on commit f4232ea

Please sign in to comment.