From e48d1339778c617ea2c852eff12ad080d93b582b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 14 Dec 2022 21:30:05 +0200 Subject: [PATCH] rename Casino_Game to CasinoGame for consistency --- files/classes/casino_game.py | 2 +- files/classes/comment.py | 2 +- files/classes/user.py | 4 ++-- files/helpers/casino.py | 32 ++++++++++++++++---------------- files/helpers/roulette.py | 10 +++++----- files/helpers/slots.py | 4 ++-- files/helpers/twentyone.py | 12 ++++++------ 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/files/classes/casino_game.py b/files/classes/casino_game.py index d8b5a3567..0c6c6626f 100644 --- a/files/classes/casino_game.py +++ b/files/classes/casino_game.py @@ -9,7 +9,7 @@ from files.helpers.lazy import lazy CASINO_GAME_KINDS = ['blackjack', 'slots', 'roulette'] -class Casino_Game(Base): +class CasinoGame(Base): __tablename__ = "casino_games" id = Column(Integer, primary_key=True) diff --git a/files/classes/comment.py b/files/classes/comment.py index 7b82037fe..d6048630c 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -74,7 +74,7 @@ class Comment(Base): awards = relationship("AwardRelationship", order_by="AwardRelationship.awarded_utc.desc()", back_populates="comment") flags = relationship("CommentFlag", order_by="CommentFlag.created_utc") options = relationship("CommentOption", order_by="CommentOption.id") - casino_game = relationship("Casino_Game") + casino_game = relationship("CasinoGame") wall_user = relationship("User", primaryjoin="User.id==Comment.wall_user_id") def __init__(self, *args, **kwargs): diff --git a/files/classes/user.py b/files/classes/user.py index 29cda7874..a2fb6254b 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -10,7 +10,7 @@ from sqlalchemy.sql.expression import not_, and_, or_ from sqlalchemy.sql.sqltypes import * from files.classes import Base -from files.classes.casino_game import Casino_Game +from files.classes.casino_game import CasinoGame from files.classes.sub import Sub from files.helpers.config.const import * from files.helpers.config.awards import AWARDS_ENABLED, HOUSE_AWARDS @@ -1047,7 +1047,7 @@ class User(Base): @property @lazy def winnings(self): - from_casino = g.db.query(func.sum(Casino_Game.winnings)).filter(Casino_Game.user_id == self.id).one()[0] + from_casino = g.db.query(func.sum(CasinoGame.winnings)).filter(CasinoGame.user_id == self.id).one()[0] from_casino_value = from_casino or 0 return from_casino_value + self.total_lottery_winnings diff --git a/files/helpers/casino.py b/files/helpers/casino.py index 041f4509c..3e343de36 100644 --- a/files/helpers/casino.py +++ b/files/helpers/casino.py @@ -1,13 +1,13 @@ import time -from files.classes.casino_game import Casino_Game +from files.classes.casino_game import CasinoGame from files.helpers.alerts import * from files.helpers.config.const import * from files.helpers.useractions import badge_grant def get_game_feed(game, db): - games = db.query(Casino_Game) \ - .filter(Casino_Game.active == False, Casino_Game.kind == game) \ - .order_by(Casino_Game.created_utc.desc()).limit(30).all() + games = db.query(CasinoGame) \ + .filter(CasinoGame.active == False, CasinoGame.kind == game) \ + .order_by(CasinoGame.created_utc.desc()).limit(30).all() def format_game(game): user = db.query(User).filter(User.id == game.user_id).one() @@ -24,27 +24,27 @@ def get_game_feed(game, db): return list(map(format_game, games)) def get_user_stats(u:User, game:str, db:scoped_session, include_ties=False): - games = db.query(Casino_Game.user_id, Casino_Game.winnings).filter(Casino_Game.kind == game, Casino_Game.user_id == u.id) - wins = games.filter(Casino_Game.winnings > 0).count() - ties = games.filter(Casino_Game.winnings == 0).count() if include_ties else 0 - losses = games.filter(Casino_Game.winnings < 0).count() + games = db.query(CasinoGame.user_id, CasinoGame.winnings).filter(CasinoGame.kind == game, CasinoGame.user_id == u.id) + wins = games.filter(CasinoGame.winnings > 0).count() + ties = games.filter(CasinoGame.winnings == 0).count() if include_ties else 0 + losses = games.filter(CasinoGame.winnings < 0).count() return (wins, ties, losses) def get_game_leaderboard(game, db:scoped_session): timestamp_24h_ago = time.time() - 86400 timestamp_all_time = CASINO_RELEASE_DAY # "All Time" starts on release day - biggest_win_all_time = db.query(Casino_Game.user_id, User.username, Casino_Game.currency, Casino_Game.winnings).select_from( - Casino_Game).join(User).order_by(Casino_Game.winnings.desc()).filter(Casino_Game.kind == game, Casino_Game.created_utc > timestamp_all_time).limit(1).one_or_none() + biggest_win_all_time = db.query(CasinoGame.user_id, User.username, CasinoGame.currency, CasinoGame.winnings).select_from( + CasinoGame).join(User).order_by(CasinoGame.winnings.desc()).filter(CasinoGame.kind == game, CasinoGame.created_utc > timestamp_all_time).limit(1).one_or_none() - biggest_win_last_24h = db.query(Casino_Game.user_id, User.username, Casino_Game.currency, Casino_Game.winnings).select_from( - Casino_Game).join(User).order_by(Casino_Game.winnings.desc()).filter(Casino_Game.kind == game, Casino_Game.created_utc > timestamp_24h_ago).limit(1).one_or_none() + biggest_win_last_24h = db.query(CasinoGame.user_id, User.username, CasinoGame.currency, CasinoGame.winnings).select_from( + CasinoGame).join(User).order_by(CasinoGame.winnings.desc()).filter(CasinoGame.kind == game, CasinoGame.created_utc > timestamp_24h_ago).limit(1).one_or_none() - biggest_loss_all_time = db.query(Casino_Game.user_id, User.username, Casino_Game.currency, Casino_Game.winnings).select_from( - Casino_Game).join(User).order_by(Casino_Game.winnings.asc()).filter(Casino_Game.kind == game, Casino_Game.created_utc > timestamp_all_time).limit(1).one_or_none() + biggest_loss_all_time = db.query(CasinoGame.user_id, User.username, CasinoGame.currency, CasinoGame.winnings).select_from( + CasinoGame).join(User).order_by(CasinoGame.winnings.asc()).filter(CasinoGame.kind == game, CasinoGame.created_utc > timestamp_all_time).limit(1).one_or_none() - biggest_loss_last_24h = db.query(Casino_Game.user_id, User.username, Casino_Game.currency, Casino_Game.winnings).select_from( - Casino_Game).join(User).order_by(Casino_Game.winnings.asc()).filter(Casino_Game.kind == game, Casino_Game.created_utc > timestamp_24h_ago).limit(1).one_or_none() + biggest_loss_last_24h = db.query(CasinoGame.user_id, User.username, CasinoGame.currency, CasinoGame.winnings).select_from( + CasinoGame).join(User).order_by(CasinoGame.winnings.asc()).filter(CasinoGame.kind == game, CasinoGame.created_utc > timestamp_24h_ago).limit(1).one_or_none() if not biggest_win_all_time: biggest_win_all_time = [None, None, None, 0] diff --git a/files/helpers/roulette.py b/files/helpers/roulette.py index 735c89eb4..c07e0eaa6 100644 --- a/files/helpers/roulette.py +++ b/files/helpers/roulette.py @@ -5,7 +5,7 @@ import time from flask import g -from files.classes.casino_game import Casino_Game +from files.classes.casino_game import CasinoGame from files.helpers.alerts import * from files.helpers.get import get_account @@ -77,9 +77,9 @@ PAYOUT_MULITPLIERS = { def get_active_roulette_games(): - return g.db.query(Casino_Game).filter( - Casino_Game.active == True, - Casino_Game.kind == 'roulette' + return g.db.query(CasinoGame).filter( + CasinoGame.active == True, + CasinoGame.kind == 'roulette' ).all() @@ -112,7 +112,7 @@ def gambler_placed_roulette_bet(gambler, bet, which, amount, currency): charge_gambler(gambler, amount, currency) - game = Casino_Game() + game = CasinoGame() game.user_id = gambler.id game.currency = currency game.wager = amount diff --git a/files/helpers/slots.py b/files/helpers/slots.py index a2d768f9c..4f5606852 100644 --- a/files/helpers/slots.py +++ b/files/helpers/slots.py @@ -4,7 +4,7 @@ from json.encoder import INFINITY from flask import abort, g -from files.classes.casino_game import Casino_Game +from files.classes.casino_game import CasinoGame from files.classes.comment import Comment from files.classes.user import User from files.helpers.casino import distribute_wager_badges @@ -41,7 +41,7 @@ def casino_slot_pull(gambler, wager_value, currency): "symbols": symbols, "text": text } - casino_game = Casino_Game() + casino_game = CasinoGame() casino_game.active = False casino_game.user_id = gambler.id casino_game.currency = currency diff --git a/files/helpers/twentyone.py b/files/helpers/twentyone.py index 980b82bda..916d3f507 100644 --- a/files/helpers/twentyone.py +++ b/files/helpers/twentyone.py @@ -5,7 +5,7 @@ from math import floor from flask import g -from files.classes.casino_game import Casino_Game +from files.classes.casino_game import CasinoGame from files.helpers.casino import distribute_wager_badges class BlackjackStatus(str, Enum): @@ -55,7 +55,7 @@ def build_casino_game(gambler, wager, currency): initial_state['wager']['amount'] = wager initial_state['wager']['currency'] = currency - casino_game = Casino_Game() + casino_game = CasinoGame() casino_game.user_id = gambler.id casino_game.currency = currency casino_game.wager = wager @@ -69,10 +69,10 @@ def build_casino_game(gambler, wager, currency): def get_active_twentyone_game(gambler): - return g.db.query(Casino_Game).filter( - Casino_Game.active == True, - Casino_Game.kind == 'blackjack', - Casino_Game.user_id == gambler.id).first() + return g.db.query(CasinoGame).filter( + CasinoGame.active == True, + CasinoGame.kind == 'blackjack', + CasinoGame.user_id == gambler.id).first() def get_active_twentyone_game_state(gambler):