Exemplo n.º 1
0
def join_multi():
    if 'room_key' in request.form and request.form['room_key'] != '':
        if table_handler.table_exist(request.form['room_key']):
            print('valid room key')
            if table_handler.isFull(
                    table_handler.identifier_to_id(request.form['room_key'])):
                print('room is full')
            else:
                table_handler.join_table(
                    table_handler.identifier_to_id(request.form['room_key']),
                    identifier_to_steamid(request.cookies.get('identifier')))
                print('Joined room')
                return render_template(
                    'multiplayer/blackjack.html',
                    website_info=configuration_handler.load('website'))

        else:
            print('Invalid room key')

    else:
        print('Auto joining room')
        table_handler.auto_join(
            identifier_to_steamid(request.cookies.get('identifier')))

        print('Joined room')
        return render_template(
            'multiplayer/blackjack.html',
            website_info=configuration_handler.load('website'))

    return redirect('/multi')
Exemplo n.º 2
0
def steamid_to_name(steamid):
    config = configuration_handler.load('keys')

    response = requests.get(
        ' http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={0}&steamids={1}'
        .format(config.steam_api_key, steamid))

    return response.json()['response']['players'][0]['personaname']
Exemplo n.º 3
0
def join_game():
    if balance_handler.sufficent_funds(request.cookies.get('identifier'),
                                       float(request.form['bet-amount'])):
        deck_identifier = game_handler.init_game(
            request.cookies.get('identifier'),
            float(request.form['bet-amount']))
        deck_handler.init_deck(deck_identifier)

        return render_template(
            'singleplayer/blackjack.html',
            website_info=configuration_handler.load('website'))

    return 'insufficent funds'
Exemplo n.º 4
0
def payout_bet(steamid):
    game = db.session.query(Game).filter(Game.player_steamid == steamid).one()

    payout_config = configuration_handler.load('payouts')

    game_state = get_game_state(steamid)
    print('Got game state')

    if game_state == Game_state.player_blackjack:
        add_balance(steamid_to_identifer(steamid),
                    game.bet * float(payout_config.blackjack))

        print('Payed out ' + str(game.bet * float(payout_config.blackjack)))

    elif game_state == Game_state.player_lead or game_state == Game_state.cpu_busted:
        add_balance(steamid_to_identifer(steamid),
                    game.bet * float(payout_config.regular))

        print('Payed out ' + str(game.bet * float(payout_config.regular)))
Exemplo n.º 5
0
def multi_index():
    return render_template('multiplayer/index.html',
                           website_info=configuration_handler.load('website'))
Exemplo n.º 6
0
def index():
    return render_template('index.html', website_info=configuration_handler.load('website'))
Exemplo n.º 7
0
def isFull(table_id):
    if db.session.query(Active_player).filter(
            Active_player.table_id == table_id).count() < int(
                configuration_handler.load('table').max_players) + 1:
        return False
    return True