From 69b83cbbdb1a30ac81878eb5769abbc327e78dda Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 2 Dec 2019 23:38:02 +0000 Subject: [PATCH] Table handlers --- houdini/handlers/games/table.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 houdini/handlers/games/table.py diff --git a/houdini/handlers/games/table.py b/houdini/handlers/games/table.py new file mode 100644 index 0000000..5e486f9 --- /dev/null +++ b/houdini/handlers/games/table.py @@ -0,0 +1,22 @@ +from houdini import handlers +from houdini.handlers import XTPacket, check + + +def table_handler(logic): + def check_table_game(_, p): + if p.table is not None and type(p.table.logic) == logic: + return True + return False + return check(check_table_game) + + +@handlers.handler(XTPacket('a', 'gt')) +async def handle_get_waddle_population(p): + await p.send_xt('gt', '%'.join(f'{table.id}|{",".join(penguin.safe_name for penguin in table.penguins)}' + for table in p.room.tables.values())) + + +@handlers.handler(XTPacket('a', 'jt')) +async def handle_join_table(p, table_id: int): + table = p.room.tables[table_id] + await table.add(p)