示例#1
0
def joker_combo(hand):
    hand = hand[:]
    b_joker_deck, r_joker_deck = create_deck('black'), create_deck('red')
    all_combos = []

    if '?B' in hand and '?R' in hand:  # Hand has both red joker and black joker
        hand.remove('?B')
        hand.remove('?R')
        for b in b_joker_deck:
            for r in r_joker_deck:
                # Can't replace joker with a card that already exists in the hand, like ['2H', '2H']
                if b not in hand and r not in hand:
                    all_combos += [hand + [b] + [r]]
    else:
        if '?B' in hand:  # Hand has only black joker
            joker_deck = b_joker_deck
            hand.remove('?B')
        elif '?R' in hand:  # Hand has only red joker
            joker_deck = r_joker_deck
            hand.remove('?R')

        for j in joker_deck:
            if j not in hand:  # Can't replace joker with a card that already exists in the hand
                all_combos += [hand + [j]]
    return all_combos
示例#2
0
def joker_combo(hand):
    hand = hand[:]
    b_joker_deck, r_joker_deck = create_deck('black'), create_deck('red')
    all_combos = []

    if '?B' in hand and '?R' in hand: # Hand has both red joker and black joker
        hand.remove('?B')
        hand.remove('?R')
        for b in b_joker_deck:
            for r in r_joker_deck:
                # Can't replace joker with a card that already exists in the hand, like ['2H', '2H']
                if b not in hand and r not in hand:
                    all_combos += [hand + [b] + [r]]
    else:
        if '?B' in hand: # Hand has only black joker
            joker_deck = b_joker_deck
            hand.remove('?B')
        elif '?R' in hand: # Hand has only red joker
            joker_deck = r_joker_deck
            hand.remove('?R')

        for j in joker_deck:
            if j not in hand: # Can't replace joker with a card that already exists in the hand
                all_combos += [hand + [j]]
    return all_combos
示例#3
0
def poker(deal=[], num_players=4, deck='standard'):
    if deal:
        newdeal = deal
    else:
        if num_players > 10: # Maximum 10 players can play using 1 deck of cards
            num_players = 10
        mydeck = create_deck(deck)
        newdeal = deal_cards(mydeck, num_players, 5)

    print '\n', 'Following hands were dealt:'
    poker_results, winner, max_value, i = {}, [], (), 0

    for hand in newdeal:
        poker_results[i] = [hand, best_wild_hand(hand)]
        print poker_results[i][0], '---->', poker_results[i][1][1]

        if poker_results[i][1][0] > max_value:
            max_value = poker_results[i][1][0]
            winner = [poker_results[i][0]]
            win_type = poker_results[i][1][1]
        elif poker_results[i][1][0] == max_value:
            if poker_results[i][0] not in winner:
                winner += [poker_results[i][0]]
        i += 1

    if len(winner) == 1:
        winner = winner[0]
    print '\n', 'The winner is:', winner, '---->', win_type
    print '---------------------------------------------------------------'
    return winner
示例#4
0
def poker(deal=[], num_players=4, deck='standard'):
    if deal:
        newdeal = deal
    else:
        if num_players > 10:  # Maximum 10 players can play using 1 deck of cards
            num_players = 10
        mydeck = create_deck(deck)
        newdeal = deal_cards(mydeck, num_players, 5)

    print '\n', 'Following hands were dealt:'
    poker_results, winner, max_value, i = {}, [], (), 0

    for hand in newdeal:
        poker_results[i] = [hand, best_wild_hand(hand)]
        print poker_results[i][0], '---->', poker_results[i][1][1]

        if poker_results[i][1][0] > max_value:
            max_value = poker_results[i][1][0]
            winner = [poker_results[i][0]]
            win_type = poker_results[i][1][1]
        elif poker_results[i][1][0] == max_value:
            if poker_results[i][0] not in winner:
                winner += [poker_results[i][0]]
        i += 1

    if len(winner) == 1:
        winner = winner[0]
    print '\n', 'The winner is:', winner, '---->', win_type
    print '---------------------------------------------------------------'
    return winner