From 10d8bf4d5d8bc85e2f64968aef1fbec17d91a565 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 26 Jun 2020 03:26:06 +0100 Subject: [PATCH] Allow `handle_get_ninja_ranks` to query other players rankings Fixes the incorrect amulet showing for fellow players --- houdini/handlers/play/ninja.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/houdini/handlers/play/ninja.py b/houdini/handlers/play/ninja.py index 7e5578e..2fddc71 100644 --- a/houdini/handlers/play/ninja.py +++ b/houdini/handlers/play/ninja.py @@ -1,10 +1,19 @@ from houdini import handlers from houdini.handlers import XTPacket +from houdini.data.penguin import Penguin @handlers.handler(XTPacket('ni', 'gnr')) -async def handle_get_ninja_ranks(p): - await p.send_xt('gnr', p.id, p.ninja_rank, p.fire_ninja_rank, p.water_ninja_rank, 0) +async def handle_get_ninja_ranks(p, penguin_id: int): + if penguin_id in p.server.penguins_by_id: + penguin = p.server.penguins_by_id[penguin_id] + ninja_rank, fire_ninja_rank, water_ninja_rank = \ + penguin.ninja_rank, penguin.fire_ninja_rank, penguin.water_ninja_rank + else: + ninja_rank, fire_ninja_rank, water_ninja_rank = await Penguin.select( + 'ninja_rank', 'fire_ninja_rank', 'water_ninja_rank' + ).where(Penguin.id == penguin_id).gino.first() + await p.send_xt('gnr', p.id, ninja_rank, fire_ninja_rank, water_ninja_rank, 0) @handlers.handler(XTPacket('ni', 'gnl'))