Skip to content

Commit

Permalink
移除asst.py;更新Maa;暂时关闭回调
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Sep 11, 2023
1 parent 2e79724 commit 1ac78c7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 300 deletions.
83 changes: 49 additions & 34 deletions arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import copy
import subprocess
import time
import os
import sys
import pathlib
from enum import Enum
from datetime import datetime, timedelta
import numpy as np
Expand Down Expand Up @@ -31,8 +33,6 @@
# 借用__main__.py里的时间计算器
from arknights_mower.__main__ import format_time

## Maa
from arknights_mower.utils.asst import Asst, Message
import json

from arknights_mower.utils.email import task_template, maa_template, recruit_template
Expand Down Expand Up @@ -1871,42 +1871,57 @@ def reload(self):
if not error:
self.reload_time = datetime.now()

@Asst.CallBackType
def log_maa(msg, details, arg):
m = Message(msg)
d = json.loads(details.decode('utf-8'))
logger.debug(d)
logger.debug(m)
logger.debug(arg)
if "what" in d and d["what"] == "StageDrops":
global stage_drop
stage_drop["details"].append(d["details"]["drops"])
stage_drop["summary"] = d["details"]["stats"]

elif "what" in d and d["what"] == "RecruitTagsSelected":
global recruit_tags_selected
recruit_tags_selected["tags"].append(d["details"]["tags"])

elif "what" in d and d["what"] == "RecruitResult":
global recruit_results
temp_dict = {
"tags": d["details"]["tags"],
"level": d["details"]["level"],
"result": d["details"]["result"],
}
recruit_results["results"].append(temp_dict)

elif "what" in d and d["what"] == "RecruitSpecialTag":
global recruit_special_tags
recruit_special_tags["tags"].append(d["details"]["tags"])

def initialize_maa(self):
asst_path = os.path.dirname(pathlib.Path(self.maa_config['maa_path']) / "Python" / "asst")
if asst_path not in sys.path:
sys.path.append(asst_path)
global Message
from asst.asst import Asst
from asst.utils import Message, Version, InstanceOptionType
from asst.updater import Updater


logger.info("开始更新Maa……")
Updater(self.maa_config['maa_path'], Version.Stable).update()
logger.info("Maa更新完成")
# 若需要获取详细执行信息,请传入 callback 参数
# 例如 asst = Asst(callback=my_callback)
Asst.load(path=self.maa_config['maa_path'])
self.MAA = Asst(callback=self.log_maa)

@Asst.CallBackType
def log_maa(msg, details, arg):
m = Message(msg)
d = json.loads(details.decode('utf-8'))
logger.debug(d)
logger.debug(m)
logger.debug(arg)
if "what" in d and d["what"] == "StageDrops":
global stage_drop
stage_drop["details"].append(d["details"]["drops"])
stage_drop["summary"] = d["details"]["stats"]

elif "what" in d and d["what"] == "RecruitTagsSelected":
global recruit_tags_selected
recruit_tags_selected["tags"].append(d["details"]["tags"])

elif "what" in d and d["what"] == "RecruitResult":
global recruit_results
temp_dict = {
"tags": d["details"]["tags"],
"level": d["details"]["level"],
"result": d["details"]["result"],
}
recruit_results["results"].append(temp_dict)

elif "what" in d and d["what"] == "RecruitSpecialTag":
global recruit_special_tags
recruit_special_tags["tags"].append(d["details"]["tags"])

# self.MAA = Asst(callback=log_maa)
self.MAA = Asst()
self.stages = []
self.MAA.set_instance_option(2, self.maa_config['touch_option'])
self.MAA.set_instance_option(InstanceOptionType.touch_type, self.maa_config['touch_option'])
# 请自行配置 adb 环境变量,或修改为 adb 可执行程序的路径
# logger.info(self.device.client.device_id)
if self.MAA.connect(self.maa_config['maa_adb_path'], self.device.client.device_id,
Expand Down Expand Up @@ -1976,8 +1991,8 @@ def maa_plan_solver(self, tasks='All', one_time=False):
logger.info("间隔未超过设定时间,不启动maa")
else:
"""森空岛签到"""
skland = SKLand()
skland.attendance()
# skland = SKLand()
# skland.attendance()

"""测试公招用"""
if 'Recruit' in tasks or tasks == 'All':
Expand Down
265 changes: 0 additions & 265 deletions arknights_mower/utils/asst.py

This file was deleted.

2 changes: 1 addition & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def start():
operators,
write,
),
daemon=True,
daemon=False,
)
mower_process.start()

Expand Down

0 comments on commit 1ac78c7

Please sign in to comment.