Leave table handlers

This commit is contained in:
Ben 2019-12-04 01:32:06 +00:00
parent 27cdb1e569
commit 269702343f

View File

@ -1,5 +1,6 @@
from houdini import handlers from houdini import handlers
from houdini.handlers import XTPacket, check from houdini.handlers import XTPacket, check
from houdini.handlers.play.navigation import handle_join_room, handle_join_player_room
def table_handler(logic): def table_handler(logic):
@ -20,3 +21,27 @@ async def handle_get_waddle_population(p):
async def handle_join_table(p, table_id: int): async def handle_join_table(p, table_id: int):
table = p.room.tables[table_id] table = p.room.tables[table_id]
await table.add(p) await table.add(p)
@handlers.handler(XTPacket('a', 'lt'))
async def handle_leave_table(p):
if p.table is not None:
await p.table.remove(p)
@handlers.handler(XTPacket('j', 'jr'), after=handle_join_room)
async def handle_join_room_table(p):
if p.table is not None:
await p.table.remove(p)
@handlers.handler(XTPacket('j', 'jp'), after=handle_join_player_room)
async def handle_join_player_room_table(p):
if p.table is not None:
await p.table.remove(p)
@handlers.disconnected
async def handle_disconnect_table(p):
if p.table is not None:
await p.table.remove(p)