mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-11 18:47:26 +08:00
[Enhance] Missions & ETR
- Add support for missions - PTT mechanism: Change first play protection to new best protection - Adapt to the new difficulty ETR - Uncap DORO*C - Incomplete support for "pick_ticket" - Fix requirements: cryptography >= 35.0.0 Note: This is an intermediate test version, only for Arcaea 5.4.0c. Next version will adapt to 5.4.0.
This commit is contained in:
@@ -3,7 +3,7 @@ from flask import Blueprint, jsonify
|
||||
from core.config_manager import Config
|
||||
|
||||
from . import (auth, course, friend, multiplayer, others, present, purchase,
|
||||
score, user, world)
|
||||
score, user, world, mission)
|
||||
|
||||
|
||||
__bp_old = Blueprint('old_server', __name__)
|
||||
@@ -24,7 +24,7 @@ def get_bps():
|
||||
|
||||
bp = Blueprint('server', __name__)
|
||||
list(map(bp.register_blueprint, [user.bp, auth.bp, friend.bp, score.bp,
|
||||
world.bp, purchase.bp, present.bp, others.bp, multiplayer.bp, course.bp]))
|
||||
world.bp, purchase.bp, present.bp, others.bp, multiplayer.bp, course.bp, mission.bp]))
|
||||
|
||||
bps = [Blueprint(x, __name__, url_prefix=x)
|
||||
for x in string_to_list(Config.GAME_API_PREFIX)]
|
||||
|
||||
68
latest version/server/mission.py
Normal file
68
latest version/server/mission.py
Normal file
@@ -0,0 +1,68 @@
|
||||
from flask import Blueprint, request
|
||||
|
||||
from core.error import NoData
|
||||
from core.mission import MISSION_DICT
|
||||
from core.sql import Connect
|
||||
from core.user import UserOnline
|
||||
|
||||
from .auth import auth_required
|
||||
from .func import arc_try, success_return
|
||||
|
||||
bp = Blueprint('mission', __name__, url_prefix='/mission')
|
||||
|
||||
|
||||
def parse_mission_form(multidict) -> list:
|
||||
r = []
|
||||
|
||||
x = multidict.get('mission_1')
|
||||
i = 1
|
||||
while x:
|
||||
r.append(x)
|
||||
x = multidict.get(f'mission_{i + 1}')
|
||||
i += 1
|
||||
return r
|
||||
|
||||
|
||||
@bp.route('/me/clear', methods=['POST']) # 新手任务确认完成
|
||||
@auth_required(request)
|
||||
@arc_try
|
||||
def mission_clear(user_id):
|
||||
m = parse_mission_form(request.form)
|
||||
r = []
|
||||
for i, mission_id in enumerate(m):
|
||||
if mission_id not in MISSION_DICT:
|
||||
return NoData(f'Mission `{mission_id}` not found')
|
||||
with Connect() as c:
|
||||
x = MISSION_DICT[mission_id](c)
|
||||
x.user_clear_mission(UserOnline(c, user_id))
|
||||
d = x.to_dict()
|
||||
d['request_id'] = i + 1
|
||||
r.append(d)
|
||||
|
||||
return success_return({'missions': r})
|
||||
|
||||
|
||||
@bp.route('/me/claim', methods=['POST']) # 领取新手任务奖励
|
||||
@auth_required(request)
|
||||
@arc_try
|
||||
def mission_claim(user_id):
|
||||
m = parse_mission_form(request.form)
|
||||
r = []
|
||||
|
||||
with Connect() as c:
|
||||
user = UserOnline(c, user_id)
|
||||
|
||||
for i, mission_id in enumerate(m):
|
||||
if mission_id not in MISSION_DICT:
|
||||
return NoData(f'Mission `{mission_id}` not found')
|
||||
|
||||
x = MISSION_DICT[mission_id](c)
|
||||
x.user_claim_mission(user)
|
||||
d = x.to_dict(has_items=True)
|
||||
d['request_id'] = i + 1
|
||||
r.append(d)
|
||||
|
||||
return success_return({
|
||||
'missions': r,
|
||||
'user': user.to_dict()
|
||||
})
|
||||
@@ -13,7 +13,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, bundle_pack
|
||||
from .purchase import bundle_bundle, get_single, bundle_pack
|
||||
from .score import song_score_friend
|
||||
from .user import user_me
|
||||
from .world import world_all
|
||||
@@ -26,6 +26,28 @@ def game_info():
|
||||
return success_return(GameInfo().to_dict())
|
||||
|
||||
|
||||
# @bp.route('/game/content_bundle', methods=['GET']) # 热更新
|
||||
# def game_content_bundle():
|
||||
# app_version = request.headers.get('AppVersion')
|
||||
# bundle_version = request.headers.get('ContentBundle')
|
||||
# import os
|
||||
# if bundle_version != '5.4.0':
|
||||
# r = {'orderedResults': [
|
||||
# {
|
||||
# 'appVersion': '5.4.0',
|
||||
# 'contentBundleVersion': '5.4.0',
|
||||
# 'jsonUrl': 'http://192.168.0.110/bundle_download/bundle.json',
|
||||
# 'jsonSize': os.path.getsize('./database/bundle/bundle.json'),
|
||||
# 'bundleUrl': 'http://192.168.0.110/bundle_download/bundle',
|
||||
# 'bundleSize': os.path.getsize('./database/bundle/bundle')
|
||||
# },
|
||||
# ]
|
||||
# }
|
||||
# else:
|
||||
# r = {}
|
||||
# return success_return(r)
|
||||
|
||||
|
||||
@bp.route('/serve/download/me/song', methods=['GET']) # 歌曲下载
|
||||
@auth_required(request)
|
||||
@arc_try
|
||||
@@ -66,15 +88,18 @@ def applog_me():
|
||||
return success_return({})
|
||||
|
||||
|
||||
map_dict = {'/user/me': user_me,
|
||||
'/purchase/bundle/pack': bundle_pack,
|
||||
'/serve/download/me/song': download_song,
|
||||
'/game/info': game_info,
|
||||
'/present/me': present_info,
|
||||
'/world/map/me': world_all,
|
||||
'/score/song/friend': song_score_friend,
|
||||
'/purchase/bundle/bundle': bundle_bundle,
|
||||
'/finale/progress': finale_progress}
|
||||
map_dict = {
|
||||
'/user/me': user_me,
|
||||
'/purchase/bundle/pack': bundle_pack,
|
||||
'/serve/download/me/song': download_song,
|
||||
'/game/info': game_info,
|
||||
'/present/me': present_info,
|
||||
'/world/map/me': world_all,
|
||||
'/score/song/friend': song_score_friend,
|
||||
'/purchase/bundle/bundle': bundle_bundle,
|
||||
'/finale/progress': finale_progress,
|
||||
'/purchase/bundle/single': get_single
|
||||
}
|
||||
|
||||
|
||||
@bp.route('/compose/aggregate', methods=['GET']) # 集成式请求
|
||||
|
||||
Reference in New Issue
Block a user