版本更新为v0.05,新增输出json
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -59,31 +58,52 @@ def get_music_name(levels_dict, music_id):
|
|||||||
return music_entry.get("name", "Unknown")
|
return music_entry.get("name", "Unknown")
|
||||||
|
|
||||||
|
|
||||||
print("")
|
def json_template(music, diff, rate, max, level, music_id):
|
||||||
print("//////////////////////////////////////////////////////////////////////")
|
template = {
|
||||||
print("")
|
'id': music_id,
|
||||||
print("华卡音舞 Ver.3 3.50.00")
|
'music': music,
|
||||||
print("全曲 Rate + Best 50 计算器")
|
'difficulty': diff,
|
||||||
print("版本号 V0.03(1)")
|
'rate': level,
|
||||||
print("由WOAOL项目组制作")
|
'max_score': max,
|
||||||
print("WACCA NEVER END")
|
'level': rate
|
||||||
print("请注意,该版本计算器不区分B15和B35,仅计算全曲的Best50成绩,并使用V4的14定数表")
|
}
|
||||||
print("该版本计算器为子版本,正常计算国服B50请不要用此计算器及其配套Table_output.json")
|
return template
|
||||||
print("")
|
|
||||||
print("//////////////////////////////////////////////////////////////////////")
|
|
||||||
print("")
|
def output_json_template(b50, alt15, total):
|
||||||
|
template = {
|
||||||
|
'b50_total': total,
|
||||||
|
'b50': b50,
|
||||||
|
'alt15': alt15
|
||||||
|
}
|
||||||
|
return template
|
||||||
|
|
||||||
|
|
||||||
|
# print("//////////////////////////////////////////////////////////////////////")
|
||||||
|
# print("华卡音舞 Ver.3 3.50.00")
|
||||||
|
# print("全曲 Rate + Best 50 计算器")
|
||||||
|
# print("版本号 V0.05(1)")
|
||||||
|
# print("由WOAOL项目组制作")
|
||||||
|
# print("WACCA NEVER END")
|
||||||
|
# print("请注意,该版本计算器不区分B15和B35,仅计算全曲的Best50成绩,并使用V4的14定数表")
|
||||||
|
# print("该版本计算器为子版本,正常计算国服B50请不要用此计算器及其配套Table_output.json")
|
||||||
|
# print("//////////////////////////////////////////////////////////////////////")
|
||||||
|
|
||||||
if not os.path.isfile('Table_output_V4.json'):
|
if not os.path.isfile('Table_output_V4.json'):
|
||||||
print("错误:找不到Table_output.json。")
|
print("")
|
||||||
|
print("错误:找不到Table_output_V4.json。")
|
||||||
print("请将Rate_SDJE.py、Table_output_V4.json、playLog.json这三个文件放在同一目录下。")
|
print("请将Rate_SDJE.py、Table_output_V4.json、playLog.json这三个文件放在同一目录下。")
|
||||||
|
print("")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
if not os.path.isfile('playLog.json'):
|
if not os.path.isfile('playlog_b50.json'):
|
||||||
print("错误:找不到playLog.json。")
|
print("")
|
||||||
print("请将Rate_SDJE.py、Table_output_V4.json、playLog.json这三个文件放在同一目录下。")
|
print("错误:找不到playlog_b50.json.json。")
|
||||||
|
print("请将Rate_SDJE.py、Table_output_V4.json、playlog_b50.json这三个文件放在同一目录下。")
|
||||||
|
print("")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
with open('playLog.json', 'r', encoding='utf-8') as file:
|
with open('playlog_b50.json', 'r', encoding='utf-8') as file:
|
||||||
play_logs = json.load(file)
|
play_logs = json.load(file)
|
||||||
|
|
||||||
with open('Table_output_V4.json', 'r', encoding='utf-8') as file:
|
with open('Table_output_V4.json', 'r', encoding='utf-8') as file:
|
||||||
@@ -118,7 +138,7 @@ for log in play_logs:
|
|||||||
if level is None:
|
if level is None:
|
||||||
continue
|
continue
|
||||||
multiplier = calculate_multiplier(max_score)
|
multiplier = calculate_multiplier(max_score)
|
||||||
rate = round(multiplier * level, 1)
|
rate = multiplier * level
|
||||||
grade_name = grade_to_name(music_grade)
|
grade_name = grade_to_name(music_grade)
|
||||||
|
|
||||||
start_time = levels_dict[music_id]["start_time"]
|
start_time = levels_dict[music_id]["start_time"]
|
||||||
@@ -126,24 +146,52 @@ for log in play_logs:
|
|||||||
|
|
||||||
if music_name not in music_rates:
|
if music_name not in music_rates:
|
||||||
music_rates[music_name] = []
|
music_rates[music_name] = []
|
||||||
music_rates[music_name].append((grade_name, rate, max_score))
|
music_rates[music_name].append((grade_name, rate, max_score, music_id, music_grade))
|
||||||
|
|
||||||
best_50.append((music_name, grade_name, rate, max_score))
|
best_50.append((music_name, grade_name, rate, max_score, level, music_id))
|
||||||
|
|
||||||
# for music_name, grades_rates in music_rates.items():
|
# for music_name, grades_rates in music_rates.items():
|
||||||
# print(f"\n{music_name}")
|
# print(f"\n{music_name}")
|
||||||
# for grade_name, rate, max_score in grades_rates:
|
# for grade_name, rate, max_score, music_id, music_grade in grades_rates:
|
||||||
# if rate > 0:
|
# if rate > 0:
|
||||||
# print(f" 难度: {grade_name:<16} 分数: {max_score} Rate: {rate:.1f}")
|
# level = levels_dict[music_id]["levels"][music_grade]
|
||||||
|
# print(f" 难度: {grade_name} 定数: {level:.1f} 分数: {max_score} Rate: {rate:.3f}")
|
||||||
|
|
||||||
best_50_sorted = sorted(best_50, key=lambda x: x[2], reverse=True)[:50]
|
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_total = sum(rate for _, _, rate, _ in best_50_sorted)
|
best_50_total = sum(rate for _, _, rate, _, _, _ in best_50_sorted)
|
||||||
|
|
||||||
print("\nBest 50:\n")
|
best_50_first_rate = best_50_sorted[0][2]
|
||||||
for music_name, grade_name, rate, max_score in best_50_sorted:
|
best_50_last_rate = best_50_sorted[49][2]
|
||||||
print(f"{music_name}\n 难度: {grade_name} 分数: {max_score} Rate: {rate:.1f}\n")
|
|
||||||
|
|
||||||
print("\n")
|
b50_json = []
|
||||||
|
alt15_json = []
|
||||||
|
|
||||||
print(f"\nBest 50 合计: {best_50_total:.1f}")
|
for music_name, grade_name, rate, max_score, level, music_id in best_50_sorted:
|
||||||
|
# print(f"{music_name}\n 难度: {grade_name} 定数: {level:.1f} 分数: {max_score} Rate: {rate:.3f}\n")
|
||||||
|
lv = f'{level:.1f}'
|
||||||
|
lv = float(lv)
|
||||||
|
rt = f'{rate:.3f}'
|
||||||
|
rt = float(rt)
|
||||||
|
b50_json.append(json_template(music_name, grade_name, lv, max_score, rt, music_id))
|
||||||
|
|
||||||
|
for music_name, grade_name, rate, max_score, level, music_id in best_50_alternate:
|
||||||
|
# print(f"{music_name}\n 难度: {grade_name} 定数: {level:.1f} 分数: {max_score} Rate: {rate:.3f}\n")
|
||||||
|
lv = f'{level:.1f}'
|
||||||
|
lv = float(lv)
|
||||||
|
rt = f'{rate:.3f}'
|
||||||
|
rt = float(rt)
|
||||||
|
alt15_json.append(json_template(music_name, grade_name, lv, max_score, rt, music_id))
|
||||||
|
|
||||||
|
total = f'{best_50_total:.3f}'
|
||||||
|
total = float(total)
|
||||||
|
data = output_json_template(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')
|
||||||
|
|
||||||
|
# print(f"\nBest 35 单曲最高: {best_50_first_rate:.3f}")
|
||||||
|
# print(f"\nBest 35 单曲最低: {best_50_last_rate:.3f}")
|
||||||
|
#
|
||||||
|
# print(f"\nBest 50 合计: {best_50_total:.3f}")
|
||||||
|
|||||||
Reference in New Issue
Block a user