diff --git a/arknights_mower/__main__.py b/arknights_mower/__main__.py index 974d62aac..90396f4f3 100644 --- a/arknights_mower/__main__.py +++ b/arknights_mower/__main__.py @@ -105,6 +105,25 @@ def set_maa_options(base_scheduler): logger.debug(f"更新Maa设置:{base_scheduler.maa_config}") +def set_recruit_options(base_scheduler): + conf = update_conf() + global recruit_config + recruit_config['recruit_enable'] = conf['recruit_enable'] + recruit_config['recruit_only_4'] = conf['recruit_only_4'] + recruit_config['recruit_robot'] = conf['recruit_robot'] + recruit_config['recruitment_time'] = conf['recruitment_time'] + base_scheduler.recruit_config = recruit_config + + logger.debug(f"更新公招设置:{base_scheduler.recruit_config}") + +def set_skland_options(base_scheduler): + conf = update_conf() + global skland_config + skland_config['skland_enable'] = conf['skland_enable'] + skland_config['skland_info'] = conf['skland_info'] + base_scheduler.skland_config = skland_config + + logger.debug(f"更新森空岛设置:{base_scheduler.skland_config}") def initialize(tasks, scheduler=None): from arknights_mower.solvers.base_schedule import BaseSchedulerSolver @@ -148,6 +167,8 @@ def initialize(tasks, scheduler=None): } set_maa_options(base_scheduler) + set_recruit_options(base_scheduler) + set_skland_options(base_scheduler) base_scheduler.ADB_CONNECT = config.ADB_CONNECT[0] base_scheduler.error = False @@ -217,6 +238,8 @@ def simulate(): remaining_time = (base_scheduler.tasks[0].time - datetime.now()).total_seconds() set_maa_options(base_scheduler) + set_recruit_options(base_scheduler) + set_skland_options(base_scheduler) if sleep_time > 540 and base_scheduler.maa_config['maa_enable'] == 1: subject = f"下次任务在{base_scheduler.tasks[0].time.strftime('%H:%M:%S')}" @@ -292,6 +315,8 @@ def load_state(file='state.json'): agent_base_config = {} maa_config = {} +recruit_config = {} +skland_config = {} def __init_params__(): diff --git a/arknights_mower/command.py b/arknights_mower/command.py index 1c879cb9f..27fdbe847 100644 --- a/arknights_mower/command.py +++ b/arknights_mower/command.py @@ -84,7 +84,7 @@ def shop(args: list[str] = [], device: Device = None): ShopSolver(device).run(args) -def recruit(args: list[str] = [], email_config={}, maa_config={}, device: Device = None): +def recruit(args: list[str] = [], email_config={}, recruit_config={}, device: Device = None): """ recruit [agents ...] 自动进行公共招募 @@ -93,9 +93,9 @@ def recruit(args: list[str] = [], email_config={}, maa_config={}, device: Device choose = {} result = {} if len(args) == 0: - choose, result = RecruitSolver(device).run(config.RECRUIT_PRIORITY, email_config, maa_config) + choose, result = RecruitSolver(device).run(config.RECRUIT_PRIORITY, email_config, recruit_config) else: - choose, result = RecruitSolver(device).run(args, email_config) + choose, result = RecruitSolver(device).run(args, email_config,recruit_config) return choose, result diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 61ccdf6b9..3122be95e 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -90,6 +90,8 @@ def __init__(self, device: Device = None, recog: Recognizer = None) -> None: self.credit_fight = None self.exit_game_when_idle = False self.refresh_connecting = False + self.recruit_config = {} + self.skland_config = {} def run(self) -> None: """ @@ -2195,12 +2197,13 @@ def maa_plan_solver(self, tasks='All', one_time=False): logger.info("间隔未超过设定时间,不启动maa") else: """森空岛签到""" - # skland = SKLand() - # skland.attendance() + if self.skland_config['skland_enable']: + skland = SKLand(self.skland_config['skland_info']) + skland.attendance() """测试公招用""" - if 'Recruit' in tasks or tasks == 'All': - recruit([], self.email_config, self.maa_config) + if self.recruit_config['recruit_enable']: + recruit([], self.email_config, self.recruit_config) self.send_email('启动MAA') self.back_to_index() diff --git a/arknights_mower/solvers/recruit.py b/arknights_mower/solvers/recruit.py index 6c984d9f4..d644f1dae 100644 --- a/arknights_mower/solvers/recruit.py +++ b/arknights_mower/solvers/recruit.py @@ -48,7 +48,7 @@ def __init__(self, device: Device = None, recog: Recognizer = None) -> None: self.recruit_pos = -1 - def run(self, priority: list[str] = None, email_config={}, maa_config={}): + def run(self, priority: list[str] = None, email_config={}, recruit_config={}): """ :param priority: list[str], 优先考虑的公招干员,默认为高稀有度优先 """ @@ -59,7 +59,7 @@ def run(self, priority: list[str] = None, email_config={}, maa_config={}): self.email_config = email_config # 调整公招参数 - self.add_recruit_param(maa_config) + self.add_recruit_param(recruit_config) logger.info('Start: 公招') # 清空 @@ -89,21 +89,22 @@ def run(self, priority: list[str] = None, email_config={}, maa_config={}): return self.agent_choose, self.result_agent - def add_recruit_param(self, maa_config): - if not maa_config: + def add_recruit_param(self, recruit_config): + if not recruit_config: raise Exception("招募设置为空") - if maa_config['recruitment_time']: + if recruit_config['recruitment_time']: recruitment_time = 460 else: recruitment_time = 540 self.recruit_config = { - "recruit_only_4": maa_config['recruit_only_4'], + "recruit_only_4": recruit_config['recruit_only_4'], "recruitment_time": { "3": recruitment_time, "4": 540 - } + }, + "recruit_robot": recruit_config['recruit_robot'] } def transition(self) -> bool: @@ -183,7 +184,7 @@ def recruit_tags(self) -> bool: logger.info(f'第{self.recruit_pos + 1}个位置上的公招标签:{tags}') # 计算招募标签组合结果 - best, need_choose = self.recruit_cal(tags, self.priority) + best, need_choose = self.recruit_cal(tags) # 刷新标签 if need_choose is False: @@ -360,10 +361,11 @@ def merge_agent_list(self, tags: [str], list_1: list[dict], list_2={}, list_3={} return merge_list, level, isRarity, isRobot - def recruit_cal(self, tags: list[str], auto_robot=False, need_Robot=True) -> (dict, bool): + def recruit_cal(self, tags: list[str]) -> (dict, bool): possible_list = {} has_rarity = False has_robot = False + recruit_robot =self.recruit_config["recruit_robot"] for item in combinations(tags, 1): # 防止出现类似情况 ['重', '装', '干', '员'] @@ -414,47 +416,65 @@ def recruit_cal(self, tags: list[str], auto_robot=False, need_Robot=True) -> (di logger.debug(f"公招可能性:{self.recruit_str(possible_list)}") + rarity_list = { + "level": -1, + "possible": {} + } + normal_list = { + "level": -1, + "possible": {} + } + robot_list = {} for key in list(possible_list.keys()): # 五星六星选择优先级大于支援机械 - if has_rarity: - if possible_list[key]['isRarity'] is False: - del possible_list[key] - continue - elif possible_list[key]['level'] < 6 and "高级资深干员" in tags: - del possible_list[key] + if possible_list[key]["isRarity"]: + if possible_list[key]["level"] > rarity_list["level"]: + rarity_list["level"] = possible_list[key]["level"] + rarity_list["possible"][key] = possible_list[key] + elif possible_list[key]["isRobot"]: + robot_list[key] = possible_list[key] + else: + if possible_list[key]["level"] > normal_list["level"]: + normal_list["level"] = possible_list[key]["level"] + normal_list["possible"][key] = possible_list[key] + + # 筛选稀有tag + if rarity_list["possible"]: + for key in list(rarity_list["possible"].keys()): + if rarity_list["possible"][key]["level"] < rarity_list["level"]: + del rarity_list["possible"][key] continue - # 不要支援机械 - elif need_Robot is False and possible_list[key]['isRobot'] is True: - del possible_list[key] - continue - # 支援机械手动选择 - elif has_robot and need_Robot is True and possible_list[key]['isRobot'] is False: - del possible_list[key] - continue + for i in range(len(rarity_list["possible"][key]["agent"]) - 1, -1, -1): + if rarity_list["possible"][key]["agent"][i]['level'] != rarity_list["possible"][key]["level"]: + rarity_list["possible"][key]["agent"].remove(rarity_list["possible"][key]["agent"][i]) + logger.debug(f"rarity_list:{rarity_list}") + return rarity_list, False + + if robot_list and self.recruit_config["recruit_robot"]: + logger.debug(f"robot_list:{robot_list.popitem()}") + return robot_list, False - '''只保留大概率能出的tag''' - for i in range(len(possible_list[key]["agent"]) - 1, -1, -1): - if possible_list[key]["agent"][i]['level'] != possible_list[key]["level"]: - possible_list[key]["agent"].remove(possible_list[key]["agent"][i]) + # 筛选非稀有tag - # 六星 五星 支援机械手动选择返回全部结果 + logger.debug(normal_list["level"]) + if normal_list["level"] < 4: + return {}, True - # 有支援机械 不需要自动点支援机械 并且需要支援机械的情况下,邮件提醒 - notice_robot = (has_robot and auto_robot == False and need_Robot) - need_choose = True - if notice_robot or has_rarity: - need_choose = False - logger.info(f"稀有tag:{self.recruit_str(possible_list)}") - return possible_list, need_choose + for key in list(normal_list["possible"].keys()): + if normal_list["possible"][key]["level"] < normal_list["level"]: + del normal_list["possible"][key] + continue + for i in range(len(normal_list["possible"][key]["agent"]) - 1, -1, -1): + if normal_list["possible"][key]["agent"][i]['level'] != normal_list["possible"][key]["level"]: + normal_list["possible"][key]["agent"].remove(normal_list["possible"][key]["agent"][i]) best = {} # 4星=需要选择tag返回选择的tag,3星不选 - for key in possible_list: - if possible_list[key]['level'] >= 4: - best[key] = possible_list[key] - break - - return best, need_choose + for key in normal_list["possible"]: + best[key] = normal_list["possible"][key] + break + logger.debug(f"normal_list:{normal_list}") + return best, True def recruit_str(self, recruit_result: dict): if not recruit_result: diff --git a/arknights_mower/solvers/skland.py b/arknights_mower/solvers/skland.py index 7795543b0..05d4d311e 100644 --- a/arknights_mower/solvers/skland.py +++ b/arknights_mower/solvers/skland.py @@ -7,24 +7,27 @@ class SKLand: - def __init__(self): - self.account = [ - { - "name": "风味手扒鸡#5916", - "phone": "", - "password": "", - "uid": "", - "cred": "" - } - ] - + def __init__(self, skland_info): + self.account = [] + for item in skland_info: + if item["isCheck"] is False: + continue + if item['account'] != "" and item['password'] != "": + self.account.append({ + "name": "", + "phone": item['account'], + "password": item['password'], + "uid": "", + "cred": "" + }) self.url = { "get_cred": "https://zonai.skland.com/api/v1/user/auth/generate_cred_by_code", "token_by_phone_password": "https://as.hypergryph.com/user/auth/v1/token_by_phone_password", "check_cred_url": "https://zonai.skland.com/api/v1/user/check", "OAuth2": "https://as.hypergryph.com/user/oauth2/v2/grant", "get_cred_url": "https://zonai.skland.com/api/v1/user/auth/generate_cred_by_code", - "attendance": "https://zonai.skland.com/api/v1/game/attendance" + "attendance": "https://zonai.skland.com/api/v1/game/attendance", + "get_binding_player": "https://zonai.skland.com/api/v1/game/player/binding" } self.request_header = { @@ -62,14 +65,32 @@ def check_cred(self, account): if response_json.get("code") == 0: logger.debug("验证cred未过期") - return True + logger.debug("验证cred过期") - return False + + def get_binding_player(self, account): + if account['cred'] == "": + logger.error("获取绑定信息失败") + raise "获取绑定信息失败" + headers = self.request_header + headers["cred"] = account['cred'] + + response = requests.get(headers=headers, url=self.url.get("get_binding_player")) + response_json = self.respone_to_json(response) + + if response_json.get("code") == 0: + logger.info("获取玩家信息成功") + player_info = response_json.get('data').get('list')[0].get('bindingList')[0] + account['name'] = player_info.get('nickName') + account['uid'] = player_info.get('uid') + + logger.debug("获取玩家信息失败") def get_OAuth2_token(self, account): token = self.sign_by_phone(account) if token == "": - raise "登陆失败" + logger.error("token获取失败") + raise "token获取失败" data = { "token": token, @@ -97,18 +118,19 @@ def get_cred(self, account): response_json = self.respone_to_json(response) if response_json.get("code") == 0: - return response_json.get("data").get("cred") - - return "" + account['cred'] = response_json.get("data").get("cred") def attendance(self): for account in self.account: - if self.get_record(account['name']): - logger.info(f"{account['name']} 今日已经签到过了") + if self.get_record(account['phone']): + logger.info(f"{account['phone']} 今日已经签到过了") continue if self.check_cred(account) is False: - account['cred'] = self.get_cred(account) + self.get_cred(account) + + self.get_binding_player(account) + logger.debug(account) data = { "uid": account["uid"], "gameId": 1 @@ -127,28 +149,30 @@ def attendance(self): elif response_json["code"] == 10001 and response_json["message"] == "请勿重复签到!": logger.info(f"{account['name']} 请勿重复签到!") award.append("请勿重复签到!") - self.get_award[account['name']] = award - self.record_attendance(account['name'], self.get_award[account['name']]) - + self.get_award[account['phone']] = award + self.record_attendance(account['phone'], self.get_award[account['phone']]) + if self.get_award: + logger.info(self.get_award) return self.get_award - def record_attendance(self, name, data): + def record_attendance(self, account, data): - data_row = [name, data, datetime.date.today()] + data_row = [account, data, datetime.date.today()] with open(self.record_path, 'a+') as f: csv_write = csv.writer(f) csv_write.writerow(data_row) - def get_record(self, name): + def get_record(self, account): + try: with open(self.record_path, 'r+') as f: csv_reader = csv.reader(f) for line in csv_reader: - if line[0] == name: - return True + if line: + if line[0] == account and line[2] == str(datetime.date.today()): + return True except: with open(self.record_path, 'a+') as f: return False return False - diff --git a/ui/src/components/MaaRecruit.vue b/ui/src/components/MaaRecruit.vue deleted file mode 100644 index 2521297d8..000000000 --- a/ui/src/components/MaaRecruit.vue +++ /dev/null @@ -1,114 +0,0 @@ - - - - - diff --git a/ui/src/components/Recruit.vue b/ui/src/components/Recruit.vue new file mode 100644 index 000000000..20655e7d0 --- /dev/null +++ b/ui/src/components/Recruit.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/ui/src/components/SKLand.vue b/ui/src/components/SKLand.vue new file mode 100644 index 000000000..e582b3e81 --- /dev/null +++ b/ui/src/components/SKLand.vue @@ -0,0 +1,49 @@ + + + + + + + + diff --git a/ui/src/pages/Advanced.vue b/ui/src/pages/Advanced.vue index 9afdd90d9..e0e96a54b 100644 --- a/ui/src/pages/Advanced.vue +++ b/ui/src/pages/Advanced.vue @@ -253,6 +253,7 @@ async function select_simulator_folder() { + diff --git a/ui/src/pages/External.vue b/ui/src/pages/External.vue index 95ce69cae..500d67398 100644 --- a/ui/src/pages/External.vue +++ b/ui/src/pages/External.vue @@ -47,7 +47,7 @@ const rogue_themes = [