From 3723f19685bb46104dd055ec25b2fb02dff7b564 Mon Sep 17 00:00:00 2001 From: EightyDollars Date: Sun, 15 Oct 2023 22:56:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E6=97=A0=E6=8B=9B=E5=8B=9F=E5=88=B8?= =?UTF-8?q?=E5=92=8C=E5=88=B7=E6=96=B0=E6=AC=A1=E6=95=B0=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E5=85=AC=E6=8B=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/recruit.py | 50 +++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/arknights_mower/solvers/recruit.py b/arknights_mower/solvers/recruit.py index 7b1ae239f..7d401d395 100644 --- a/arknights_mower/solvers/recruit.py +++ b/arknights_mower/solvers/recruit.py @@ -33,6 +33,15 @@ def __init__(self, device: Device = None, recog: Recognizer = None) -> None: self.recruit_pos = -1 + self.priority = None + self.recruiting = 0 + self.has_ticket = True # 默认含有招募票 + self.can_refresh = True # 默认可以刷新 + self.send_message_config = None + self.permit_count = None + self.can_refresh = None + self.enough_lmb = True + def run(self, priority: list[str] = None, send_message_config={}, recruit_config={}): """ :param priority: list[str], 优先考虑的公招干员,默认为高稀有度优先 @@ -40,10 +49,8 @@ def run(self, priority: list[str] = None, send_message_config={}, recruit_config self.priority = priority self.recruiting = 0 self.has_ticket = True # 默认含有招募票 - self.can_refresh = True # 默认可以刷新 self.send_message_config = send_message_config - self.permit_count = -1 - self.enough_lmb = True + self.permit_count = None # 调整公招参数 self.add_recruit_param(recruit_config) @@ -101,17 +108,40 @@ def transition(self) -> bool: elif self.scene() == Scene.RECRUIT_MAIN: segments = segment.recruit(self.recog.img) - recruit_main_img = self.recog.img[20:80, 1290:1400] + if self.can_refresh is None: + refresh_img = self.recog.img[100:150, 1390:1440] + + refresh_gray = cv2.cvtColor(refresh_img, cv2.COLOR_BGR2GRAY) + refresh_binary = cv2.threshold(refresh_gray, 220, 255, cv2.THRESH_BINARY)[1] + refresh_res = rapidocr.engine(refresh_binary, use_det=False, use_cls=False, use_rec=True)[0][0][0] + if refresh_res == '0' or refresh_res == 'o' or refresh_res == 'O': + refresh_res = 0 + self.can_refresh = False + else: + self.can_refresh = True + + logger.info(f"刷新次数:{refresh_res}") - if self.permit_count == -1: + if self.permit_count is None: + recruit_ticket_img = self.recog.img[20:80, 1290:1380] + recruit_ticket_binary = cv2.threshold(refresh_gray, 220, 255, cv2.THRESH_BINARY)[1] try: - res = rapidocr.engine(recruit_main_img, use_det=False, use_cls=False, use_rec=True)[0][0][0] - self.permit_count = int(res) - logger.info(f"招募券数量:{self.permit_count}") + res = rapidocr.engine(recruit_ticket_binary, use_det=False, use_cls=False, use_rec=True)[0][0][0] + if res == '0' or res == 'o' or res == 'O': + res = 0 + if str(res).isdigit(): + self.permit_count = int(res) + logger.info(f"招募券数量:{res}") + else: + raise RuntimeError except: logger.error("招募券数量读取失败") - if self.permit_count == 0: + if self.can_refresh is False and self.permit_count <= 0: + logger.info("无招募券和刷新次数,结束公招") + return True + + if self.permit_count <= 0: self.has_ticket = False tapped = False @@ -292,8 +322,6 @@ def recruit_result(self): img_binary = cv2.threshold(gray_img, 220, 255, cv2.THRESH_BINARY)[1] max = 0 get_path = "" - t_height_ = None - t_width_ = None for tem_path in pathlib.Path(f"{__rootdir__}/resources/agent_name").glob("*.png"): From 07201d62a897bc30f343f578a2bbd8902cff5b93 Mon Sep 17 00:00:00 2001 From: EightyDollars Date: Sun, 15 Oct 2023 22:57:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9A=E6=A3=AE=E7=A9=BA=E5=B2=9B?= =?UTF-8?q?=E7=AD=BE=E5=88=B0=E5=BC=82=E5=B8=B8=E5=AF=BC=E8=87=B4=E5=90=8E?= =?UTF-8?q?=E7=BB=AD=E4=BB=BB=E5=8A=A1=E4=B8=8D=E8=BF=9B=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_schedule.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 0a84277bb..1ccd0314f 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -2283,9 +2283,12 @@ def maa_plan_solver(self, tasks='All', one_time=False): logger.info("间隔未超过设定时间,不启动maa") else: """森空岛签到""" - if self.skland_config['skland_enable']: - skland = SKLand(self.skland_config['skland_info']) - skland.attendance() + try: + if self.skland_config['skland_enable']: + skland = SKLand(self.skland_config['skland_info']) + skland.attendance() + except Exception: + logger.info(f"森空岛签到失败 {Exception}") """测试公招用""" if self.recruit_config['recruit_enable']: