AS3 player data lookup handlers

This commit is contained in:
Ben 2019-08-19 02:24:47 +01:00
parent d79efd6680
commit 2e414e0f5a

View File

@ -1,4 +1,4 @@
from houdini import handlers
from houdini import handlers, ClientType
from houdini.handlers import XTPacket
from houdini.data.penguin import Penguin
@ -49,6 +49,55 @@ async def handle_get_player(p, penguin_id: int):
@handlers.cooldown(1)
async def handle_get_mascot(p, mascot_id: int):
await p.send_xt('gmo', await get_mascot_string(p, mascot_id))
@handlers.handler(XTPacket('u', 'pbi'), client=ClientType.Vanilla)
@handlers.cooldown(1)
async def handle_get_player_by_id(p, penguin_id: int):
await p.send_xt('pbi', penguin_id)
@handlers.handler(XTPacket('u', 'pbs'), client=ClientType.Vanilla)
@handlers.cooldown(1)
async def handle_get_player_by_swid(p, penguin_id: int):
if penguin_id in p.server.penguins_by_id:
nickname = p.server.penguins_by_id[penguin_id].data.nickname
else:
nickname = await Penguin.select('nickname').where(Penguin.id == penguin_id).gino.scalar()
await p.send_xt('pbs', penguin_id, penguin_id, nickname)
@handlers.handler(XTPacket('u', 'pbn'), client=ClientType.Vanilla)
@handlers.cooldown(1)
async def handle_get_player_by_name(p, player_name: str):
player_name = player_name.lower()
if player_name in p.server.penguins_by_username:
player = p.server.penguins_by_username[player_name]
await p.send_xt('pbn', player.data.id, player.data.id, player.data.nickname)
else:
player_id, nickname = await Penguin.select('id', 'nickname').where(
Penguin.username == player_name).gino.first()
if player_id is not None:
await p.send_xt('pbn', player_id, player_id, nickname)
else:
await p.send_xt('pbn')
@handlers.handler(XTPacket('u', 'pbsms'), client=ClientType.Vanilla)
async def handle_pbsm_start(p):
await p.send_xt('pbsms')
@handlers.handler(XTPacket('u', 'pbsm'), client=ClientType.Vanilla)
async def handle_get_player_ids(p, ids: str):
await p.send_xt('pbsm', ids)
@handlers.handler(XTPacket('u', 'pbsmf'), client=ClientType.Vanilla)
async def handle_pbsm_finish(p):
await p.send_xt('pbsmf')
@handlers.handler(XTPacket('u', 'sp'))
async def handle_set_player_position(p, x: int, y: int):
p.x, p.y = x, y