diff --git a/files/routes/awards.py b/files/routes/awards.py index 657410e49d..d5048a8c61 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -65,19 +65,23 @@ def buy(v, award): price = int(og_price * v.discount) if request.values.get("mb"): - if v.procoins < price: return {"error": "Not enough marseybux."}, 400 - if award == "grass": return {"error": "You can't buy the grass award with marseybux."}, 403 - v.charge_account('procoins', price) + if award == "grass": + return {"error": "You can't buy the grass award with marseybux."}, 403 + + charged = v.charge_account('procoins', price) + if not charged: + return {"error": "Not enough marseybux."}, 400 else: - if v.coins < price: return {"error": "Not enough coins."}, 400 - v.charge_account('coins', price) + charged = v.charge_account('coins', price) + if not charged: + return {"error": "Not enough coins."}, 400 + v.coins_spent += price if v.coins_spent >= 1000000: badge_grant(badge_id=73, user=v) elif v.coins_spent >= 500000: badge_grant(badge_id=72, user=v) elif v.coins_spent >= 250000: - badge_grant(badge_id=71, user=v) elif v.coins_spent >= 100000: badge_grant(badge_id=70, user=v) diff --git a/files/routes/hats.py b/files/routes/hats.py index 823005d823..e5105723b5 100644 --- a/files/routes/hats.py +++ b/files/routes/hats.py @@ -47,13 +47,17 @@ def buy_hat(v, hat_id): if existing: return {"error": "You already own this hat!"}, 400 if request.values.get("mb"): - if v.procoins < hat.price: return {"error": "Not enough marseybux."}, 400 - v.procoins -= hat.price + charged = v.charge_account('procoins', hat.price) + if not charged: + return {"error": "Not enough marseybux."}, 400 + hat.author.procoins += hat.price * 0.1 currency = "marseybux" else: - if v.coins < hat.price: return {"error": "Not enough coins."}, 400 - v.coins -= hat.price + charged = v.charge_account('coins', price) + if not charged: + return {"error": "Not enough coins."}, 400 + v.coins_spent_on_hats += hat.price hat.author.coins += hat.price * 0.1 currency = "coins"