Example #1
0
def init_round(game, player):
    turn_based.init_round(game, player)
    dealer_hand = game['dealer_hand']
    while hand_value(dealer_hand) < 16:
        cards.draw(out_of=game['draw_pile'], into=dealer_hand)
        player['log']()

    dhv = hand_value(dealer_hand)

    for player in game['players']:
        phv = hand_value(player['hand'])
        if phv > 21 or (phv < dhv and dhv <= 21):
            player['coins'] -= player['bet']
        else:
            player['coins'] += player['bet']
        game['draw_pile'] += player['hand']
        player['hand'] = []
        player['hand_value'] = 0
        player['log']()

    cards.deal(out_of=dealer_hand, into=[game['draw_pile']])
    deal_round(game)
Example #2
0
def action_hit(game, player):
    cards.draw(out_of=game['draw_pile'], into=player['hand'])
    player['hand_value'] = hand_value(player['hand'])
    if player['hand_value'] >= 21:
        return 'end_turn'
Example #3
0
def deal_round(game):
    shuffle(game['draw_pile'])
    cards.deal(game=game, num_cards=2)
    cards.draw(out_of=game['draw_pile'], into=game['dealer_hand'])