Exemple #1
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()
Exemple #2
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.")