mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2025-12-14 08:06:23 +08:00
[Enhance][Bug fix] ETR world score & Finale & Bundle Update Message
- Start to consider the ETR scores when getting the sum of all scores in global ranking. - Add support for automatically adding partner "Hikari & Tairitsu (Reunion)" and "Hikari (Fatalis)", to try to unlock Finale stories correctly. #110 #164 - Fix a bug that the POST requests will be neglected if a new content bundle update exists.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from .config_manager import Config
|
||||
|
||||
ARCAEA_SERVER_VERSION = 'v2.11.3.11'
|
||||
ARCAEA_SERVER_VERSION = 'v2.11.3.12'
|
||||
ARCAEA_DATABASE_VERSION = 'v2.11.3.11'
|
||||
ARCAEA_LOG_DATBASE_VERSION = 'v1.1'
|
||||
|
||||
|
||||
@@ -155,7 +155,6 @@ class UserRegister(User):
|
||||
''', {'user_code': self.user_code, 'user_id': self.user_id, 'join_date': now, 'name': self.name, 'password': self.hash_pwd, 'memories': Config.DEFAULT_MEMORIES, 'email': self.email})
|
||||
|
||||
|
||||
|
||||
class UserLogin(User):
|
||||
# 密码和token的加密方式为 SHA-256
|
||||
limiter = ArcLimiter(Config.GAME_LOGIN_RATE_LIMIT, 'game_login')
|
||||
@@ -663,38 +662,28 @@ class UserInfo(User):
|
||||
def update_global_rank(self) -> None:
|
||||
'''用户世界排名计算,有新增成绩则要更新'''
|
||||
|
||||
self.c.execute('''select song_id, rating_ftr, rating_byn from chart''')
|
||||
x = self.c.fetchall()
|
||||
|
||||
song_list_ftr = [self.user_id]
|
||||
song_list_byn = [self.user_id]
|
||||
for i in x:
|
||||
if i[1] > 0:
|
||||
song_list_ftr.append(i[0])
|
||||
if i[2] > 0:
|
||||
song_list_byn.append(i[0])
|
||||
|
||||
score_sum = 0
|
||||
if len(song_list_ftr) >= 2:
|
||||
self.c.execute(
|
||||
f'''select sum(score) from best_score where user_id=? and difficulty=2 and song_id in ({','.join(['?']*(len(song_list_ftr)-1))})''', tuple(song_list_ftr))
|
||||
|
||||
'''
|
||||
with user_scores as (
|
||||
select song_id, difficulty, score from best_score where user_id = ? and difficulty in (2, 3, 4)
|
||||
)
|
||||
select sum(a) from(
|
||||
select sum(score) as a from user_scores where difficulty = 2 and song_id in (select song_id from chart where rating_ftr > 0)
|
||||
union
|
||||
select sum(score) as a from user_scores where difficulty = 3 and song_id in (select song_id from chart where rating_byn > 0)
|
||||
union
|
||||
select sum(score) as a from user_scores where difficulty = 4 and song_id in (select song_id from chart where rating_etr > 0)
|
||||
)
|
||||
''',
|
||||
(self.user_id,)
|
||||
)
|
||||
x = self.c.fetchone()
|
||||
if x[0] is not None:
|
||||
score_sum += x[0]
|
||||
if x[0] is None:
|
||||
return
|
||||
|
||||
if len(song_list_byn) >= 2:
|
||||
self.c.execute(
|
||||
f'''select sum(score) from best_score where user_id=? and difficulty=3 and song_id in ({','.join(['?']*(len(song_list_byn)-1))})''', tuple(song_list_byn))
|
||||
|
||||
x = self.c.fetchone()
|
||||
if x[0] is not None:
|
||||
score_sum += x[0]
|
||||
|
||||
self.c.execute('''update user set world_rank_score = :b where user_id = :a''', {
|
||||
'a': self.user_id, 'b': score_sum})
|
||||
|
||||
self.world_rank_score = score_sum
|
||||
'''update user set world_rank_score = ? where user_id = ?''', (x[0], self.user_id))
|
||||
self.world_rank_score = x[0]
|
||||
|
||||
def select_user_one_column(self, column_name: str, default_value=None) -> None:
|
||||
'''
|
||||
|
||||
@@ -110,7 +110,7 @@ def header_check(request) -> ArcError:
|
||||
if Config.ALLOW_APPVERSION: # 版本检查
|
||||
if 'AppVersion' not in headers or headers['AppVersion'] not in Config.ALLOW_APPVERSION:
|
||||
return LowVersion('Invalid app version', 5)
|
||||
if 'ContentBundle' in headers and headers['ContentBundle'] != BundleParser.max_bundle_version.get(headers.get('AppVersion', ''), '0.0.0'):
|
||||
if request.method == 'GET' and 'ContentBundle' in headers and headers['ContentBundle'] != BundleParser.max_bundle_version.get(headers.get('AppVersion', ''), '0.0.0'):
|
||||
return LowVersion('Invalid content bundle version', 11)
|
||||
|
||||
if has_arc_hash and not ArcHashChecker(request).check():
|
||||
|
||||
@@ -7,6 +7,7 @@ from werkzeug.datastructures import ImmutableMultiDict
|
||||
from core.bundle import BundleDownload
|
||||
from core.download import DownloadList
|
||||
from core.error import RateLimit
|
||||
from core.item import ItemCharacter
|
||||
from core.sql import Connect
|
||||
from core.system import GameInfo
|
||||
from core.user import UserOnline
|
||||
@@ -14,7 +15,7 @@ from core.user import UserOnline
|
||||
from .auth import auth_required
|
||||
from .func import arc_try, error_return, success_return
|
||||
from .present import present_info
|
||||
from .purchase import bundle_bundle, get_single, bundle_pack
|
||||
from .purchase import bundle_bundle, bundle_pack, get_single
|
||||
from .score import song_score_friend
|
||||
from .user import user_me
|
||||
from .world import world_all
|
||||
@@ -65,14 +66,28 @@ def finale_progress():
|
||||
|
||||
|
||||
@bp.route('/finale/finale_start', methods=['POST'])
|
||||
def finale_start():
|
||||
@auth_required(request)
|
||||
@arc_try
|
||||
def finale_start(user_id):
|
||||
# testify开始,对立再见
|
||||
# 没数据
|
||||
# 但是对立不再见
|
||||
|
||||
with Connect() as c:
|
||||
item = ItemCharacter(c)
|
||||
item.set_id('55') # Hikari (Fatalis)
|
||||
item.user_claim_item(UserOnline(c, user_id))
|
||||
return success_return({})
|
||||
|
||||
|
||||
@bp.route('/finale/finale_end', methods=['POST'])
|
||||
def finale_end():
|
||||
@auth_required(request)
|
||||
@arc_try
|
||||
def finale_end(user_id):
|
||||
|
||||
with Connect() as c:
|
||||
item = ItemCharacter(c)
|
||||
item.set_id('5') # Hikari & Tairitsu (Reunion)
|
||||
item.user_claim_item(UserOnline(c, user_id))
|
||||
return success_return({})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user