Example #1
0
def flop():
    """模拟发3张公牌
    """
    deck = Deck()
    board = deck.deal_hands(3)
    myhand = deck.deal_hands(2)
    return myhand, board, deck
Example #2
0
def river():
    """模拟发5张公牌
    """
    deck = Deck()
    board = deck.deal_hands(5)
    myhand = deck.deal_hands(2)
    return myhand, board, deck
Example #3
0
def index():
    if request.method == "GET":
        return render_template("index.html")
    elif request.method == "POST":
        try:
        
            form = get_form_data(request)
            
            my_2_cards, board_cards = list(), list() 
            for k, v in form.items():
                card_code = int(k.split("_")[-1])
                option = int(v)
                if option == 1: # 手牌
                    my_2_cards.append(_CARD_CODES[card_code])
                elif option == 2:
                    board_cards.append(_CARD_CODES[card_code])
    
            rest_cards = Deck().cards
            for c in (my_2_cards + board_cards):
                rest_cards.remove(c)
            
            if len(board_cards) == 5:
                odd = river_round_solver(my_2_cards, board_cards, rest_cards)
            elif len(board_cards) == 4:
                odd = turn_round_solver(my_2_cards, board_cards, rest_cards)
            elif len(board_cards) == 3:
                odd = flop_round_solver(my_2_cards, board_cards, rest_cards)
    
            form["odd"] = str(odd)
    
            return render_template("index.html", **form)
        except:
            return render_template("index.html") 
    else:
        raise Exception()
Example #4
0
def turn():
    """模拟发4张公牌
    """
    deck = Deck()
    board = deck.deal_hands(4)
    myhand = deck.deal_hands(2)
    return myhand, board, deck
Example #5
0
def main_loop():
    while 1:
        print("game start!")
        my_2_cards, board_cards = UserInput()
        rest_cards = Deck().cards
        for c in (my_2_cards + board_cards):
            rest_cards.remove(c)
    
        if len(board_cards) == 5:
            river_round_solver(my_2_cards, board_cards, rest_cards)
        elif len(board_cards) == 4:
            turn_round_solver(my_2_cards, board_cards, rest_cards)
        elif len(board_cards) == 3:
            flop_round_solver(my_2_cards, board_cards, rest_cards)
        else:
            print("wrong input, again.")