Skip to content

Commit

Permalink
Merge pull request #360 from EightyDollars/dev_shawn
Browse files Browse the repository at this point in the history
chore:增加公招新增干员信息
  • Loading branch information
ZhaoZuohong authored Nov 1, 2023
2 parents 40b9493 + d2c8924 commit d1cf3b7
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 34 deletions.
8 changes: 7 additions & 1 deletion arknights_mower/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def hide_password(conf):
hpconf = deepcopy(conf)
hpconf["pass_code"] = "*" * len(conf["pass_code"])
hpconf["sendKey"] = "*" * len(conf["sendKey"])
hpconf["skland_config"] = conf["skland_info"]
for item in hpconf["skland_config"]:
item['password'] = "******"
return hpconf


Expand Down Expand Up @@ -145,8 +148,11 @@ def set_skland_options(base_scheduler):
skland_config["skland_enable"] = conf["skland_enable"]
skland_config["skland_info"] = conf["skland_info"]
base_scheduler.skland_config = skland_config
temp_str = base_scheduler.skland_config
for item in temp_str["skland_info"]:
item['password'] = "*******"
logger.debug(f"更新森空岛设置:{temp_str}")

logger.debug(f"更新森空岛设置:{base_scheduler.skland_config}")


def get_logic_exp(trigger):
Expand Down
8 changes: 8 additions & 0 deletions arknights_mower/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
recruit_agent = json.loads(
Path(f'{__rootdir__}/data/recruit.json').read_text('utf-8'))

recruit_result = json.loads(
Path(f'{__rootdir__}/data/recruit_result.json').read_text('utf-8'))

key_mapping = json.loads(
Path(f"{__rootdir__}/data/key_mapping.json").read_text("utf-8"))

Expand All @@ -79,3 +82,8 @@
}
)

result_template_list = []

for item in recruit_result:
for name in recruit_result[item]:
result_template_list.append(name)
31 changes: 31 additions & 0 deletions arknights_mower/data/recruit.json
Original file line number Diff line number Diff line change
Expand Up @@ -1303,5 +1303,36 @@
"近卫干员",
"近战位"
]
},
"char_416_zumama": {
"name": "森蚺",
"stars": 6,
"tags": [
"重装干员",
"输出",
"生存",
"防护",
"高级资深干员",
"近战位"
]
},
"char_415_flint": {
"name": "燧石",
"stars": 5,
"tags": [
"输出",
"资深干员",
"近卫干员",
"近战位"
]
},
"char_366_acdrop": {
"name": "酸糖",
"stars": 4,
"tags": [
"输出",
"远程位",
"狙击干员"
]
}
}
1 change: 1 addition & 0 deletions arknights_mower/data/recruit_result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"4": ["char_211_adnach", "char_210_stward", "char_127_estell", "char_102_texas", "char_373_lionhd", "char_145_prove", "char_326_glacus", "char_112_siege", "char_134_ifrit", "char_213_mostma"], "3": ["char_503_rang", "char_009_12fce", "char_208_melan", "char_281_popka", "char_122_beagle", "char_124_kroos", "char_212_ansel", "char_253_greyy", "char_235_jesica", "char_302_glaze", "char_149_scave", "char_151_myrtle", "char_298_susuro", "char_181_flower", "char_150_snakek", "char_258_podego", "char_128_plosis", "char_308_swire", "char_155_tiger", "char_143_ghost", "char_356_broca", "char_279_excu", "char_171_bldsk", "char_158_milu", "char_218_cuttle", "char_241_panda", "char_103_angel", "char_2013_cerber", "char_248_mgllan", "char_202_demkni", "char_188_helage", "char_283_midn", "char_263_skadi"], "2": ["char_502_nblade", "char_500_noirc", "char_501_durin", "char_240_wyvern", "char_192_falco", "char_284_spot", "char_121_lava", "char_120_hibisc", "char_278_orchid", "char_141_nights", "char_109_fmout", "char_328_cammou", "char_126_shotst", "char_190_clour", "char_118_yuki", "char_290_vigna", "char_130_doberm", "char_289_gyuki", "char_193_frostl", "char_185_frncat", "char_301_cutter", "char_236_rope", "char_117_myrrh", "char_385_finlpp", "char_199_yak", "char_196_sunbr", "char_183_skgoat", "char_277_sqrrel", "char_115_headbr", "char_349_chiave", "char_261_sddrag", "char_401_elysm", "char_294_ayer", "char_274_astesi", "char_129_bluep", "char_204_platnm", "char_367_swllow", "char_219_meteo", "char_379_sesa", "char_306_leizi", "char_344_beewax", "char_242_otter", "char_108_silent", "char_148_nearl", "char_243_waaifu", "char_107_liskam", "char_201_moeshd", "char_163_hpsts", "char_378_asbest", "char_173_slchan", "char_174_slbell", "char_254_vodfox", "char_195_glassb", "char_343_tknogi", "char_215_mantic", "char_197_poca", "char_222_bpipe", "char_358_lisa", "char_250_phatom", "char_400_weedy", "char_147_shining", "char_179_cgbird", "char_136_hsguma", "char_172_svrash", "char_293_thorns", "char_282_catap", "char_137_brownb", "char_164_nightm", "char_416_zumama", "char_415_flint", "char_366_acdrop"], "1": ["char_123_fang", "char_133_mm", "char_337_utage", "char_237_gravel", "char_272_strong", "char_226_hmau", "char_144_red", "char_340_shwaz", "char_225_haak", "char_010_chen", "char_017_huang"], "-1": ["char_285_medic2", "char_286_cast3", "char_376_therex", "char_4000_jnight", "char_4093_frston"]}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arknights_mower/resources/recruit_ticket.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 added arknights_mower/resources/stone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2297,8 +2297,8 @@ def maa_plan_solver(self, tasks='All', one_time=False):
if self.skland_config['skland_enable']:
skland = SKLand(self.skland_config['skland_info'])
skland.attendance()
except Exception:
logger.info(f"森空岛签到失败 {Exception}")
except RuntimeError as e:
logger.info("森空岛签到失败:{}".format(e.__str__()))

"""测试公招用"""
if self.recruit_config['recruit_enable']:
Expand Down
16 changes: 8 additions & 8 deletions arknights_mower/solvers/recruit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import re
import cv2

from ..data import recruit_agent, agent_with_tags, recruit_tag
from ..data import recruit_agent, agent_with_tags, recruit_tag, result_template_list
from ..ocr import ocr_rectify, ocrhandle
from ..utils import segment, rapidocr
from .. import __rootdir__
Expand Down Expand Up @@ -125,7 +125,9 @@ def transition(self) -> bool:
logger.info(f"刷新次数:{refresh_res}")

if self.permit_count is None:
recruit_ticket_img = self.recog.img[20:80, 1230:1380]
p0, p1 = self.find("recruit_ticket")
p2, p3 = self.find("stone")
recruit_ticket_img = self.recog.img[p0[1]:p1[1], p1[0]:p2[0]]
recruit_ticket_gray = cv2.cvtColor(recruit_ticket_img, cv2.COLOR_BGR2GRAY)
try:
res = rapidocr.engine(recruit_ticket_gray, use_det=False, use_cls=False, use_rec=True)[0][0][0]
Expand Down Expand Up @@ -321,25 +323,23 @@ def recruit_result(self):
max = 0
get_path = ""

for tem_path in pathlib.Path(f"{__rootdir__}/resources/agent_name").glob("*.png"):

for template_name in result_template_list:
tem_path = f"{__rootdir__}/resources/agent_name/{template_name}.png"
template_ = cv2.imread(tem_path.__str__())
template_ = cv2.cvtColor(template_, cv2.COLOR_BGR2GRAY)
res = cv2.matchTemplate(img_binary, template_, cv2.TM_CCORR_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
if max < max_val:
get_path = tem_path
max = max_val
if max > 0.7:
break

if max > 0.7:
agent_id = os.path.basename(get_path)
agent_id = agent_id.replace(".png", "")
agent = recruit_agent[agent_id]['name']

# 暂时不会选6星,所以不会有阿
if agent == "阿":
agent = "阿消"

if agent is not None:
# 汇总开包结果
self.result_agent[str(self.recruit_pos + 1)] = agent
Expand Down
48 changes: 25 additions & 23 deletions arknights_mower/solvers/skland.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@
class SKLand:
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": ""
})
try:
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": ""
})
except:
raise RuntimeError("森空岛信息初始化失败")

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",
Expand Down Expand Up @@ -49,18 +53,18 @@ def respone_to_json(self, responese):
responese_json = json.loads(responese.text)
return responese_json
except:
logger.info("请求返回数据存在问题")
raise RuntimeError("返回信息获取失败")

"""登录获取cred"""

def sign_by_phone(self, account):
data = {"phone": account['phone'], "password": account['password']}
response = requests.post(headers=self.request_header, url=self.url.get("token_by_phone_password"), data=data)

response_json = self.respone_to_json(response)
if response_json.get("status") == 0:
return response_json.get("data").get("token")
return ""
else:
raise RuntimeError("token获取失败")

def check_cred(self, account):
if account['cred'] == "":
Expand All @@ -72,13 +76,12 @@ def check_cred(self, account):

if response_json.get("code") == 0:
logger.debug("验证cred未过期")

logger.debug("验证cred过期")
else:
raise RuntimeError("验证cred过期")

def get_binding_player(self, account):
if account['cred'] == "":
logger.error("获取绑定信息失败")
raise "获取绑定信息失败"
raise RuntimeError("获取绑定信息失败")
headers = self.request_header
headers["cred"] = account['cred']

Expand All @@ -90,14 +93,13 @@ def get_binding_player(self, account):
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("获取玩家信息失败")
else:
raise RuntimeError("验证cred过期")

def get_OAuth2_token(self, account):
token = self.sign_by_phone(account)
if token == "":
logger.error("token获取失败")
raise "token获取失败"
raise RuntimeError("token获取失败")

data = {
"token": token,
Expand All @@ -116,7 +118,7 @@ def get_cred(self, account):
code = self.get_OAuth2_token(account)

if code == "":
raise ("OAuth2授权代码获取失败")
raise RuntimeError("OAuth2授权代码获取失败")
data = {
"kind": 1,
"code": code
Expand Down

0 comments on commit d1cf3b7

Please sign in to comment.