Esempio n. 1
0
def ocr_bet(seat):
    """
    If ocr fails this function will uses:
    1. fix_game_disruption()
    2. set_just_do_check_fold_to_true()
    """

    ocr_string = ocr.ocr_bet_to_string(config.game_position, seat)
    shout("bet ocr string at seat %s is: %s" % (seat, ocr_string))
    eval_string = replace_letters_comma_space_m_k(ocr_string)
    digit_string = eval_string.replace("*", "")

    if digit_string.isdigit():
        return eval(eval_string)
    # else include digit_string like: '', 'c540!'
    else:
        fix_game_disruption("ocr_bet is not digit at seat %s" % seat)
        ocr_string = ocr.ocr_bet_to_string(config.game_position, seat)
        shout("bet ocr string at seat %s is: %s" % (seat, ocr_string))
        eval_string = replace_letters_comma_space_m_k(ocr_string)
        digit_string = eval_string.replace("*", "")

        if digit_string.isdigit():
            return eval(eval_string)
        else:
            set_just_do_check_fold_to_true("ocr_bet is not digit")
            screenshot_error("ocr_bet is not digit at seat %s" % seat)
            return None
Esempio n. 2
0
def ocr_my_bank():
    """
    If ocr fails this function will uses:
    1. fix_game_disruption()
    Will not uses:
    1. set_just_do_check_fold_to_true()
    """
    #global my_seat_number , MY_PROFILE_NAME , waiting_for_first_hand , just_do_check_fold

    ocr_string = ocr.ocr_my_bank_to_string(config.game_position,
                                           config.my_seat_number)
    shout("my bank ocr string at seat %s is: %s" %
          (config.my_seat_number, ocr_string))
    eval_string = replace_letters_comma_space_m_k(ocr_string)
    digit_string = eval_string.replace("*", "")

    if digit_string.isdigit():
        return eval(eval_string)
    # else include digit_string like: '', 'c540!'
    else:
        fix_game_disruption("ocr_my_bank is not digit at seat %s" %
                            config.my_seat_number)
        ocr_string = ocr.ocr_my_bank_to_string(config.game_position,
                                               config.my_seat_number)
        shout("my bank ocr string at seat %s is: %s" %
              (config.my_seat_number, ocr_string))
        eval_string = replace_letters_comma_space_m_k(ocr_string)
        digit_string = eval_string.replace("*", "")

        if digit_string.isdigit():
            return eval(eval_string)
        else:
            screenshot_error("ocr_my_bank is not digit at seat %s" %
                             config.my_seat_number)
            return None
Esempio n. 3
0
def number_of_clicks_on_button(button_name, number): # Number of clicks 
    # for plus and minus buttons
    #global game_position, just_do_check_fold , my_seat_number , MY_PROFILE_NAME , waiting_for_first_hand

    number = int(number)
    if pm.button_pixel(config.game_position, button_name) :
        for i in range (number):
            click(button_name)
    else :
        time0 = time.time()
        fix_game_disruption("button %s is not visible" %button_name)
        time1 = time.time() - time0
        if config.waiting_for_first_hand == True:
            return None
        elif config.just_do_check_fold == True:
            if pm.button_pixel(config.game_position, 'check') :
                click('check')
            elif pm.button_pixel(config.game_position, 'fold') :
                click('fold') 
            else:
                screenshot_error("check and fold buttons are not visible") 
        if pm.player_cards_pixel(config.game_position,  config.my_seat_number ) \
        and pm.button_pixel(config.game_position, button_name) and time1 <= 10 :
            for i in range (number):
                click(button_name)
        else :
            set_just_do_check_fold_to_true("There is problem on clicking on button %s" %button_name)
Esempio n. 4
0
def click_on_button(button_name): 
    # for call, check, fold, bet, raise,
    # exit, menu, rebuy_menu,
    # exit_yes, leave_next_hand_ok, buy_in, and re_buy buttons.
    #global game_position, just_do_check_fold , my_seat_number , MY_PROFILE_NAME , waiting_for_first_hand 

    if pm.button_pixel(config.game_position, button_name) : 
        click(button_name) 
        if button_name == 'exit':
            config.waiting_for_first_hand = None

    else :

        if button_name in ('call', 'check', 'fold', 'bet', 'raise') :

            time0 = time.time()
            fix_game_disruption("button %s is not visible" %button_name )
            time1 = time.time() - time0
            if config.waiting_for_first_hand == True:
                return None
            elif config.just_do_check_fold == True:
                if pm.button_pixel(config.game_position, 'check') :
                    click('check')
                elif pm.button_pixel(config.game_position, 'fold') :
                    click('fold') 
                else:
                    screenshot_error("check and fold buttons are not visible")  
            elif pm.player_cards_pixel(config.game_position, config.my_seat_number ) \
            and pm.button_pixel(config.game_position, button_name) and time1 <= 10 :
                click(button_name) #new function
            else :
                set_just_do_check_fold_to_true("There is problem on clicking on button %s" %button_name)

        elif button_name in ('exit', 'menu', 'rebuy_menu'):

            fix_game_disruption("button %s is not visible" %button_name )
            if pm.button_pixel(config.game_position, button_name):
                click(button_name)
                if button_name == 'exit':
                    config.waiting_for_first_hand = None
            else:
                raise_exception_the_problem("button %s is not visible" %button_name)

        elif button_name in ('exit_yes', 'leave_next_hand_ok', 'buy_in', 're_buy'):

            raise_exception_the_problem("button %s is not visible" %button_name)
Esempio n. 5
0
def check_fold():
    #global game_position, just_do_check_fold , my_seat_number , MY_PROFILE_NAME , waiting_for_first_hand
    if pm.button_pixel(config.game_position, 'check') :
        click('check')
    elif pm.button_pixel(config.game_position, 'fold') :
        click('fold') 
    else :

        fix_game_disruption("check_fold()")
        if config.waiting_for_first_hand != False:
            return None
        elif pm.button_pixel(config.game_position, 'check') :
            click('check')
        elif pm.button_pixel(config.game_position, 'fold') :
            click('fold') 
        else:
            set_just_do_check_fold_to_true("check_fold()(It's already True)") 
            screenshot_error("check and fold buttons are not visible")      
Esempio n. 6
0
def click_decision():

    decision = decision_making.decide.decide()
    if decision[0] == "check" :
        check()
    elif decision[0] == "call" :
        call()
    elif decision[0] == "fold" :
        fold()
    elif decision[0] == "raise" :
        raising(decision[1] * BLIND_VALUE)
    elif decision[0] == "all_in" :
        all_in()
    elif decision[0] == "check_fold" :
        check_fold()
    elif decision[0] == "not defined" :
        screenshot_error("decide function deficiency")
        check_fold()
    elif decision == None:
        screenshot_error("A play function returned None")
        check_fold()
    else :
        screenshot_error("returned string is not in standard format")
        check_fold()
    time.sleep(1)
Esempio n. 7
0

    elif waiting_for_first_hand == None :
        raise Exception("5.This can not happen IN FUTURE becuase main menu automation is built\
                        ( fix_game_disruption --> Sit_In --> table is full --> exit -->\
                        waiting_for_first_hand = None --> main menu --> waiting_for_first_hand = True )")

""

#-------    

    if Hand_End_Cheker1 == False and pm.pre_flop_pixel(game_position) == False \
    and waiting_for_first_hand == False and just_do_check_fold != True :
        fix_game_disruption("2")
        set_just_do_check_fold_to_true("2")
        screenshot_error('6. pm.pre_flop_pixel() == False')
    elif Hand_End_Cheker1 == False and waiting_for_first_hand == False and just_do_check_fold != True :
        Pre_Flop1 = True #(2020: Pre_Flop1 has no usage)
        preflop_stage = True

    if Hand_End_Cheker1 == False and pm.player_cards_pixel(game_position,  my_seat_number ) == True and waiting_for_first_hand == False :  
        read_and_global_my_cards() #
        play_sound() #


    its_my_turn = False
    Gray1 = True ; fo = 0 
    time1 = time.time()
    shout("Looking for light...", color = 'light_magenta') 
    while Hand_End_Cheker1 == False and (its_my_turn == False or Gray1 == True) and flop_stage == False and waiting_for_first_hand == False and time.time() - time1 < 5 * 60 :
        if pm.button_pixel(game_position, 'i_am_back') :