mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-13 11:47:32 +08:00
Update to v1.5
A small update.
This commit is contained in:
@@ -2,6 +2,7 @@ import sqlite3
|
||||
import time
|
||||
import json
|
||||
import server.arcworld
|
||||
import hashlib
|
||||
|
||||
|
||||
def b2int(x):
|
||||
@@ -20,6 +21,16 @@ def int2b(x):
|
||||
return True
|
||||
|
||||
|
||||
def md5(code):
|
||||
# md5加密算法
|
||||
code = code.encode()
|
||||
md5s = hashlib.md5()
|
||||
md5s.update(code)
|
||||
codes = md5s.hexdigest()
|
||||
|
||||
return codes
|
||||
|
||||
|
||||
def get_score(c, user_id, song_id, difficulty):
|
||||
# 根据user_id、song_id、难度得到该曲目最好成绩,返回字典
|
||||
c.execute('''select * from best_score where user_id = :a and song_id = :b and difficulty = :c''',
|
||||
@@ -480,6 +491,29 @@ def arc_score_post(user_id, song_id, difficulty, score, shiny_perfect_count, per
|
||||
return ptt, re
|
||||
|
||||
|
||||
def arc_score_check(user_id, song_id, difficulty, score, shiny_perfect_count, perfect_count, near_count, miss_count, health, modifier, beyond_gauge, clear_type, song_token, song_hash, submission_hash):
|
||||
# 分数校验,返回布尔值
|
||||
if shiny_perfect_count < 0 or perfect_count < 0 or near_count < 0 or miss_count < 0 or score < 0:
|
||||
return False
|
||||
if difficulty not in [0, 1, 2, 3]:
|
||||
return False
|
||||
|
||||
all_note = perfect_count + near_count + miss_count
|
||||
ascore = 10000000 / all_note * \
|
||||
(perfect_count + near_count/2) + shiny_perfect_count
|
||||
if abs(ascore - score) >= 5:
|
||||
return False
|
||||
|
||||
x = song_token + song_hash + song_id + str(difficulty) + str(score) + str(shiny_perfect_count) + str(
|
||||
perfect_count) + str(near_count) + str(miss_count) + str(health) + str(modifier) + str(clear_type)
|
||||
y = str(user_id) + song_hash
|
||||
checksum = md5(x+md5(y))
|
||||
if checksum != submission_hash:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def arc_all_post(user_id, scores_data, clearlamps_data):
|
||||
# 向云端同步,无返回
|
||||
# 注意,best_score表不比较,直接覆盖
|
||||
|
||||
@@ -62,18 +62,6 @@ def arc_register(name: str, password: str): # 注册
|
||||
else:
|
||||
return 2000001
|
||||
|
||||
# def insert_user_char(c, user_id):
|
||||
# # 为用户添加所有可用角色
|
||||
# for i in range(0, 38):
|
||||
# if i in [0, 1, 2, 4, 13, 26, 27, 28, 29, 36, 21]:
|
||||
# sql = 'insert into user_char values('+str(user_id)+','+str(
|
||||
# i)+''',30,25000,25000,90,90,90,'',0,0,'',0,1,1)'''
|
||||
# c.execute(sql)
|
||||
# else:
|
||||
# if i != 5:
|
||||
# sql = 'insert into user_char values('+str(user_id)+','+str(
|
||||
# i)+''',30,25000,25000,90,90,90,'',0,0,'',0,0,0)'''
|
||||
# c.execute(sql)
|
||||
def insert_user_char(c, user_id):
|
||||
# 为用户添加所有可用角色
|
||||
c.execute('''select * from character''')
|
||||
|
||||
Reference in New Issue
Block a user