Aevann 2024-01-12 10:12:35 +02:00
parent 289db918ed
commit 476d6994b4
10 changed files with 31 additions and 14 deletions

View File

@ -91,6 +91,7 @@ function vote(type, id, dir) {
}
let global_price;
let global_currency;
const note_section = document.getElementById('note_section')
const gif_button = note_section.querySelector('[title="Add GIF"]')
@ -153,13 +154,20 @@ function pick(kind, price, coins, marseybux) {
const ownednum = Number(document.getElementById(`${kind}-owned`).textContent);
if (kind == 'grass')
global_currency = 'coins'
else if (kind == 'benefactor')
global_currency = 'marseybux'
else
global_currency = 'coins/marseybux'
if (ownednum > 0) {
document.getElementById('award_price').textContent = `${ownednum} owned`;
giveaward_button.classList.remove('d-none');
document.getElementById('buyandgiveaward').classList.add('d-none');
}
else {
document.getElementById('award_price').textContent = `Price: ${price} coins/marseybux`;
document.getElementById('award_price').textContent = `Price: ${price} ${global_currency}`;
giveaward_button.classList.add('d-none');
document.getElementById('buyandgiveaward').classList.remove('d-none');
}
@ -188,7 +196,7 @@ function giveaward(t) {
}
else {
ownedblock.textContent = `Price: ${global_price}`
document.getElementById('award_price').textContent = `Price: ${global_price} coins/marseybux`;
document.getElementById('award_price').textContent = `Price: ${global_price} ${global_currency}`;
}
}
);

View File

@ -238,7 +238,7 @@ class User(Base):
if not should_check_balance or account_balance >= amount:
user_query.update({ User.marseybux: User.marseybux - amount })
succeeded = True
elif currency == 'combined':
elif currency == 'coins/marseybux':
if self.marseybux >= amount:
subtracted_mbux = amount
subtracted_coins = 0

View File

@ -180,7 +180,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr
if cost > v.coins + v.marseybux:
abort(403, f"You need {cost} currency to mention these ping groups!")
v.charge_account('combined', cost)
v.charge_account('coins/marseybux', cost)
if obj:
obj.ping_cost += cost
return 'everyone'
@ -223,7 +223,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr
coin_receivers.update(member_ids)
if cost:
v.charge_account('combined', cost)
v.charge_account('coins/marseybux', cost)
if obj:
obj.ping_cost += cost

View File

@ -62,11 +62,11 @@ def buy_award(v, kind, AWARDS):
elif kind == "benefactor":
currency = 'marseybux'
else:
currency = 'combined'
currency = 'coins/marseybux'
charged = v.charge_account(currency, price)
if not charged[0]:
abort(400, "Not enough coins/marseybux!")
abort(400, f"Not enough {currency}!")
v.coins_spent += charged[1]
if v.coins_spent >= 1000000:

View File

@ -35,7 +35,7 @@ def create_group(v):
if name in {'everyone', 'jannies', 'holejannies', 'followers', 'commenters'} or g.db.get(Group, name):
abort(400, "This group already exists!")
if not v.charge_account('combined', GROUP_COST)[0]:
if not v.charge_account('coins/marseybux', GROUP_COST)[0]:
abort(403, "You don't have enough coins or marseybux!")
g.db.add(v)

View File

@ -85,7 +85,7 @@ def buy_hat(v, hat_id):
if not hat.is_purchasable:
abort(403, "This hat is not for sale!")
charged = v.charge_account('combined', hat.price)
charged = v.charge_account('coins/marseybux', hat.price)
if not charged[0]:
abort(400, "Not enough coins/marseybux!")

View File

@ -372,7 +372,7 @@ def create_sub2(v):
if not hole_group_name_regex.fullmatch(name):
abort(400, "Name does not match the required format!")
if not v.charge_account('combined', HOLE_COST)[0]:
if not v.charge_account('coins/marseybux', HOLE_COST)[0]:
abort(400, "You don't have enough coins or marseybux!")
hole = get_hole(name, graceful=True)

View File

@ -26,7 +26,7 @@ def vote_option(option_id, v):
if option.exclusive == 2:
if option.parent.total_bet_voted(v):
abort(403, "You can't participate in a closed bet!")
if not v.charge_account('combined', POLL_BET_COINS)[0]:
if not v.charge_account('coins/marseybux', POLL_BET_COINS)[0]:
abort(400, f"You don't have {POLL_BET_COINS} coins or marseybux!")
g.db.add(v)
@ -79,7 +79,7 @@ def vote_option_comment(option_id, v):
if option.exclusive == 2:
if option.parent.total_bet_voted(v):
abort(403, "You can't participate in a closed bet!")
if not v.charge_account('combined', POLL_BET_COINS)[0]:
if not v.charge_account('coins/marseybux', POLL_BET_COINS)[0]:
abort(400, f"You don't have {POLL_BET_COINS} coins or marseybux!")
g.db.add(v)

View File

@ -365,7 +365,7 @@ def settings_personal_post(v):
else:
cost = HOUSE_JOIN_COST
success = v.charge_account('combined', cost)[0]
success = v.charge_account('coins/marseybux', cost)[0]
if not success: abort(403)
if house == "None": house = ''

View File

@ -22,7 +22,16 @@
{% macro iterate_awards(awards) %}
{% for award in awards %}
{% set price = (award.price*v.award_discount)|int %}
<div data-bs-toggle="tooltip" data-bs-placement="bottom" title="Price: <s>{{award.price}}</s> {{price}} coins/marseybux - {{award.description}}" id="{{award.kind}}" data-positive="{{award.positive}}" data-nonce="{{g.nonce}}" data-onclick="pick('{{award.kind}}', {{price}}, {{v.coins}}, {{v.marseybux}})" data-bs-html="true">
{% if award.kind == 'grass' %}
{% set currency = 'coins' %}
{% elif award.kind == 'benefactor' %}
{% set currency = 'marseybux' %}
{% else %}
{% set currency = 'coins/marseybux' %}
{% endif %}
<div data-bs-toggle="tooltip" data-bs-placement="bottom" title="Price: <s>{{award.price}}</s> {{price}} {{currency}} - {{award.description}}" id="{{award.kind}}" data-positive="{{award.positive}}" data-nonce="{{g.nonce}}" data-onclick="pick('{{award.kind}}', {{price}}, {{v.coins}}, {{v.marseybux}})" data-bs-html="true">
<i class="{{award.icon}} {{award.color}}"></i>
<div class="pt-1 award-name">{{award.title}}</div>
<span id="{{award.kind}}-owned" class="d-none">{{award.owned}}</span>