use charge_account everywhere

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-12 18:33:00 +02:00
parent d04c170466
commit cdff11424f
8 changed files with 11 additions and 12 deletions

View File

@ -103,7 +103,7 @@ def purchase_lottery_tickets(v, quantity=1):
if (most_recent_lottery is None):
return False, "There is no active lottery."
v.coins -= LOTTERY_TICKET_COST * quantity
v.charge_account('coins', LOTTERY_TICKET_COST * quantity)
v.currently_held_lottery_tickets += quantity
v.total_held_lottery_tickets += quantity
@ -125,4 +125,3 @@ def grant_lottery_tickets_to_user(v, quantity):
active_lottery.prize += prize_value
active_lottery.tickets_sold += quantity

View File

@ -216,7 +216,7 @@ def distribute(v, option_id):
if o.exclusive >= 2: pool += o.upvotes
pool *= POLL_BET_COINS
autojanny.coins -= pool
autojanny.charge_account('coins', pool)
if autojanny.coins < 0: autojanny.coins = 0
g.db.add(autojanny)
@ -1175,7 +1175,7 @@ def approve_post(post_id, v):
cache.delete_memoized(frontlist)
v.coins -= 1
v.charge_account('coins', 1)
g.db.add(v)
return {"message": "Post approved!"}

View File

@ -23,7 +23,7 @@ def vote_option(option_id, v):
if option.exclusive == 2:
if v.coins < POLL_BET_COINS: abort(400, f"You don't have {POLL_BET_COINS} coins!")
v.coins -= POLL_BET_COINS
v.charge_account('coins', POLL_BET_COINS)
g.db.add(v)
autojanny = get_account(AUTOJANNY_ID)
autojanny.coins += POLL_BET_COINS

View File

@ -879,7 +879,7 @@ def submit_post(v, sub=None):
is_bot = v.id != BBBB_ID and bool(request.headers.get("Authorization")) or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID)
if request.values.get("ghost") and v.coins >= 100:
v.coins -= 100
v.charge_account('coins', 100)
ghost = True
else: ghost = False

View File

@ -276,8 +276,8 @@ def settings_profile_post(v):
if v.house: cost = 2000
else: cost = 500
if v.coins >= cost: v.coins -= cost
elif v.procoins >= cost: v.procoins -= cost
if v.coins >= cost: v.charge_account('coins', cost)
elif v.procoins >= cost: v.charge_account('procoins', cost)
else: abort(403)
if house == "None": house = ''

View File

@ -332,7 +332,7 @@ def create_sub2(v):
if v.coins < HOLE_COST:
return render_template("sub/create_hole.html", v=v, cost=HOLE_COST, error="You don't have enough coins!"), 403
v.coins -= HOLE_COST
v.charge_account('coins', HOLE_COST)
g.db.add(v)
if v.shadowbanned: return {"error": "Internal Server Error"}, 500

View File

@ -271,7 +271,7 @@ def transfer_coins(v, username):
if not v.patron and not receiver.patron and not v.alts_patron and not receiver.alts_patron: tax = math.ceil(amount*0.03)
else: tax = 0
v.coins -= amount
v.charge_account('coins', amount)
if not v.shadowbanned:
receiver.coins += amount - tax
@ -310,7 +310,7 @@ def transfer_bux(v, username):
if v.procoins < amount: abort(400, "You don't have enough marseybux")
if amount < 100: abort(400, "You have to gift at least 100 marseybux.")
v.procoins -= amount
v.charge_account('procoins', amount)
if not v.shadowbanned:
receiver.procoins += amount

View File

@ -86,7 +86,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
existing.vote_type = new
g.db.add(existing)
elif existing.vote_type != 0 and new == 0:
target.author.coins -= coin_delta * coin_mult
target.author.charge_account('coins', coin_delta * coin_mult)
target.author.truecoins -= coin_delta
g.db.add(target.author)
g.db.delete(existing)