Example #1
0
def newgame2():
    '''
    Short circuits restarting the game.
    '''
    winnings = 0
    if request.method == 'POST':
        winnings = int(request.form['mydata'])
        database.changechips(user, database.fetchchips(user) + winnings - 500)
        return ""
Example #2
0
def getrank():
    '''
    Passes rank for database/match history purposes.
    '''
    if request.method == 'POST':
        place = (request.form['mydata'])
        now = datetime.datetime.now()
        database.addpastmatch(
            user,
            database.formatmatchdata(str(database.fetchchips(user)),
                                     str(place),
                                     now.strftime("%m/%d/%Y   %H'%M")))
        return ""
Example #3
0
def profile():
    '''
    Generates profile page after pressing profile button. Checks session.
    '''
    if user in session:
        chips = database.fetchchips(user)
        return render_template('profile.html',
                               username=user,
                               numchips=chips,
                               matches=database.getpastmatches(user),
                               logged_in=True)
    return render_template('index.html',
                           username="",
                           errors=True,
                           logged_in=False)
Example #4
0
def clearmatchinprogress():
    '''
    Clears match in progress. Checks session.
    '''
    if user in session:
        database.clearcurrmatch(user)
        return render_template('profile.html',
                               username=user,
                               numchips=database.fetchchips(user),
                               matches=database.getpastmatches(user),
                               logged_in=True,
                               alerts=["Current Match Cleared"])
    return render_template('index.html',
                           username="",
                           errors=True,
                           logged_in=False)
Example #5
0
def newgame():
    '''
    Brings up the game's html after starting/continuing game. Checks session.
    '''
    if user in session:
        if int(database.fetchchips(user)) < 0:
            return render_template(
                "index.html",
                username="",
                errors=True,
                alerts=["You have no chips left. Account suspended."],
                logged_in=False)
        return render_template('poker.html',
                               bank=500,
                               username=user,
                               logged_in=True)
    return render_template('index.html',
                           username="",
                           errors=True,
                           logged_in=False)
Example #6
0
def home():
    '''
    Generates mainpage. Passes user info.
    '''
    if user in session:
        if int(database.fetchchips(user)) < 0:
            return render_template(
                "index.html",
                username="",
                errors=True,
                alerts=["You have no chips left. Account suspended."],
                logged_in=False)
        return render_template('login.html',
                               username=user,
                               alerts=[],
                               errors=True,
                               logged_in=True,
                               game=database.readcurrmatch(user))
    return render_template('index.html',
                           username="",
                           errors=True,
                           logged_in=False)