From 4027a7af086d1732e1b1f6fcf6fa709829a9336d Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 14 Feb 2020 21:58:44 +0000 Subject: [PATCH] `waddle_handler` decorator --- houdini/handlers/games/waddle.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/houdini/handlers/games/waddle.py b/houdini/handlers/games/waddle.py index fd5a348..2babb97 100644 --- a/houdini/handlers/games/waddle.py +++ b/houdini/handlers/games/waddle.py @@ -1,10 +1,19 @@ from houdini import handlers -from houdini.handlers import XTPacket +from houdini.handlers import XTPacket, check +from houdini.handlers.play.navigation import handle_join_room, handle_join_player_room + + +def waddle_handler(waddle): + def check_waddle_game(_, p): + if p.waddle is not None and type(p.waddle) == waddle: + return True + return False + return check(check_waddle_game) @handlers.handler(XTPacket('gw', ext='z')) async def handle_get_waddle_population(p): - await p.send_xt('gw', '%'.join(f'{waddle.id}|{",".join(penguin.safe_name for penguin in waddle.penguins)}' + await p.send_xt('gw', '%'.join(f'{waddle.id}|{",".join(penguin.safe_name if penguin else str() for penguin in waddle.penguins)}' for waddle in p.room.waddles.values()))