mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-13 03:27:26 +08:00
[Enhance] API for redeem
- Add API endpoints for redeem system
- Continue to fix the bug mentioned in 930faf508d
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from time import time
|
||||
|
||||
from .config import Config
|
||||
|
||||
|
||||
@@ -79,8 +81,27 @@ class Room:
|
||||
|
||||
@property
|
||||
def player_num(self) -> int:
|
||||
self.check_player_online()
|
||||
return sum(i.player_id != 0 for i in self.players)
|
||||
|
||||
def check_player_online(self, now: int = None):
|
||||
# 检测玩家是否被自动踢出房间 / 离线判断
|
||||
now = round(time() * 1000000) if now is None else now
|
||||
flag = False
|
||||
player_index_list = []
|
||||
for i, x in enumerate(self.players):
|
||||
if x.player_id == 0 or x.last_timestamp == 0:
|
||||
continue
|
||||
if now - x.last_timestamp >= Config.PLAYER_TIMEOUT:
|
||||
self.delete_player(i)
|
||||
flag = True
|
||||
player_index_list.append(i)
|
||||
elif x.online == 1 and now - x.last_timestamp >= Config.PLAYER_PRE_TIMEOUT:
|
||||
x.online = 0
|
||||
player_index_list.append(i)
|
||||
|
||||
return flag, player_index_list
|
||||
|
||||
def get_players_info(self):
|
||||
# 获取所有玩家信息
|
||||
re = b''
|
||||
|
||||
Reference in New Issue
Block a user