forked from rDrama/rDrama
Apply double-spend fix to hats.
parent
54cae4b570
commit
f1153031cc
|
@ -65,19 +65,23 @@ def buy(v, award):
|
||||||
price = int(og_price * v.discount)
|
price = int(og_price * v.discount)
|
||||||
|
|
||||||
if request.values.get("mb"):
|
if request.values.get("mb"):
|
||||||
if v.procoins < price: return {"error": "Not enough marseybux."}, 400
|
if award == "grass":
|
||||||
if award == "grass": return {"error": "You can't buy the grass award with marseybux."}, 403
|
return {"error": "You can't buy the grass award with marseybux."}, 403
|
||||||
v.charge_account('procoins', price)
|
|
||||||
|
charged = v.charge_account('procoins', price)
|
||||||
|
if not charged:
|
||||||
|
return {"error": "Not enough marseybux."}, 400
|
||||||
else:
|
else:
|
||||||
if v.coins < price: return {"error": "Not enough coins."}, 400
|
charged = v.charge_account('coins', price)
|
||||||
v.charge_account('coins', price)
|
if not charged:
|
||||||
|
return {"error": "Not enough coins."}, 400
|
||||||
|
|
||||||
v.coins_spent += price
|
v.coins_spent += price
|
||||||
if v.coins_spent >= 1000000:
|
if v.coins_spent >= 1000000:
|
||||||
badge_grant(badge_id=73, user=v)
|
badge_grant(badge_id=73, user=v)
|
||||||
elif v.coins_spent >= 500000:
|
elif v.coins_spent >= 500000:
|
||||||
badge_grant(badge_id=72, user=v)
|
badge_grant(badge_id=72, user=v)
|
||||||
elif v.coins_spent >= 250000:
|
elif v.coins_spent >= 250000:
|
||||||
|
|
||||||
badge_grant(badge_id=71, user=v)
|
badge_grant(badge_id=71, user=v)
|
||||||
elif v.coins_spent >= 100000:
|
elif v.coins_spent >= 100000:
|
||||||
badge_grant(badge_id=70, user=v)
|
badge_grant(badge_id=70, user=v)
|
||||||
|
|
|
@ -47,13 +47,17 @@ def buy_hat(v, hat_id):
|
||||||
if existing: return {"error": "You already own this hat!"}, 400
|
if existing: return {"error": "You already own this hat!"}, 400
|
||||||
|
|
||||||
if request.values.get("mb"):
|
if request.values.get("mb"):
|
||||||
if v.procoins < hat.price: return {"error": "Not enough marseybux."}, 400
|
charged = v.charge_account('procoins', hat.price)
|
||||||
v.procoins -= hat.price
|
if not charged:
|
||||||
|
return {"error": "Not enough marseybux."}, 400
|
||||||
|
|
||||||
hat.author.procoins += hat.price * 0.1
|
hat.author.procoins += hat.price * 0.1
|
||||||
currency = "marseybux"
|
currency = "marseybux"
|
||||||
else:
|
else:
|
||||||
if v.coins < hat.price: return {"error": "Not enough coins."}, 400
|
charged = v.charge_account('coins', price)
|
||||||
v.coins -= hat.price
|
if not charged:
|
||||||
|
return {"error": "Not enough coins."}, 400
|
||||||
|
|
||||||
v.coins_spent_on_hats += hat.price
|
v.coins_spent_on_hats += hat.price
|
||||||
hat.author.coins += hat.price * 0.1
|
hat.author.coins += hat.price * 0.1
|
||||||
currency = "coins"
|
currency = "coins"
|
||||||
|
|
Loading…
Reference in New Issue