forked from MarseyWorld/MarseyWorld
rename Casino_Game to CasinoGame for consistency
parent
a71b21c1b6
commit
e48d133977
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue