mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-10 01:37:27 +08:00
@@ -402,7 +402,7 @@ def all_character():
|
||||
def change_character():
|
||||
# 修改角色数据
|
||||
skill_ids = ['No_skill', 'gauge_easy', 'note_mirror', 'gauge_hard', 'frag_plus_10_pack_stellights', 'gauge_easy|frag_plus_15_pst&prs', 'gauge_hard|fail_frag_minus_100', 'frag_plus_5_side_light', 'visual_hide_hp', 'frag_plus_5_side_conflict', 'challenge_fullcombo_0gauge', 'gauge_overflow', 'gauge_easy|note_mirror', 'note_mirror', 'visual_tomato_pack_tonesphere',
|
||||
'frag_rng_ayu', 'gaugestart_30|gaugegain_70', 'combo_100-frag_1', 'audio_gcemptyhit_pack_groovecoaster', 'gauge_saya', 'gauge_chuni', 'kantandeshou', 'gauge_haruna', 'frags_nono', 'gauge_pandora', 'gauge_regulus', 'omatsuri_daynight', 'sometimes(note_mirror|frag_plus_5)', 'scoreclear_aa|visual_scoregauge', 'gauge_tempest', 'gauge_hard', 'gauge_ilith_summer', 'frags_kou', 'visual_ink', 'shirabe_entry_fee', 'frags_yume']
|
||||
'frag_rng_ayu', 'gaugestart_30|gaugegain_70', 'combo_100-frag_1', 'audio_gcemptyhit_pack_groovecoaster', 'gauge_saya', 'gauge_chuni', 'kantandeshou', 'gauge_haruna', 'frags_nono', 'gauge_pandora', 'gauge_regulus', 'omatsuri_daynight', 'sometimes(note_mirror|frag_plus_5)', 'scoreclear_aa|visual_scoregauge', 'gauge_tempest', 'gauge_hard', 'gauge_ilith_summer', 'frags_kou', 'visual_ink', 'shirabe_entry_fee', 'frags_yume', 'note_mirror|visual_hide_far']
|
||||
return render_template('web/changechar.html', skill_ids=skill_ids)
|
||||
|
||||
|
||||
@@ -564,7 +564,6 @@ def edit_user():
|
||||
'''select user_id from user where name=:a''', {'a': name})
|
||||
|
||||
user_id = c.fetchone()
|
||||
posts = []
|
||||
if user_id:
|
||||
user_id = user_id[0]
|
||||
|
||||
@@ -642,7 +641,6 @@ def edit_user_purchase():
|
||||
'''select user_id from user where name=:a''', {'a': name})
|
||||
|
||||
user_id = c.fetchone()
|
||||
posts = []
|
||||
if user_id:
|
||||
user_id = user_id[0]
|
||||
|
||||
@@ -717,11 +715,13 @@ def change_item():
|
||||
else:
|
||||
orig_price = None
|
||||
if discount_from:
|
||||
discount_from = int(time.mktime(time.strptime(discount_from, "%Y-%m-%dT%H:%M"))) * 1000
|
||||
discount_from = int(time.mktime(time.strptime(
|
||||
discount_from, "%Y-%m-%dT%H:%M"))) * 1000
|
||||
else:
|
||||
discount_from = None
|
||||
if discount_to:
|
||||
discount_to = int(time.mktime(time.strptime(discount_to, "%Y-%m-%dT%H:%M"))) * 1000
|
||||
discount_to = int(time.mktime(time.strptime(
|
||||
discount_to, "%Y-%m-%dT%H:%M"))) * 1000
|
||||
else:
|
||||
discount_to = None
|
||||
except:
|
||||
@@ -767,3 +767,60 @@ def change_item():
|
||||
flash(error)
|
||||
|
||||
return render_template('web/changeitem.html')
|
||||
|
||||
|
||||
@bp.route('/updateusersave', methods=['POST', 'GET'])
|
||||
@login_required
|
||||
def update_user_save():
|
||||
# 将用户存档覆盖到分数表中
|
||||
|
||||
if request.method == 'GET':
|
||||
return render_template('web/updateusersave.html')
|
||||
|
||||
error = None
|
||||
flag = True
|
||||
name = None
|
||||
user_code = None
|
||||
|
||||
conn = sqlite3.connect('./database/arcaea_database.db')
|
||||
c = conn.cursor()
|
||||
|
||||
# 全修改
|
||||
if 'name' not in request.form and 'user_code' not in request.form:
|
||||
flag = False
|
||||
web.system.update_all_save(c)
|
||||
flash("全部用户存档同步成功 Successfully update all users' saves.")
|
||||
|
||||
else:
|
||||
name = request.form['name']
|
||||
user_code = request.form['user_code']
|
||||
|
||||
# 指定修改
|
||||
if name or user_code:
|
||||
|
||||
if user_code:
|
||||
c.execute('''select user_id from user where user_code=:a''', {
|
||||
'a': user_code})
|
||||
else:
|
||||
c.execute(
|
||||
'''select user_id from user where name=:a''', {'a': name})
|
||||
|
||||
user_id = c.fetchone()
|
||||
if user_id:
|
||||
user_id = user_id[0]
|
||||
web.system.update_one_save(c, user_id)
|
||||
flash("用户存档同步成功 Successfully update the user's saves.")
|
||||
|
||||
else:
|
||||
error = '玩家不存在 The player does not exist.'
|
||||
|
||||
else:
|
||||
if flag:
|
||||
error = '输入为空 Null Input.'
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
if error:
|
||||
flash(error)
|
||||
|
||||
return render_template('web/updateusersave.html')
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import os
|
||||
import sqlite3
|
||||
import time
|
||||
import json
|
||||
import server.arcscore
|
||||
|
||||
|
||||
def int2b(x):
|
||||
@@ -140,7 +142,7 @@ def update_user_char(c):
|
||||
|
||||
def update_database():
|
||||
# 将old数据库不存在数据加入到新数据库上,并删除old数据库
|
||||
# 对于arcaea_datebase.db,更新best_score,friend,recent30,user,user_world, user_item并用character数据更新user_char
|
||||
# 对于arcaea_datebase.db,更新best_score,friend,recent30,user,user_world, user_item, user_save并用character数据更新user_char
|
||||
# 对于arcsong.db,更新songs
|
||||
if os.path.isfile("database/old_arcaea_database.db") and os.path.isfile("database/arcaea_database.db"):
|
||||
conn1 = sqlite3.connect('./database/old_arcaea_database.db')
|
||||
@@ -154,6 +156,7 @@ def update_database():
|
||||
update_one_table(c1, c2, 'recent30')
|
||||
update_one_table(c1, c2, 'user_world')
|
||||
update_one_table(c1, c2, 'user_item')
|
||||
update_one_table(c1, c2, 'user_save')
|
||||
|
||||
update_user_char(c2)
|
||||
|
||||
@@ -243,3 +246,55 @@ def get_all_item():
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return re
|
||||
|
||||
|
||||
def update_one_save(c, user_id):
|
||||
# 同步指定用户存档
|
||||
# 注意,best_score表不比较,直接覆盖
|
||||
|
||||
c.execute('''select scores_data, clearlamps_data from user_save where user_id=:a''', {
|
||||
'a': user_id})
|
||||
x = c.fetchone()
|
||||
if x:
|
||||
scores = json.loads(x[0])[""]
|
||||
clearlamps = json.loads(x[1])[""]
|
||||
clear_song_id_difficulty = []
|
||||
clear_state = []
|
||||
for i in clearlamps:
|
||||
clear_song_id_difficulty.append(i['song_id']+str(i['difficulty']))
|
||||
clear_state.append(i['clear_type'])
|
||||
|
||||
for i in scores:
|
||||
rating = server.arcscore.get_one_ptt(
|
||||
i['song_id'], i['difficulty'], i['score'])
|
||||
try:
|
||||
index = clear_song_id_difficulty.index(
|
||||
i['song_id'] + str(i['difficulty']))
|
||||
except:
|
||||
index = -1
|
||||
if index != -1:
|
||||
clear_type = clear_state[index]
|
||||
else:
|
||||
clear_type = 0
|
||||
c.execute('''delete from best_score where user_id=:a and song_id=:b and difficulty=:c''', {
|
||||
'a': user_id, 'b': i['song_id'], 'c': i['difficulty']})
|
||||
c.execute('''insert into best_score values(:a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :m, :n)''', {
|
||||
'a': user_id, 'b': i['song_id'], 'c': i['difficulty'], 'd': i['score'], 'e': i['shiny_perfect_count'], 'f': i['perfect_count'], 'g': i['near_count'], 'h': i['miss_count'], 'i': i['health'], 'j': i['modifier'], 'k': i['time_played'], 'l': clear_type, 'm': clear_type, 'n': rating})
|
||||
|
||||
ptt = server.arcscore.get_user_ptt(c, user_id) # 更新PTT
|
||||
c.execute('''update user set rating_ptt=:a where user_id=:b''', {
|
||||
'a': ptt, 'b': user_id})
|
||||
|
||||
return
|
||||
|
||||
|
||||
def update_all_save(c):
|
||||
# 同步所有用户存档
|
||||
|
||||
c.execute('''select user_id from user_save''')
|
||||
x = c.fetchall()
|
||||
if x:
|
||||
for i in x:
|
||||
update_one_save(c, i[0])
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user