Skip to content

Commit

Permalink
适配更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawnsdaddy committed Nov 1, 2024
1 parent 4eee2c5 commit 8a5c345
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 819 deletions.
28 changes: 14 additions & 14 deletions arknights_mower/data/key_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,20 @@
"CONSUME",
60110
],
"randomMaterial_5d5": [
"randomMaterial_5d5",
"randomMaterial_4",
"2024感谢庆典物资补给",
"CONSUME",
60111
],
"2024感谢庆典物资补给": [
"randomMaterial_5d5",
"randomMaterial_4",
"2024感谢庆典物资补给",
"CONSUME",
60111
],
"randomMaterial_rhine2": [
"randomMaterial_rhine2",
"randomMaterial_rhine2",
Expand Down Expand Up @@ -10120,19 +10134,5 @@
"高级材料提货券",
"CONSUME",
30201
],
"SINGLE_55_0_1_GACHA": [
"SINGLE_55_0_1_GACHA",
"SINGLE_55_0_1_GACHA",
"未致蒙尘寻访凭证",
"NORMAL",
40003
],
"未致蒙尘寻访凭证": [
"SINGLE_55_0_1_GACHA",
"SINGLE_55_0_1_GACHA",
"未致蒙尘寻访凭证",
"NORMAL",
40003
]
}
Binary file modified arknights_mower/models/CONSUME.pkl
Binary file not shown.
Binary file modified arknights_mower/models/NORMAL.pkl
Binary file not shown.
Binary file modified arknights_mower/models/avatar.pkl
Binary file not shown.
Binary file modified arknights_mower/models/recruit.pkl
Binary file not shown.
Binary file modified arknights_mower/resources/arrange_order_options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified arknights_mower/resources/infra_overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 8 additions & 68 deletions arknights_mower/solvers/base_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class BaseMixin:
def detect_arrange_order(self):
name_list = ["工作状态", "技能", "心情", "信赖值"]
x_list = (1196, 1320, 1445, 1572)
x_list = (1309, 1435, 1560, 1685)
y = 70
hsv = cv2.cvtColor(self.recog.img, cv2.COLOR_RGB2HSV)
mask = cv2.inRange(hsv, (99, 200, 0), (100, 255, 255))
Expand All @@ -32,7 +32,7 @@ def detect_arrange_order(self):
return (name_list[idx], False)

def switch_arrange_order(self, name, ascending=False):
name_x = {"工作状态": 1197, "技能": 1322, "心情": 1447, "信赖值": 1575}
name_x = {"工作状态": 1309, "技能": 1439, "心情": 1565, "信赖值": 1690}
if isinstance(name, int):
name = list(name_x.keys())[name - 1]
if isinstance(ascending, str):
Expand Down Expand Up @@ -104,74 +104,14 @@ def verify_agent(self, agent: list[str], error_count=0, max_agent_count=-1):
raise e

def swipe_left(self, right_swipe):
if right_swipe > 3:
self.detail_filter(控制中枢=True)
self.detail_filter(控制中枢=False)
else:
swipe_time = 2 if right_swipe == 3 else right_swipe
for i in range(swipe_time):
self.swipe_noinertia((650, 540), (1900, 0))
# if right_swipe > 3:
# return right_swipe
# else:
# swipe_time = 2 if right_swipe == 3 else right_swipe
for i in range(right_swipe):
self.swipe_noinertia((650, 540), (1900, 0))
return 0

def detail_filter(self, **kwargs):
if kwargs:
text = ",".join(
f"{'打开' if value else '关闭'}{label}筛选"
for label, value in kwargs.items()
)
text += ",关闭其余筛选"
logger.info(text)
else:
logger.info("关闭所有筛选")

labels = [
"未进驻",
"产出设施",
"功能设施",
"自定义设施",
"控制中枢",
"生产类后勤",
"功能类后勤",
"恢复类后勤",
]
label_x = (560, 815, 1070, 1330)
label_y = (540, 645)

label_pos = []
for y in label_y:
for x in label_x:
label_pos.append((x, y))

label_pos_map = dict(zip(labels, label_pos))
target_state = dict(zip(labels, [False] * len(labels)))
target_state.update(kwargs)

filter_pos = (self.recog.w * 0.95, self.recog.h * 0.05)
self.tap(filter_pos)

err_cnt = 0
while not self.find("arrange_order_options_scene"):
self.ctap(filter_pos)
err_cnt += 1
if err_cnt > 3:
raise Exception("未进入筛选页面")

for label, pos in label_pos_map.items():
current_state = self.get_color(pos)[2] > 100
if target_state[label] != current_state:
self.tap(pos, interval=0.1)

self.recog.update()
confirm_pos = (self.recog.w * 0.8, self.recog.h * 0.8)
self.tap(confirm_pos)

err_cnt = 0
while self.find("arrange_order_options_scene"):
self.ctap(confirm_pos)
err_cnt += 1
if err_cnt > 3:
raise Exception("筛选确认失败")

def detect_room_number(self, img) -> int:
score = []
for i in range(1, 5):
Expand Down
95 changes: 47 additions & 48 deletions arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,8 @@ def plan_fia(self):

def plan_metadata(self):
planned_index = []
for t in self.tasks:
if "dorm" in t.meta_data:
planned_index.extend([int(w[4:]) for w in t.meta_data.split(",")])
# 移除当前 SHIFT_ON 重新刷新
self.tasks = [p for p in self.tasks if p.type != TaskTypes.SHIFT_ON]
_time = datetime.max
min_resting_time = datetime.max
_plan = {}
Expand Down Expand Up @@ -718,7 +717,7 @@ def infra_main(self):
self.refresh_skill_time(upgrade)
else:
self.plan_run_order(self.task.meta_data)
self.skip(["planned", "todo_task", "collect_notification"])
self.skip(["todo_task", "collect_notification"])
elif self.task.type == TaskTypes.SKILL_UPGRADE:
self.skill_upgrade(self.task.meta_data)
del self.tasks[0]
Expand Down Expand Up @@ -2373,19 +2372,27 @@ def tap_confirm(self, room, new_plan=None):
if wait_confirm > 0:
logger.info(f"等待跑单 {str(wait_confirm)} 秒")
self.sleep(wait_confirm)
self.tap_element("confirm_blue")
if self.find("arrange_confirm"):
retry_count = 0
while self.find("confirm_blue") and retry_count < 4:
self.tap_element("confirm_blue")
self.sleep(0.5)
self.recog.update()
retry_count += 1
retry_count = 0
while self.find("arrange_confirm") and retry_count < 4:
_x0 = self.recog.w // 3 * 2 # double confirm
_y0 = self.recog.h - 10
self.tap((_x0, _y0))
self.sleep(0.5)
self.recog.update()

def choose_train_agent(
self, current_room, agents, idx, error_count=0, fast_mode=False
):
if current_room[idx] != agents[idx]:
while (
self.find("arrange_order_options") is None
and self.find("confirm_blue") is None
# self.find("arrange_order_options",scope=((1785, 0), (1920, 128))) is None
self.find("confirm_blue") is None
):
if error_count > 3:
raise Exception("未成功进入干员选择界面")
Expand Down Expand Up @@ -2473,11 +2480,8 @@ def choose_agent(
retry_count = 0
selected = []
logger.debug(f"上次进入房间为:{self.last_room},本次房间为:{room}")
self.detail_filter()
if self.detect_arrange_order()[0] == "信赖值":
self.switch_arrange_order("工作状态")
siege = False # 推进之王
last_special_filter = ""
while len(agent) > 0:
if retry_count > 1:
raise Exception("到达最大尝试次数 1次")
Expand All @@ -2486,7 +2490,6 @@ def choose_agent(
right_swipe = self.swipe_left(right_swipe)
max_swipe = 50
retry_count += 1
self.detail_filter()
if first_time:
# 清空
if is_dorm:
Expand Down Expand Up @@ -2515,45 +2518,42 @@ def choose_agent(
self.switch_arrange_order(arrange_type[0], arrange_type[1])
# 滑倒最左边
self.sleep(interval=0.5)
if not siege:
right_swipe = self.swipe_left(right_swipe)
pre_order = arrange_type
first_time = False

if (
not siege
and not is_dorm
and agent
and all(
element in ["推进之王", "安哲拉", "斯卡蒂", "幽灵鲨", "乌尔比安"]
for element in agent
)
):
siege = True

if agent[0] in ["推进之王", "安哲拉", "斯卡蒂", "幽灵鲨"]:
self.detail_filter(恢复类后勤=True)
if last_special_filter != "恢复类后勤":
right_swipe = 0
last_special_filter = "恢复类后勤"
else:
self.detail_filter(功能类后勤=True)
if last_special_filter != "功能类后勤":
right_swipe = 0
last_special_filter = "功能类后勤"
self.switch_arrange_order(3, "true")
elif agent and agent[0] in self.op_data.operators:
ag = self.op_data.operators[agent[0]]
if ag.is_resting():
self.detail_filter(自定义设施=True)
last_special_filter = "自定义设施"
self.switch_arrange_order(3, "true")
# if (
# not siege
# and not is_dorm
# and agent
# and all(
# element in ["推进之王", "安哲拉", "斯卡蒂", "幽灵鲨", "乌尔比安"]
# for element in agent
# )
# ):
# siege = True
#
# if agent[0] in ["推进之王", "安哲拉", "斯卡蒂", "幽灵鲨"]:
# self.detail_filter(恢复类后勤=True)
# if last_special_filter != "恢复类后勤":
# right_swipe = 0
# last_special_filter = "恢复类后勤"
# else:
# self.detail_filter(功能类后勤=True)
# if last_special_filter != "功能类后勤":
# right_swipe = 0
# last_special_filter = "功能类后勤"
# self.switch_arrange_order(3, "true")
# elif agent and agent[0] in self.op_data.operators:
# ag = self.op_data.operators[agent[0]]
# if ag.is_resting():
# self.detail_filter(自定义设施=True)
# last_special_filter = "自定义设施"
# self.switch_arrange_order(3, "true")
changed, ret = self.scan_agent(agent)
if changed:
selected.extend(changed)
# 如果找到了
index_change = True
siege = False
else:
# 如果没找到 而且右移次数大于5
if ret[0][0] == first_name and right_swipe > 5:
Expand All @@ -2566,9 +2566,6 @@ def choose_agent(
self.swipe_noinertia(st, (ed[0] - st[0], 0))
right_swipe += 1
if len(agent) == 0:
if siege:
self.detail_filter()
right_swipe = 0
break

# 安排空闲干员
Expand All @@ -2579,7 +2576,6 @@ def choose_agent(
# 滑动到最左边
self.sleep(interval=0.5)
right_swipe = self.swipe_left(right_swipe)
self.detail_filter(未进驻=True)
self.switch_arrange_order(3, "true")
# 只选择在列表里面的
# 替换组小于20才休息,防止进入就满心情进行网络连接
Expand Down Expand Up @@ -2997,7 +2993,7 @@ def agent_arrange_room(
if room == "train":
self.choose_train(plan[room], choose_error <= 0)
else:
while self.find("arrange_order_options", score=0.5) is None:
while self.find("confirm_blue") is None:
if error_count > 3:
raise Exception("未成功进入干员选择界面")
self.ctap((self.recog.w * 0.82, self.recog.h * 0.2))
Expand Down Expand Up @@ -3103,6 +3099,9 @@ def agent_arrange(self, plan: tp.BasePlan, get_time=False):
if self.scene() in self.waiting_scene:
if not self.waiting_solver():
return
else:
logger.info("检测到漏单")
send_message("检测到漏单!", level="WARNING")
wait = 0
while self.find("order_ready", scope=((450, 675), (600, 750))) is None:
if wait > 6:
Expand Down
12 changes: 12 additions & 0 deletions arknights_mower/utils/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,18 @@ def add(self, operator):
if operator.workaholic and operator.name not in self.workaholic_agent:
self.workaholic_agent.append(operator.name)

def average_mood(self):
total_mood = 0
current_mood = 0
count = 0
for k, v in self.operators().items():
if not v.is_resting() and v.operator_type != "low" and not v.workaholic:
current_mood += v.current_mood() - v.lower_limit
total_mood += v.upper_limit - v.lower_limit
count += 1
logger.debug(f"{count}, {current_mood / total_mood}")
return current_mood / total_mood

def available_free(self, free_type="high"):
ret = 0
freeName = []
Expand Down
6 changes: 3 additions & 3 deletions arknights_mower/utils/recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def get_scene(self) -> int:
self.scene = Scene.CTRLCENTER_ASSISTANT
elif self.find("infra_overview"):
self.scene = Scene.INFRA_MAIN
elif self.find("infra_todo"):
elif self.find("infra_todo", scope=((0, 1013), (241, 1080))):
self.scene = Scene.INFRA_TODOLIST
elif self.find("clue"):
self.scene = Scene.INFRA_CONFIDENTIAL
Expand Down Expand Up @@ -670,9 +670,9 @@ def find(
"factory_collect": (1542, 886),
"fight/refresh": (1639, 22),
"hypergryph": (0, 961),
"infra_overview": (54, 135),
# "infra_overview": (54, 135),
"infra_overview_in": (64, 705),
"infra_todo": (13, 1013),
# "infra_todo": (13, 1013),
"loading2": (620, 247),
"loading7": (106, 635),
"login_account": (622, 703),
Expand Down
Binary file added ui/public/building_skill/bskill_man_spd&cost1.webp
Binary file not shown.
Binary file added ui/public/building_skill/bskill_man_spd&limit5.webp
Binary file not shown.
Binary file added ui/public/building_skill/bskill_meet_spd&bd2.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ui/public/building_skill/bskill_train_siracusa.webp
Binary file not shown.
Binary file added ui/public/depot/2024感谢庆典物资补给.webp
Binary file not shown.
Loading

0 comments on commit 8a5c345

Please sign in to comment.