From 28b50bb4b7d2622d83b895a038aee05bb1f2fd22 Mon Sep 17 00:00:00 2001 From: HereXianggeGe <2250120966@qq.com> Date: Sat, 2 Nov 2024 17:50:16 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BE=93=E5=87=BAxls?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E6=98=BE=E7=A4=BA=E5=80=99=E8=A1=A5=E6=9C=AA?= =?UTF-8?q?=E9=B8=9F=E5=8A=A0=E6=AD=8C=E6=9B=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rate_onlyBest50.py | 66 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/Rate_onlyBest50.py b/Rate_onlyBest50.py index 38fcf6a..9c0d0cc 100644 --- a/Rate_onlyBest50.py +++ b/Rate_onlyBest50.py @@ -1,5 +1,6 @@ import json import os +import xlwt def calculate_multiplier(max_score): @@ -79,10 +80,68 @@ def output_json_template(b50, alt15, total): return template +def output_xls(b50, alt15, t): + xls = xlwt.Workbook(encoding='utf-8') + work_sheet = xls.add_sheet('Sheet1') + work_sheet.col(1).width = 256*30 + + work_sheet.write(0, 0, "Best50") + work_sheet.write(0, 1, "注意:该表格仅计算单曲rate最高50首,并采用了新14定数表作为统计资料") + work_sheet.write(2, 0, "ID") + work_sheet.write(2, 1, '歌曲') + work_sheet.write(2, 2, '难度') + work_sheet.write(2, 3, '单曲rate') + work_sheet.write(2, 4, '最高分数') + work_sheet.write(2, 5, '定数') + work_sheet.write(1, 4, 'Rate:') + count = 3 + + style_ex = xlwt.XFStyle() + pattern = xlwt.Pattern() + pattern.pattern = xlwt.Pattern.SOLID_PATTERN + pattern.pattern_fore_colour = 10 + style_ex.pattern = pattern + + style_inf = xlwt.XFStyle() + pattern1 = xlwt.Pattern() + pattern1.pattern = xlwt.Pattern.SOLID_PATTERN + pattern1.pattern_fore_colour = 20 + style_inf.pattern = pattern1 + + for i in b50: + work_sheet.write(count, 0, i['id']) + work_sheet.write(count, 1, i['music']) + if i['difficulty'] == 'EXPERT': + work_sheet.write(count, 2, i['difficulty'], style=style_ex) + elif i['difficulty'] == 'INFERNO': + work_sheet.write(count, 2, i['difficulty'], style=style_inf) + work_sheet.write(count, 3, i['rate']) + work_sheet.write(count, 4, i['max_score']) + work_sheet.write(count, 5, i['level']) + count = count + 1 + + work_sheet.write(count, 0, '候补未鸟加歌曲') + for i in alt15: + if i['max_score'] < 990000: + count = count + 1 + work_sheet.write(count, 0, i['id']) + work_sheet.write(count, 1, i['music']) + if i['difficulty'] == 'EXPERT': + work_sheet.write(count, 2, i['difficulty'], style=style_ex) + elif i['difficulty'] == 'INFERNO': + work_sheet.write(count, 2, i['difficulty'], style=style_inf) + work_sheet.write(count, 3, i['rate']) + work_sheet.write(count, 4, i['max_score']) + work_sheet.write(count, 5, i['level']) + work_sheet.write(1, 5, xlwt.Formula('SUM(D4:D53)'), + style=xlwt.easyxf('font: bold on; pattern: pattern solid, fore_colour ice_blue')) + xls.save('output.xls') + + # print("//////////////////////////////////////////////////////////////////////") # print("华卡音舞 Ver.3 3.50.00") # print("全曲 Rate + Best 50 计算器") -# print("版本号 V0.05(1)") +# print("版本号 V0.05(2)") # print("由WOAOL项目组制作") # print("WACCA NEVER END") # print("请注意,该版本计算器不区分B15和B35,仅计算全曲的Best50成绩,并使用V4的14定数表") @@ -158,7 +217,7 @@ for log in play_logs: # print(f" 难度: {grade_name} 定数: {level:.1f} 分数: {max_score} Rate: {rate:.3f}") best_50_sorted = sorted(best_50, key=lambda x: x[2], reverse=True)[0:50] -best_50_alternate = sorted(best_50, key=lambda x: x[2], reverse=True)[50:65] +best_50_alternate = sorted(best_50, key=lambda x: x[2], reverse=True)[50:150] best_50_total = sum(rate for _, _, rate, _, _, _ in best_50_sorted) @@ -187,6 +246,9 @@ for music_name, grade_name, rate, max_score, level, music_id in best_50_alternat total = f'{best_50_total:.3f}' total = float(total) data = output_json_template(b50_json, alt15_json, total) + +output_xls(b50_json, alt15_json, total) + with open('b50_result.json', 'w+', encoding='utf-8') as json_file: json.dump(data, json_file, ensure_ascii=False, indent=2) print('Done')