Archived
1
0
Fork 0

Update maimai grade

This commit is contained in:
多羅狼 2023-12-30 23:22:43 +08:00 committed by GitHub
parent 0546572cd4
commit c978e9bcfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 33 deletions

View file

@ -447,8 +447,7 @@ async def _(msg: Bot.MessageSession, base: float, score: float):
@mai.command('grade <grade> {{maimai.help.grade}}') @mai.command('grade <grade> {{maimai.help.grade}}')
async def _(msg: Bot.MessageSession, grade: str): async def _(msg: Bot.MessageSession, grade: str):
res = await get_grade_info(msg, grade) await get_grade_info(msg, grade)
await msg.finish(res)
@mai.command('update', required_superuser=True) @mai.command('update', required_superuser=True)

View file

@ -67,20 +67,20 @@ grade_conversion = {
'里皆传': 'tgrade12', '里皆传': 'tgrade12',
'裡皆傳': 'tgrade12', '裡皆傳': 'tgrade12',
'裏皆傳': 'tgrade12', '裏皆傳': 'tgrade12',
'expert初级': 'expert1', 'Expert初级': 'expert1',
'expert初級': 'expert1', 'Expert初級': 'expert1',
'expert中级': 'expert2', 'Expert中级': 'expert2',
'expert中級': 'expert2', 'Expert中級': 'expert2',
'expert上级': 'expert3', 'Expert上级': 'expert3',
'expert上級': 'expert3', 'Expert上級': 'expert3',
'master初级': 'master1', 'Master初级': 'master1',
'master初級': 'master1', 'Master初級': 'master1',
'master中级': 'master2', 'Master中级': 'master2',
'master中級': 'master2', 'Master中級': 'master2',
'master上级': 'master3', 'Master上级': 'master3',
'master上級': 'master3', 'Master上級': 'master3',
'master超上级': 'master4', 'Master超上级': 'master4',
'master超上級': 'master4', 'Master超上級': 'master4',
} }
score_to_rank = { score_to_rank = {
@ -507,11 +507,11 @@ async def get_grade_info(msg, grade):
with open(file_path, 'r') as file: with open(file_path, 'r') as file:
data = json.load(file) data = json.load(file)
grade = grade.lower() if grade.lower() in [key.lower() for key in grade_conversion.keys()]:
if grade in list(grade_conversion.keys()): grade_key = grade_conversion[grade.lower()]
grade_key = grade_conversion[grade] grade = next(k for k, v in grade_conversion.items() if v == grade_key)
else: else:
await msg.finish("无效的段位") await msg.finish(msg.locale.t('maimai.message.grade.grade_not_found'))
if grade_key.startswith('tgrade'): if grade_key.startswith('tgrade'):
grade_type = 'tgrade' grade_type = 'tgrade'
@ -521,11 +521,10 @@ async def get_grade_info(msg, grade):
grade_type = 'rgrade' grade_type = 'rgrade'
chart_info = [] chart_info = []
grade_data = data[grade_type][grade_key]
condition = grade_data["condition"]
if grade_type != 'rgrade': if grade_type != 'rgrade':
grade_data = data[grade_type][grade_key]
charts = grade_data["charts"] charts = grade_data["charts"]
condition = grade_data["condition"]
life = grade_data["life"]
for chart in charts: for chart in charts:
music = (await total_list.get()).by_id(str(chart['song_id'])) music = (await total_list.get()).by_id(str(chart['song_id']))
@ -533,19 +532,15 @@ async def get_grade_info(msg, grade):
chart_info.append(f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") chart_info.append(f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}")
else: else:
grade_data = data[grade_type][grade_key]
base = grade_data["base"] base = grade_data["base"]
condition = grade_data["condition"]
level = grade_data["level_index"] level = grade_data["level_index"]
life = grade_data["life"]
music_data = (await total_list.get()).filter(ds=(base[0], base[1]), diff=[level]) music_data = (await total_list.get()).filter(ds=(base[0], base[1]), diff=[level])
for i in range(4): for i in range(4):
music = music_data.random() music = music_data.random()
chart_info.append(f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}") chart_info.append(f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''} {diffs[level]} {music['level'][level]}")
output_lines = '\n'.join(chart_info) content = '\n'.join(chart_info)
condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}" condition_info = f"GREAT{condition[0]}/GOOD{condition[1]}/MISS{condition[2]}/CLEAR{condition[3]}"
res = f"以下为{grade}段位列表:\n{output_lines}\n血量上限:{life}\n{condition_info}" await msg.finish(msg.locale.t('maimai.message.grade', grade=grade, content=content, life=grade_data["life"], condition=condition_info))
return res

View file

@ -1,8 +1,9 @@
{ {
"maimai.help.alias": "查询歌曲的别名。", "maimai.help.alias": "查询歌曲的别名。",
"maimai.help.b50": "查询 Maimai 用户的 B50 信息。", "maimai.help.b50": "查询 Maimai 用户的 B50 列表。",
"maimai.help.base": "根据定数或定数范围搜索歌曲。", "maimai.help.base": "根据定数或定数范围搜索歌曲。",
"maimai.help.desc": "查询 Maimai 相关内容。", "maimai.help.desc": "查询 Maimai 相关内容。",
"maimai.help.grade": "查询段位认定列表。",
"maimai.help.id": "根据 ID 查询歌曲或谱面信息。", "maimai.help.id": "根据 ID 查询歌曲或谱面信息。",
"maimai.help.info": "查询歌曲的相关谱面成绩ID 需要加入前缀“id”空格用“_”替代。", "maimai.help.info": "查询歌曲的相关谱面成绩ID 需要加入前缀“id”空格用“_”替代。",
"maimai.help.level": "根据等级搜索歌曲。", "maimai.help.level": "根据等级搜索歌曲。",
@ -32,6 +33,8 @@
"maimai.message.error.non_digital": "发生错误:歌曲 ID 必须为数字。", "maimai.message.error.non_digital": "发生错误:歌曲 ID 必须为数字。",
"maimai.message.forbidden": "此用户禁止了其他人获取数据。", "maimai.message.forbidden": "此用户禁止了其他人获取数据。",
"maimai.message.goal_invalid": "无效的目标评级,请检查输入。", "maimai.message.goal_invalid": "无效的目标评级,请检查输入。",
"maimai.message.grade": "以下为${grade}段位列表:\n${content}\n血量上限${life}\n${condition}",
"maimai.message.grade.grade_not_found": "无效的段位,请检查输入。",
"maimai.message.info.no_record": "未游玩过此谱面", "maimai.message.info.no_record": "未游玩过此谱面",
"maimai.message.level": "以下为 ${level} 级的曲目列表:", "maimai.message.level": "以下为 ${level} 级的曲目列表:",
"maimai.message.level_invalid": "无效的等级,请检查输入。", "maimai.message.level_invalid": "无效的等级,请检查输入。",
@ -51,7 +54,7 @@
"maimai.message.process.less_than_8": "歌曲等级必须大于 8 级。", "maimai.message.process.less_than_8": "歌曲等级必须大于 8 级。",
"maimai.message.random.error": "发生错误:随机歌曲失败,请检查输入。", "maimai.message.random.error": "发生错误:随机歌曲失败,请检查输入。",
"maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}。\n${user} 的分数为 ${rating},排名为 #${rank}\n已经超越了 ${surpassing_rate}% 的玩家。", "maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}。\n${user} 的分数为 ${rating},排名为 #${rank}\n已经超越了 ${surpassing_rate}% 的玩家。",
"maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%\nBREAK 2550一共 ${brk} 个)等价于 ${b2t_2550_great} 个 TAP GREAT-${b2t_2550_great_prop}%\nBREAK 2000一共 ${brk} 个)等价于 ${b2t_2000_great} 个 TAP GREAT-${b2t_2000_great_prop}%", "maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%\nBREAK 2550一共 ${brk} 个)相当于 ${b2t_2550_great} 个 TAP GREAT-${b2t_2550_great_prop}%\nBREAK 2000一共 ${brk} 个)相当于 ${b2t_2000_great} 个 TAP GREAT-${b2t_2000_great_prop}%",
"maimai.message.scoreline.error": "发生错误:计算结果失败,请检查输入。", "maimai.message.scoreline.error": "发生错误:计算结果失败,请检查输入。",
"maimai.message.scorelist": "以下为 ${user} 的 ${level} 级成绩列表:", "maimai.message.scorelist": "以下为 ${user} 的 ${level} 级成绩列表:",
"maimai.message.search": "“${keyword}”的搜索结果:", "maimai.message.search": "“${keyword}”的搜索结果:",

View file

@ -1,6 +1,6 @@
{ {
"maimai.help.alias": "查詢歌曲的別名。", "maimai.help.alias": "查詢歌曲的別名。",
"maimai.help.b50": "查詢 Maimai 使用者的 B50 資訊。", "maimai.help.b50": "查詢 Maimai 使用者的 B50 列表。",
"maimai.help.base": "依據定數或定數範圍內搜尋歌曲。", "maimai.help.base": "依據定數或定數範圍內搜尋歌曲。",
"maimai.help.desc": "查詢 Maimai 相關的內容。", "maimai.help.desc": "查詢 Maimai 相關的內容。",
"maimai.help.id": "依據 ID 查詢歌曲或譜面資訊。", "maimai.help.id": "依據 ID 查詢歌曲或譜面資訊。",

View file

@ -205,4 +205,10 @@ async def _(msg: Bot.MessageSession):
img = await msgchain2image([Plain(output)], msg) img = await msgchain2image([Plain(output)], msg)
await msg.finish([BImage(img)]) await msg.finish([BImage(img)])
else: else:
await msg.finish(output.strip()) await msg.finish(output.strip())
@mai_regex.regex(re.compile(r"(.+)\s?段位[认認]定表"), desc='{maimai.help.maimai_regex.grade}')
async def _(msg: Bot.MessageSession):
grade = msg.matched_msg.groups()[0]
await get_grade_info(msg, grade)