Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawnsdaddy committed Sep 6, 2024
1 parent c590293 commit 7f53a66
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
8 changes: 2 additions & 6 deletions arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3238,12 +3238,8 @@ def maa_plan_solver(self, tasks="All", one_time=False):
# 任务及参数请参考 docs/集成文档.md
self.initialize_maa()
if tasks == "All":
tasks = ["StartUp", "Fight", "Visit", "Mall", "Award"]
# tasks = ['StartUp', 'Fight', 'Visit', 'Mall', 'Award', 'Depot']
# tasks = ['StartUp', 'Fight', 'Recruit', 'Visit', 'Mall', 'Award']
tasks = ["StartUp", "Fight", "Mall", "Award"]
for maa_task in tasks:
# if maa_task == "Recruit":
# continue
self.append_maa_task(maa_task)
self.MAA.start()
stop_time = None
Expand Down Expand Up @@ -3425,7 +3421,7 @@ def recruit_plan_solver(self):
] is None or datetime.now() > self.last_execution["recruit"] + timedelta(
hours=config.conf.recruit_gap
):
RecruitSolver().run()
RecruitSolver(self.device, self.recog).run()

self.last_execution["recruit"] = datetime.now()
logger.info(f"下一次公开招募执行时间在{config.conf.recruit_gap}小时之后")
Expand Down
17 changes: 9 additions & 8 deletions arknights_mower/solvers/recruit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
)
from arknights_mower.models import noto_sans, riic_base_digits
from arknights_mower.utils import config
from arknights_mower.utils.device.device import Device
from arknights_mower.utils.email import recruit_rarity, recruit_template, send_message
from arknights_mower.utils.graph import SceneGraphSolver
from arknights_mower.utils.image import cmatch, cropimg, loadres, thres2
from arknights_mower.utils.log import logger
from arknights_mower.utils.recognize import Scene
from arknights_mower.utils.recognize import Recognizer, Scene
from arknights_mower.utils.vector import va

number = riic_base_digits
Expand All @@ -37,8 +38,8 @@


class RecruitSolver(SceneGraphSolver):
def __init__(self) -> None:
super().__init__()
def __init__(self, device: Device = None, recog: Recognizer = None) -> None:
super().__init__(device, recog)
self.find_scope = {
"recruit/begin_recruit": [(340, 200), (590, 300)],
"recruit/job_requirements": [(100, 20), (300, 100)],
Expand Down Expand Up @@ -200,7 +201,7 @@ def transition(self) -> bool:
tag_all_choose = True
for x in choose:
h, w, _ = tag_template[x].shape
tag_img = cropimg(config.recog.img, [tags[x], va(tags[x], (w, h))])
tag_img = cropimg(self.recog.img, [tags[x], va(tags[x], (w, h))])

if self.tag_not_choosed(tag_img):
tag_all_choose = False
Expand Down Expand Up @@ -280,7 +281,7 @@ def recruit_result(self):
if job_pt := self.find(i):
break

img = cropimg(config.recog.gray, ((job_pt[1][0], 730), (1800, 860)))
img = cropimg(self.recog.gray, ((job_pt[1][0], 730), (1800, 860)))
img = cv2.threshold(img, 220, 255, cv2.THRESH_BINARY)[1]

score = {}
Expand Down Expand Up @@ -463,7 +464,7 @@ def get_recruit_tag(self) -> dict | bool:
left = 530
right = 1300

img = config.recog.img[up:down, left:right]
img = self.recog.img[up:down, left:right]
tags_img = self.split_tags(img)
tags = {}
h, w, _ = img.shape
Expand Down Expand Up @@ -511,7 +512,7 @@ def get_ticket_number(self, height: int | None = 0, thres: int | None = 180):
p3, _ = self.find("recruit/stone")
p1 = (p2[0], p1[1] + 10)
p3 = (p3[0] - 30, p2[1] - 5)
img = cropimg(config.recog.gray, (p1, p3))
img = cropimg(self.recog.gray, (p1, p3))
default_height = 29
if height and height != default_height:
scale = default_height / height
Expand Down Expand Up @@ -559,7 +560,7 @@ def get_recruit_time(
elif mode == "minute":
area = [(850, 280), (980, 400)]

img = cropimg(config.recog.gray, area)
img = cropimg(self.recog.gray, area)
templates = noto_sans
default_height = 28

Expand Down
2 changes: 1 addition & 1 deletion arknights_mower/utils/config/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class WaitingSceneConf(ConfModel):
"界面主题"
screenshot_interval: int = 500
"截图最短间隔(毫秒)"
screenshot: float = 24
screenshot: float = 0.02
"截图保留时长(小时)"
check_for_updates: bool = True
"检查更新"
Expand Down
2 changes: 1 addition & 1 deletion arknights_mower/utils/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def restart_simulator(stop=True, start=True):
cmd = ""
blocking = False

if simulator_type not in Simulator_Type:
if simulator_type not in [types.value for types in Simulator_Type]:
logger.warning(f"尚未支持{simulator_type}重启/自动启动")
csleep(10)
return
Expand Down
1 change: 0 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def stop():
global mower_thread
global saved_state

logger.info(mower_thread)
if mower_thread is None:
return "true"
from arknights_mower.__main__ import base_scheduler
Expand Down

0 comments on commit 7f53a66

Please sign in to comment.