forked from MarseyWorld/MarseyWorld
Apply double-spend fix to hats.
parent
54cae4b570
commit
f1153031cc
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue