mirror of
https://github.com/solero/houdini.git
synced 2024-11-12 13:48:20 +00:00
Load player sent on world join
This commit is contained in:
commit
c08e8b8260
@ -48,3 +48,5 @@ async def handle_login(p, credentials: WorldCredentials):
|
||||
p.data = data
|
||||
p.login_key = credentials.login_key
|
||||
await p.send_xt('l')
|
||||
|
||||
p.age = (datetime.now() - p.data.registration_date).days
|
||||
|
@ -2,7 +2,7 @@ from houdini import handlers
|
||||
from houdini.handlers import XTPacket
|
||||
from houdini.converters import RoomConverter
|
||||
|
||||
import random
|
||||
import random, time
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('j', 'js'), pre_login=True)
|
||||
@ -18,12 +18,23 @@ async def handle_join_server(p, penguin_id: int, login_key: str, lang: str):
|
||||
await p.send_xt('js', int(p.data.agent_status), int(0),
|
||||
int(p.data.moderator), int(p.data.book_modified))
|
||||
|
||||
#handleGetMyPlayerPuffles()
|
||||
|
||||
current_time = int(time.time())
|
||||
penguin_standard_time = current_time * 1000
|
||||
server_time_offset = 7
|
||||
|
||||
await p.send_xt('lp', await p.server.penguin_string_compiler.compile(p), p.data.coins, 0, 1440,
|
||||
penguin_standard_time, p.age, 0, p.data.minutes_played, None, server_time_offset, 1, 0, 211843)
|
||||
|
||||
spawn = random.choice(p.server.spawn_rooms)
|
||||
await spawn.add_penguin(p)
|
||||
|
||||
await p.data.load_inventories()
|
||||
p.joined_world = True
|
||||
|
||||
p.server.penguins_by_id[p.data.id] = p
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('j', 'jr'))
|
||||
@handlers.cooldown(1)
|
||||
|
@ -1,8 +1,27 @@
|
||||
from houdini import handlers
|
||||
from houdini.handlers import XTPacket
|
||||
|
||||
async def get_player_info_by_id(p, id):
|
||||
if id in p.server.penguins_by_id:
|
||||
player = p.server.penguins_by_id[id]
|
||||
player_tuple = (player.data.nickname, player.data.id, player.data.nickname)
|
||||
else:
|
||||
player_tuple = await p.data.select('nickname', 'id', 'nickname').where(p.data.id == id).gino.first()
|
||||
|
||||
if player_tuple is not None:
|
||||
player_data = [str(player_detail) for player_detail in player_tuple]
|
||||
return "|".join(player_data)
|
||||
|
||||
return str()
|
||||
|
||||
@handlers.handler(XTPacket('u', 'h'))
|
||||
@handlers.cooldown(59)
|
||||
async def handle_heartbeat(p):
|
||||
await p.send_xt('h')
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('u', 'pbi'))
|
||||
async def handle_get_player_info_by_id(p, penguin_id: int):
|
||||
await p.send_xt('pbi', await get_player_info_by_id(p, penguin_id))
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ class Penguin(Spheniscidae):
|
||||
|
||||
__slots__ = ['x', 'y', 'frame', 'room', 'waddle', 'table', 'data',
|
||||
'login_key', 'member', 'membership_days', 'avatar',
|
||||
'walking_puffle', 'permissions']
|
||||
'walking_puffle', 'permissions', 'age']
|
||||
|
||||
def __init__(self, *args):
|
||||
super().__init__(*args)
|
||||
@ -17,6 +17,7 @@ class Penguin(Spheniscidae):
|
||||
self.room = None
|
||||
self.waddle = None
|
||||
self.table = None
|
||||
self.age = 0
|
||||
|
||||
self.data = None
|
||||
self.login_key = None
|
||||
|
Loading…
Reference in New Issue
Block a user