コード例 #1
0
ファイル: main 2020-6.py プロジェクト: mohsen-haddadi/Stuffs
def play_a_hand():
    t1 = time.time()
    while True:
        if shifted_to_next_stage():
            read_board_cards()
            if not stages_are_sequenced():
                set_just_do_check_fold_to_true('stages are not sequenced')
                screenshot_error('stages are not sequenced')
        if its_my_turn():
            update_betting_rounds()
            read_and_save_bets()
            if config.bot_status == 'I_AM_PLAYING':
                click_decision()  #🌏🌱♣♠♦♥🌱🌏
        if t1 - time.time() > 5 * 60:
            fix_game_disruption('This hand last more than 5 minutes')
        config.new_hand = hand_is_ended()
        if config.new_hand:
            shout("-------- Hand ended --------", color='on_green')
            break
        if config.bot_status != 'I_AM_PLAYING':
            break
        if game_is_paused():
            input("press Enter to start again...")
            fix_game_disruption('game is unpaused')
            break
コード例 #2
0
ファイル: main.py プロジェクト: mohsen-haddadi/Stuffs
def play_a_hand():
    t1 = time.time()
    while True:
        if shifted_to_next_stage():
            read_board_cards()
            if not stages_are_sequenced():
                set_just_do_check_fold_to_true('stages are not sequenced')
                screenshot_error('stages are not sequenced')
        if its_my_turn():
            update_betting_rounds()
            read_and_save_bets()
            if config.bot_status == 'I_AM_PLAYING':
                click_decision()  #🌏🌱♣♠♦♥🌱🌏
        if t1 - time.time() > 5 * 60:
            config.bot_status = 'WAITING_FOR_FIRST_HAND'
            fix_game_disruption('This hand last more than 5 minutes')
        config.new_hand = hand_is_ended()
        if config.new_hand:
            shout("appending hand data to csv file", color='on_green')
            append_new_line_to_csv(config.csv_path)
            shout("-------- Hand ended --------", color='on_green')
            break
        if game_is_paused():
            fix_game_disruption('game is unpaused')
            break
        if config.bot_status != 'I_AM_PLAYING':
            break
コード例 #3
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" :
        c.bot_status = 'OPERATOR_SHOULD_PLAY_THE_HAND'
        # uncomment these 2 next lines and remove line above, 
        # when play.py module is completed.
        #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)
コード例 #4
0
ファイル: click.py プロジェクト: mohsen-haddadi/Stuffs
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 , bot_status

    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.bot_status == 'WAITING_FOR_FIRST_HAND':
            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)
コード例 #5
0
ファイル: click.py プロジェクト: mohsen-haddadi/Stuffs
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 , bot_status

    if pm.button_pixel(config.game_position, button_name):
        click(button_name)
        if button_name == 'exit':
            config.bot_status = 'ON_MAIN_MENU'

    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.bot_status == 'WAITING_FOR_FIRST_HAND':
                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.bot_status = 'ON_MAIN_MENU'
            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)
コード例 #6
0
ファイル: click.py プロジェクト: mohsen-haddadi/Stuffs
def check_fold():
    #global game_position, just_do_check_fold , my_seat_number , MY_PROFILE_NAME , bot_status
    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.bot_status != 'I_AM_PLAYING':
            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")
コード例 #7
0
def observing_a_hand():
    """Use wait_hand_ends_when_observing() before all breaks, 
    except one which ended without any problem.
    """

    set_seats_not_folded_dictionary()
    acted_players = 0
    t1 = time.time()
    while True:
        if shifted_to_next_stage():
            acted_players = 0
            read_board_cards()
            if not stages_are_sequenced():
                shout("Stages are not sequenced", color='on_light_red')
                screenshot_error('stages are not sequenced')
                wait_hand_ends_when_observing(waiting_minutes=30)
                break  # new line
        seat_to_report = find_seat_to_report(acted_players)
        if ready_to_report(seat_to_report):
            acted_players += 1
            report_the_player(seat_to_report)  #🗺️ 💎♣💎♠💎♦💎♥💎 🗺️
            #update_betting_rounds()
            #read_and_save_bets()
        if t1 - time.time() > 5 * 60:
            c.bot_status = 'WAITING_FOR_FIRST_HAND'
            fix_game_disruption('This hand last more than 5 minutes')
            wait_hand_ends_when_observing(waiting_minutes=30)
            break  # new line
        c.new_hand = hand_is_ended()
        if c.new_hand:
            declare_the_winners()
            wait_celebration_ends(waiting_seconds=10)
            # Hand is ended without any problem. Save statistical data here.
            shout('I should save statistical data here later.', 'rainbow')
            shout("-------- Hand ended --------", color='on_green')
            break
        if c.bot_status != 'OBSERVING':  # will not be used
            break
        if game_is_paused():
            fix_game_disruption('game is unpaused')
            if c.bot_status == 'OBSERVING':
                wait_hand_ends_when_observing(waiting_minutes=30)
            break
コード例 #8
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)
コード例 #9
0
        read_and_save_my_cards()
        rebuy_if_bank_is_low(min_blinds=15)
        read_and_save_banks_and_names()
        if config.bot_status != 'I_AM_PLAYING':
            continue
        play_sound_for_good_starting_hands()

        shout("Waiting for my turn at preflop_stage...", 'light_magenta')
        t1 = time.time()
        # Playing a whole hand in this loop
        while True:
            if shifted_to_next_stage():
                read_board_cards()
                if not stages_are_sequenced():
                    set_just_do_check_fold_to_true('stages are not sequenced')
                    screenshot_error('stages are not sequenced')
            if its_my_turn():
                update_betting_rounds()
                read_and_save_bets()
                if config.bot_status == 'I_AM_PLAYING':
                    click_decision()
            if t1 - time.time() > 5 * 60:
                fix_game_disruption('This hand last more than 5 minutes')
            new_hand = hand_is_ended()
            if new_hand:
                shout("-------- Hand ended --------", color='on_green')
                break
            if config.bot_status != 'I_AM_PLAYING':
                break

    else: