Change something about constant table and aggregate

This commit is contained in:
Lost-MSth
2022-01-24 21:44:37 +08:00
parent 4666c9c153
commit d9a543bc5a
6 changed files with 1142 additions and 1136 deletions

View File

@@ -40,14 +40,6 @@ app.register_blueprint(api.api_main.bp)
conn1, conn2 = Pipe() conn1, conn2 = Pipe()
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'}
def add_url_prefix(url, strange_flag=False): def add_url_prefix(url, strange_flag=False):
# 给url加前缀返回字符串 # 给url加前缀返回字符串
@@ -243,7 +235,7 @@ def aggregate():
request.args = ImmutableMultiDict( request.args = ImmutableMultiDict(
{key: value[0] for key, value in parse_qs(urlparse(url).query).items()}) {key: value[0] for key, value in parse_qs(urlparse(url).query).items()})
resp_t = app.view_functions[map_dict[urlparse(endpoint).path]]() resp_t = map_dict[urlparse(endpoint).path]()
if hasattr(resp_t, "response"): if hasattr(resp_t, "response"):
resp_t = resp_t.response[0].decode().rstrip('\n') resp_t = resp_t.response[0].decode().rstrip('\n')
@@ -807,6 +799,15 @@ def sys_set(user_id, path):
return error_return(108) return error_return(108)
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}
def main(): def main():
log_dict = { log_dict = {
'version': 1, 'version': 1,

File diff suppressed because it is too large Load Diff

View File

@@ -11,11 +11,6 @@ import time
import random import random
ETO_UNCAP_BONUS_PROGRESS = 7
LUNA_UNCAP_BONUS_PROGRESS = 7
AYU_UNCAP_BONUS_PROGRESS = 5
def int2b(x): def int2b(x):
# int与布尔值转换 # int与布尔值转换
if x is None or x == 0: if x is None or x == 0:
@@ -28,7 +23,7 @@ def calc_stamina(max_stamina_ts, curr_stamina):
# 计算体力,返回剩余体力数值 # 计算体力,返回剩余体力数值
stamina = int(Constant.MAX_STAMINA - (max_stamina_ts - stamina = int(Constant.MAX_STAMINA - (max_stamina_ts -
int(time.time()*1000)) / Constant.STAMINA_RECOVER_TICK) int(time.time()*1000)) / Constant.STAMINA_RECOVER_TICK)
if stamina >= Constant.MAX_STAMINA: if stamina >= Constant.MAX_STAMINA:
if curr_stamina >= Constant.MAX_STAMINA: if curr_stamina >= Constant.MAX_STAMINA:
@@ -470,7 +465,7 @@ def world_update(c, user_id, song_id, difficulty, rating, clear_type, beyond_gau
if fragment_flag: if fragment_flag:
break break
if fragment_flag: if fragment_flag:
character_bonus_progress = ETO_UNCAP_BONUS_PROGRESS character_bonus_progress = Constant.ETO_UNCAP_BONUS_PROGRESS
step += character_bonus_progress * step_times step += character_bonus_progress * step_times
rewards, steps, curr_position, curr_capture, info = climb_step( rewards, steps, curr_position, curr_capture, info = climb_step(
user_id, map_id, step, y[3], y[2]) # 二次爬梯,重新计算 user_id, map_id, step, y[3], y[2]) # 二次爬梯,重新计算
@@ -478,7 +473,7 @@ def world_update(c, user_id, song_id, difficulty, rating, clear_type, beyond_gau
elif skill_special == 'luna_uncap': elif skill_special == 'luna_uncap':
# luna觉醒技能限制格开始时世界模式进度加7 # luna觉醒技能限制格开始时世界模式进度加7
if 'restrict_id' in steps[0] and 'restrict_type' in steps[0] and steps[0]['restrict_type'] != '' and steps[0]['restrict_id'] != '': if 'restrict_id' in steps[0] and 'restrict_type' in steps[0] and steps[0]['restrict_type'] != '' and steps[0]['restrict_id'] != '':
character_bonus_progress = LUNA_UNCAP_BONUS_PROGRESS character_bonus_progress = Constant.LUNA_UNCAP_BONUS_PROGRESS
step += character_bonus_progress * step_times step += character_bonus_progress * step_times
rewards, steps, curr_position, curr_capture, info = climb_step( rewards, steps, curr_position, curr_capture, info = climb_step(
user_id, map_id, step, y[3], y[2]) # 二次爬梯,重新计算 user_id, map_id, step, y[3], y[2]) # 二次爬梯,重新计算
@@ -486,9 +481,9 @@ def world_update(c, user_id, song_id, difficulty, rating, clear_type, beyond_gau
elif skill_special == 'ayu_uncap': elif skill_special == 'ayu_uncap':
# ayu觉醒技能世界模式进度+5或-5但不会小于0 # ayu觉醒技能世界模式进度+5或-5但不会小于0
if random.random() >= 0.5: if random.random() >= 0.5:
character_bonus_progress = AYU_UNCAP_BONUS_PROGRESS character_bonus_progress = Constant.AYU_UNCAP_BONUS_PROGRESS
else: else:
character_bonus_progress = -AYU_UNCAP_BONUS_PROGRESS character_bonus_progress = -Constant.AYU_UNCAP_BONUS_PROGRESS
step += character_bonus_progress * step_times step += character_bonus_progress * step_times
if step < 0: if step < 0:
@@ -516,7 +511,7 @@ def world_update(c, user_id, song_id, difficulty, rating, clear_type, beyond_gau
c.execute('''update user_char set level=?, exp=? where user_id=? and character_id=?''', c.execute('''update user_char set level=?, exp=? where user_id=? and character_id=?''',
(level, exp, user_id, character_id)) (level, exp, user_id, character_id))
else: else:
exp = server.character.LEVEL_STEPS[level] exp = Constant.LEVEL_STEPS[level]
if beyond_gauge == 0: if beyond_gauge == 0:
re = { re = {

View File

@@ -1,12 +1,10 @@
from setting import Config from setting import Config
from server.sql import Connect from server.sql import Connect
from .config import Constant
import server.info import server.info
import server.item import server.item
import server.setme import server.setme
LEVEL_STEPS = {1: 0, 2: 50, 3: 100, 4: 150, 5: 200, 6: 300, 7: 450, 8: 650, 9: 900, 10: 1200, 11: 1600, 12: 2100, 13: 2700, 14: 3400, 15: 4200, 16: 5100,
17: 6100, 18: 7200, 19: 8500, 20: 10000, 21: 11500, 22: 13000, 23: 14500, 24: 16000, 25: 17500, 26: 19000, 27: 20500, 28: 22000, 29: 23500, 30: 25000}
def int2b(x): def int2b(x):
# int与布尔值转换 # int与布尔值转换
@@ -18,7 +16,7 @@ def int2b(x):
def get_level_steps(): def get_level_steps():
# 返回level_steps字典数组 # 返回level_steps字典数组
return [{'level': i, 'level_exp': LEVEL_STEPS[i]} for i in LEVEL_STEPS] return [{'level': i, 'level_exp': Constant.LEVEL_STEPS[i]} for i in Constant.LEVEL_STEPS]
def calc_char_value(level, value1, value20, value30): def calc_char_value(level, value1, value20, value30):
@@ -114,7 +112,7 @@ def get_user_character(c, user_id):
"overdrive": calc_char_value(i[2], i[11], i[14], i[17]), "overdrive": calc_char_value(i[2], i[11], i[14], i[17]),
"prog": calc_char_value(i[2], i[10], i[13], i[16]), "prog": calc_char_value(i[2], i[10], i[13], i[16]),
"frag": calc_char_value(i[2], i[9], i[12], i[15]), "frag": calc_char_value(i[2], i[9], i[12], i[15]),
"level_exp": LEVEL_STEPS[i[2]], "level_exp": Constant.LEVEL_STEPS[i[2]],
"exp": i[3], "exp": i[3],
"level": i[2], "level": i[2],
"name": i[7], "name": i[7],
@@ -151,7 +149,7 @@ def get_one_character(c, user_id, character_id):
"overdrive": calc_char_value(x[2], x[11], x[14], x[17]), "overdrive": calc_char_value(x[2], x[11], x[14], x[17]),
"prog": calc_char_value(x[2], x[10], x[13], x[16]), "prog": calc_char_value(x[2], x[10], x[13], x[16]),
"frag": calc_char_value(x[2], x[9], x[12], x[15]), "frag": calc_char_value(x[2], x[9], x[12], x[15]),
"level_exp": LEVEL_STEPS[x[2]], "level_exp": Constant.LEVEL_STEPS[x[2]],
"exp": x[3], "exp": x[3],
"level": x[2], "level": x[2],
"name": x[7], "name": x[7],
@@ -168,18 +166,18 @@ def calc_level_up(c, user_id, character_id, exp, exp_addition):
exp += exp_addition exp += exp_addition
if exp >= LEVEL_STEPS[20]: # 未觉醒溢出 if exp >= Constant.LEVEL_STEPS[20]: # 未觉醒溢出
c.execute('''select is_uncapped from user_char where user_id=? and character_id=?''', c.execute('''select is_uncapped from user_char where user_id=? and character_id=?''',
(user_id, character_id)) (user_id, character_id))
x = c.fetchone() x = c.fetchone()
if x and x[0] == 0: if x and x[0] == 0:
return LEVEL_STEPS[20], 20 return Constant.LEVEL_STEPS[20], 20
a = [] a = []
b = [] b = []
for i in LEVEL_STEPS: for i in Constant.LEVEL_STEPS:
a.append(i) a.append(i)
b.append(LEVEL_STEPS[i]) b.append(Constant.LEVEL_STEPS[i])
if exp >= b[-1]: # 溢出 if exp >= b[-1]: # 溢出
return b[-1], a[-1] return b[-1], a[-1]
@@ -215,9 +213,9 @@ def char_use_core(user_id, character_id, amount):
exp, level = calc_level_up( exp, level = calc_level_up(
c, user_id, character_id, x[0], amount*Config.CORE_EXP) c, user_id, character_id, x[0], amount*Config.CORE_EXP)
c.execute('''update user_char set level=?, exp=? where user_id=? and character_id=?''', c.execute('''update user_char set level=?, exp=? where user_id=? and character_id=?''',
(level, exp, user_id, character_id)) (level, exp, user_id, character_id))
server.item.claim_user_item( server.item.claim_user_item(
c, user_id, 'core_generic', 'core', -amount) c, user_id, 'core_generic', 'core', -amount)
r = {'character': [get_one_character(c, user_id, character_id)]} r = {'character': [get_one_character(c, user_id, character_id)]}
r['cores'] = server.item.get_user_cores(c, user_id) r['cores'] = server.item.get_user_cores(c, user_id)

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
from server.sql import Connect from server.sql import Connect
from setting import Config from setting import Config
from .config import Constant
import server.info import server.info
import server.character import server.character
@@ -90,7 +91,7 @@ def change_char_uncap(user_id, character_id):
"overdrive": server.character.calc_char_value(y[2], y[11], y[14], y[17]), "overdrive": server.character.calc_char_value(y[2], y[11], y[14], y[17]),
"prog": server.character.calc_char_value(y[2], y[10], y[13], y[16]), "prog": server.character.calc_char_value(y[2], y[10], y[13], y[16]),
"frag": server.character.calc_char_value(y[2], y[9], y[12], y[15]), "frag": server.character.calc_char_value(y[2], y[9], y[12], y[15]),
"level_exp": server.character.LEVEL_STEPS[y[2]], "level_exp": Constant.LEVEL_STEPS[y[2]],
"exp": y[3], "exp": y[3],
"level": y[2], "level": y[2],
"name": y[7], "name": y[7],