diff --git a/files/assets/js/casino/blackjack_screen.js b/files/assets/js/casino/blackjack_screen.js index 58130777f..f12f0f3b8 100644 --- a/files/assets/js/casino/blackjack_screen.js +++ b/files/assets/js/casino/blackjack_screen.js @@ -119,28 +119,28 @@ function updateBlackjackTable(state) { if (gameCompleted) { switch (state.status) { case 'BLACKJACK': - updateResult(`Blackjack: Received ${state.payout} ${currency}`, "warning"); + updateResult(`Blackjack: Received ${commas(state.payout)} ${currency}`, "warning"); break; case 'WON': if (state.status_split === 'LOST') { updateResult(`Won and Lost: Received 0 ${currency}`, "success"); } else if (state.status_split === 'PUSHED') { - updateResult(`Won and PUSHED: Received ${state.payout} ${currency}`, "success"); + updateResult(`Won and PUSHED: Received ${commas(state.payout)} ${currency}`, "success"); } else { - updateResult(`Won: Received ${state.payout} ${currency}`, "success"); + updateResult(`Won: Received ${commas(state.payout)} ${currency}`, "success"); } break; case 'PUSHED': if (state.status_split === 'WON') { - updateResult(`Won and PUSHED: Received ${state.payout} ${currency}`, "success"); + updateResult(`Won and PUSHED: Received ${commas(state.payout)} ${currency}`, "success"); } else if (state.status_split === 'LOST') { - updateResult(`Lost and Pushed: Lost ${state.wager.amount} ${currency}`, "danger"); + updateResult(`Lost and Pushed: Lost ${commas(state.wager.amount)} ${currency}`, "danger"); } else { - updateResult(`Pushed: Received ${state.wager.amount} ${currency}`, "success"); + updateResult(`Pushed: Received ${commas(state.wager.amount)} ${currency}`, "success"); } break; @@ -149,14 +149,14 @@ function updateBlackjackTable(state) { updateResult(`Won and Lost: Received 0 ${currency}`, "success"); } else if (state.status_split === 'PUSHED') { - updateResult(`Lost and Pushed: Lost ${state.wager.amount} ${currency}`, "danger"); + updateResult(`Lost and Pushed: Lost ${commas(state.wager.amount)} ${currency}`, "danger"); } else { let lost = state.wager.amount; if (state.player_doubled_down || state.has_player_split) { lost *= 2; } - updateResult(`Lost ${lost} ${currency}`, "danger"); + updateResult(`Lost ${commas(lost)} ${currency}`, "danger"); } break; @@ -172,7 +172,7 @@ function updateBlackjackTable(state) { if (state.status === 'PLAYING' || (state.has_player_split && state.status_split === 'PLAYING')) { - updateResult(`${state.has_player_split ? state.wager.amount * 2 : state.wager.amount} ${currency} are at stake`, "success"); + updateResult(`${commas(state.has_player_split ? state.wager.amount * 2 : state.wager.amount)} ${currency} are at stake`, "success"); } else { enableWager(); } diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 94cb3094b..7bbf78eb1 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -798,7 +798,6 @@ function toggleElement(id, id2) { } const formatter = new Intl.NumberFormat('en-US'); -function change_currency(id, amount) { - const el = document.getElementById(id) - el.textContent = formatter.format(parseInt(el.textContent.replaceAll(',', '')) + amount); +function commas(number) { + return formatter.format(number) } diff --git a/files/assets/js/userpage_v.js b/files/assets/js/userpage_v.js index 749ffedbe..c16e46e05 100644 --- a/files/assets/js/userpage_v.js +++ b/files/assets/js/userpage_v.js @@ -12,6 +12,11 @@ function updateBux(mobile=false) { if (amount > 0) document.getElementById("bux-transfer-taxed" + suf).textContent = amount; } +function change_currency(id, amount) { + const el = document.getElementById(id) + el.textContent = commas(parseInt(el.textContent.replaceAll(',', '')) + amount); +} + function transferCoins(t, mobile=false) { close_inline_emoji_modal(); diff --git a/files/classes/comment.py b/files/classes/comment.py index ff8e60b9d..932d966af 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -511,15 +511,15 @@ class Comment(Base): body = f"{player_hand} vs. {dealer_hand}" if blackjack_status == 'push': - body += f"Pushed. Refunded {wager} {currency_kind}." + body += f"Pushed. Refunded {commas(wager)} {currency_kind}." elif blackjack_status == 'bust': - body += f"Bust. Lost {wager} {currency_kind}." + body += f"Bust. Lost {commas(wager)} {currency_kind}." elif blackjack_status == 'lost': - body += f"Lost {wager} {currency_kind}." + body += f"Lost {commas(wager)} {currency_kind}." elif blackjack_status == 'won': - body += f"Won {wager} {currency_kind}." + body += f"Won {commas(wager)} {currency_kind}." elif blackjack_status == 'blackjack': - body += f"Blackjack! Won {floor(wager * 3/2)} {currency_kind}." + body += f"Blackjack! Won {commas(floor(wager * 3/2))} {currency_kind}." if is_insured == "1": body += " Insured." diff --git a/files/classes/user.py b/files/classes/user.py index a0f574662..93a8ce4cf 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1067,8 +1067,8 @@ class User(Base): 'hat': self.hat_active(v)[0], 'bannerurl': self.banner_url, 'bio_html': self.bio_html_eager, - 'coins': self.coins, - 'marseybux': self.marseybux, + 'coins': commas(self.coins), + 'marseybux': commas(self.marseybux), 'post_count': self.real_post_count(v), 'comment_count': self.real_comment_count(v), 'badges': [[x.path, x.text, x.until] for x in self.ordered_badges(v)], diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index b2d2f6ea6..59fe8347a 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -1153,3 +1153,6 @@ if not IS_LOCALHOST: with open("includes/content-security-policy", "w") as f: f.write(f'add_header Content-Security-Policy "{csp}";') + +def commas(number): + return "{:,}".format(number) diff --git a/files/helpers/slots.py b/files/helpers/slots.py index e57c47c1a..e3c7fc603 100644 --- a/files/helpers/slots.py +++ b/files/helpers/slots.py @@ -103,13 +103,13 @@ def build_symbols(for_payout): def build_text(wager_value, result, currency): if result == 0: - return f'Lost {wager_value} {currency}' + return f'Lost {commas(wager_value)} {currency}' elif result == 1: return 'Broke Even' elif result == 12: - return f'Jackpot! Won {wager_value * (result-1)} {currency}' + return f'Jackpot! Won {commas(wager_value * (result-1))} {currency}' else: - return f'Won {wager_value * (result-1)} {currency}' + return f'Won {commas(wager_value * (result-1))} {currency}' def determine_payout(): diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index bb9cdca60..af9df8be4 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -103,8 +103,8 @@ def expand_art(url): return f"{SITE_FULL_IMAGES}/asset_submissions/art/original/{id}.webp" @app.template_filter("commas") -def commas(number): - return "{:,}".format(number) +def commas_filter(number): + return commas(number) def current_registered_users(): return "{:,}".format(g.db.query(User).count()) diff --git a/files/templates/bank_statement.html b/files/templates/bank_statement.html index 25c49e0f4..5cd0d2a11 100644 --- a/files/templates/bank_statement.html +++ b/files/templates/bank_statement.html @@ -27,7 +27,7 @@ {{log.currency}} - {% if log.amount > 0 %}+{% endif %}{{log.amount}} + {% if log.amount > 0 %}+{% endif %}{{log.amount | commas}}
{{log.age_string}} @@ -35,7 +35,7 @@
{{log.reason | safe}} - {{log.balance}} + {{log.balance | commas}} {% endfor %}