From 0021ad1ad1ed601bb66078f80ddb459831c30fcf Mon Sep 17 00:00:00 2001 From: rsakeys Date: Tue, 3 Mar 2020 22:42:24 +0000 Subject: [PATCH] Add support for CARD type redemption codes. --- houdini/handlers/redemption/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/houdini/handlers/redemption/__init__.py b/houdini/handlers/redemption/__init__.py index e79010e..793fb6e 100644 --- a/houdini/handlers/redemption/__init__.py +++ b/houdini/handlers/redemption/__init__.py @@ -42,6 +42,7 @@ async def handle_code(p, redemption_code: str): puffle_items=RedemptionAwardPuffleItem)\ .query.where(RedemptionCode.code == redemption_code) code = await query.gino.first() + items = [] if code is None: return await p.send_error(720) @@ -106,10 +107,17 @@ async def handle_code(p, redemption_code: str): if code.uses != -1: await PenguinRedemptionCode.create(penguin_id=p.id, code_id=code.id) - await p.send_xt('rsc', 'INNOCENT', ','.join(map(str, awards)), redeemed, len(innocent_items)) + return await p.send_xt('rsc', 'INNOCENT', ','.join(map(str, awards)), redeemed, len(innocent_items)) if code.type == 'GOLDEN': - await p.send_xt('rsc', 'GOLDEN', p.ninja_rank, p.fire_ninja_rank, p.water_ninja_rank, 0, + return await p.send_xt('rsc', 'GOLDEN', p.ninja_rank, p.fire_ninja_rank, p.water_ninja_rank, 0, int(p.fire_ninja_rank > 0), int(p.water_ninja_rank > 0), 0) + if code.type == 'GOLDEN': + return await p.send_xt('rsc', 'GOLDEN', p.ninja_rank, p.fire_ninja_rank, p.water_ninja_rank, 0, + int(p.fire_ninja_rank > 0), int(p.water_ninja_rank > 0), 0) + if code.type == 'CARD': + for award in code.cards: + items.append(str(award.card_id)) + await p.add_card(p.server.cards[award.card_id])