mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-11 02:17:28 +08:00
Add experimental aggregate API
This commit is contained in:
@@ -26,14 +26,14 @@ def int2b(x):
|
||||
def calc_stamina(max_stamina_ts, curr_stamina):
|
||||
# 计算体力,返回剩余体力数值
|
||||
|
||||
stamina = int(server.info.MAX_STAMINA - (max_stamina_ts -
|
||||
int(time.time()*1000)) / server.info.STAMINA_RECOVER_TICK)
|
||||
stamina = int(Config.MAX_STAMINA - (max_stamina_ts -
|
||||
int(time.time()*1000)) / Config.STAMINA_RECOVER_TICK)
|
||||
|
||||
if stamina >= server.info.MAX_STAMINA:
|
||||
if curr_stamina >= server.info.MAX_STAMINA:
|
||||
if stamina >= Config.MAX_STAMINA:
|
||||
if curr_stamina >= Config.MAX_STAMINA:
|
||||
stamina = curr_stamina
|
||||
else:
|
||||
stamina = server.info.MAX_STAMINA
|
||||
stamina = Config.MAX_STAMINA
|
||||
if stamina < 0:
|
||||
stamina = 0
|
||||
|
||||
@@ -245,8 +245,8 @@ def play_world_song(user_id, args):
|
||||
return {}
|
||||
stamina = calc_stamina(max_stamina_ts, stamina) - \
|
||||
info['stamina_cost'] * stamina_multiply
|
||||
max_stamina_ts = now + server.info.STAMINA_RECOVER_TICK * \
|
||||
(server.info.MAX_STAMINA - stamina)
|
||||
max_stamina_ts = now + Config.STAMINA_RECOVER_TICK * \
|
||||
(Config.MAX_STAMINA - stamina)
|
||||
c.execute('''update user set max_stamina_ts=?, stamina=? where user_id=?''',
|
||||
(max_stamina_ts, stamina, user_id))
|
||||
r = {
|
||||
@@ -600,11 +600,11 @@ def add_stamina(c, user_id, add_stamina):
|
||||
if x and x[0] is not None and x[1] is not None:
|
||||
stamina = calc_stamina(x[0], x[1]) + add_stamina
|
||||
max_stamina_ts = now - \
|
||||
(stamina-server.info.MAX_STAMINA) * \
|
||||
server.info.STAMINA_RECOVER_TICK
|
||||
(stamina-Config.MAX_STAMINA) * \
|
||||
Config.STAMINA_RECOVER_TICK
|
||||
else:
|
||||
max_stamina_ts = now
|
||||
stamina = server.info.MAX_STAMINA
|
||||
stamina = Config.MAX_STAMINA
|
||||
|
||||
c.execute('''update user set max_stamina_ts=?, stamina=? where user_id=?''',
|
||||
(max_stamina_ts, stamina, user_id))
|
||||
|
||||
@@ -213,7 +213,7 @@ def char_use_core(user_id, character_id, amount):
|
||||
x = c.fetchone()
|
||||
if x:
|
||||
exp, level = calc_level_up(
|
||||
c, user_id, character_id, x[0], amount*server.info.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=?''',
|
||||
(level, exp, user_id, character_id))
|
||||
server.item.claim_user_item(
|
||||
|
||||
@@ -7,9 +7,6 @@ import server.item
|
||||
import time
|
||||
from setting import Config
|
||||
|
||||
MAX_STAMINA = 12
|
||||
STAMINA_RECOVER_TICK = 1800000
|
||||
CORE_EXP = 250
|
||||
|
||||
|
||||
def int2b(x):
|
||||
@@ -214,6 +211,28 @@ def arc_aggregate_small(user_id):
|
||||
|
||||
return r
|
||||
|
||||
def get_purchase_pack(user_id):
|
||||
# 返回曲包数据
|
||||
with Connect() as c:
|
||||
return server.arcpurchase.get_purchase(c, 'pack')
|
||||
|
||||
def get_game_info():
|
||||
# 返回游戏基本信息
|
||||
r={
|
||||
"max_stamina": Config.MAX_STAMINA,
|
||||
"stamina_recover_tick": Config.STAMINA_RECOVER_TICK,
|
||||
"core_exp": Config.CORE_EXP,
|
||||
"curr_ts": int(time.time()*1000),
|
||||
"level_steps": server.character.get_level_steps(),
|
||||
"world_ranking_enabled": True,
|
||||
"is_byd_chapter_unlocked": True
|
||||
}
|
||||
return r
|
||||
|
||||
def get_user_present(user_id):
|
||||
# 返回礼品信息
|
||||
with Connect() as c:
|
||||
return server.arcpurchase.get_user_present(c, user_id)
|
||||
|
||||
def arc_aggregate_big(user_id):
|
||||
# 返回比较全的用户数据
|
||||
|
||||
Reference in New Issue
Block a user