From f3059cb1d1571079ae278de574d85759369e7898 Mon Sep 17 00:00:00 2001 From: Ben <32749673+ketnipz@users.noreply.github.com> Date: Mon, 10 Aug 2020 22:48:30 +0100 Subject: [PATCH] Set cost to 0 for redeemable that normally cost coins Fixes bug where players would be charged for redeeming items that normally cost coins. This could cause coins to go into negative. --- houdini/handlers/redemption/code.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/houdini/handlers/redemption/code.py b/houdini/handlers/redemption/code.py index 64323f8..9f1d66c 100644 --- a/houdini/handlers/redemption/code.py +++ b/houdini/handlers/redemption/code.py @@ -133,13 +133,13 @@ async def handle_code_vanilla(p, redemption_code: str): for item in choices: if type(item) is Item: awards.append(str(item.id)) - await p.add_inventory(item, notify=False) + await p.add_inventory(item, notify=False, cost=0) elif type(item) is Igloo: awards.append(f'g{item.id}') - await p.add_igloo(item, notify=False) + await p.add_igloo(item, notify=False, cost=0) elif type(item) is Furniture: awards.append(f'f{item.id}') - await p.add_furniture(item, notify=False) + await p.add_furniture(item, notify=False, cost=0) await PenguinRedemptionCode.create(penguin_id=p.id, code_id=code[0].id) @@ -155,30 +155,30 @@ async def handle_code_vanilla(p, redemption_code: str): if code.items: for award in code.items: awards.append(str(award.item_id)) - await p.add_inventory(p.server.items[award.item_id], notify=False) + await p.add_inventory(p.server.items[award.item_id], notify=False, cost=0) if code.furniture: for award in code.furniture: awards.append(f'f{award.furniture_id}') - await p.add_furniture(p.server.furniture[award.furniture_id], notify=False) + await p.add_furniture(p.server.furniture[award.furniture_id], notify=False, cost=0) if code.igloos: for award in code.igloos: awards.append(f'g{award.igloo_id}') - await p.add_igloo(p.server.igloos[award.igloo_id], notify=False) + await p.add_igloo(p.server.igloos[award.igloo_id], notify=False, cost=0) if code.locations: for award in code.locations: awards.append(f'loc{award.location_id}') - await p.add_location(p.server.locations[award.location_id], notify=False) + await p.add_location(p.server.locations[award.location_id], notify=False, cost=0) if code.flooring: for award in code.flooring: awards.append(f'flr{award.flooring_id}') - await p.add_flooring(p.server.flooring[award.flooring_id], notify=False) + await p.add_flooring(p.server.flooring[award.flooring_id], notify=False, cost=0) if code.puffles: for award in code.puffles: awards.append(f'p{award.puffle_id}') if code.puffle_items: for award in code.puffle_items: awards.append(f'pi{award.puffle_item_id}') - await p.add_puffle_item(p.server.puffle_items[award.puffle_item_id], notify=False) + await p.add_puffle_item(p.server.puffle_items[award.puffle_item_id], notify=False, cost=0) await PenguinRedemptionCode.create(penguin_id=p.id, code_id=code.id) await p.update(coins=p.coins + code.coins).apply() @@ -242,7 +242,7 @@ async def handle_send_cart(p, redemption_code: str, choice: str): awards.append(choice) elif choice.isdigit(): awards.append(choice) - await p.add_inventory(p.server.items[int(choice)], notify=False) + await p.add_inventory(p.server.items[int(choice)], notify=False, cost=0) if code.uses is not None: await PenguinRedemptionCode.create(penguin_id=p.id, code_id=code.id)