Beispiel #1
0
def check_is_turn(screen_area, deck, stack_collection, db):
    element_area = introduction.save_element(screen_area, 'turn_area', db)
    if image_processing.search_element(element_area, ['turn'], 'green_board/', db) is False:
        if len(session_log.get_actual_hand(screen_area, db)) == 10:
            turn = image_processing.search_cards(element_area, deck, 2, db)
            session_log.update_hand_after_turn(str(screen_area), turn, db)
        last_row = session_log.get_last_row_from_log_session(screen_area, db)
        hand = last_row[0][0]
        stack = current_stack.get_actual_game_data(screen_area, stack_collection, db)
        if make_turn_decision(screen_area, hand, stack, stack_collection, db):
            return True
    return False
Beispiel #2
0
def check_is_fold(screen_area, x_coordinate, y_coordinate, width, height, image_path, db):
    last_hand = session_log.get_last_row_from_log_session(screen_area, db)[0]['hand']
    last_hand = last_hand[:4]
    image_processing.imaging(x_coordinate, y_coordinate, width, height, image_path, screen_area, db)
    cur_hand = image_processing.search_cards(screen_area, db_query.get_cards(db), 4, db)
    if last_hand != cur_hand:
        folder_name = IMAGES_FOLDER + '/' + str(datetime.datetime.now().date())
        image_name = str(math.floor(time.time())) + ".png"
        session_log.update_action_log_session('end', str(screen_area), db)
        current_stack.save_stack_image(screen_area, image_name, folder_name, db)
        check_conditions_before_insert(cur_hand, int(screen_area), db_query.get_stack_images(db), image_name, folder_name, db)
        get_decision(screen_area, db)
        return True
Beispiel #3
0
def check_is_river(screen_area, deck, stack_collection, db):
    element_area = introduction.save_element(screen_area, 'river_area', db)
    if image_processing.search_element(element_area, ['river'], 'green_board/',
                                       db) is False:
        if len(session_log.get_actual_hand(screen_area, db)) == 12:
            river = image_processing.search_cards(element_area, deck, 2, db)
            session_log.update_hand_after_turn(str(screen_area), river, db)
        last_row = session_log.get_last_row_from_log_session(screen_area, db)
        hand = last_row[0][0]
        stack = last_row[0][1]
        action = last_row[0][3]
        if make_river_decision(screen_area, hand, stack, action,
                               stack_collection, db):
            return True
    return False
Beispiel #4
0
def make_flop_decision(screen_area, hand, image_name, folder_name, stack,
                       action, is_headsup, flop_deck, stack_collection, db):
    try:
        save_flop_image(screen_area, image_name, folder_name, db)
        flop_area = db_query.get_flop_area(screen_area, db)
        flop_card = image_processing.search_cards(str(flop_area), flop_deck, 6,
                                                  db)
        hand = hand + flop_card
        opponent_reaction = image_processing.search_last_opponent_action(
            screen_area, db)
        if not isinstance(opponent_reaction, str):
            opponent_reaction = opponent_reaction['alias']
        session_log.update_hand_after_flop(str(screen_area), hand, db)
        hand_value = get_hand_value(hand, screen_area, db)
        combination_value = db_query.get_combination_value(
            'flop', hand_value, db)
        flop_action(screen_area, action, hand_value, combination_value, stack,
                    is_headsup, opponent_reaction, stack_collection, db)
    except Exception as e:
        error_log.error_log('makeFlopDecision' + action, str(e))
        print(e)
Beispiel #5
0
def start():
    global APP_STATE
    if not APP_STATE:
        APP_STATE = remote_control.get_app_state()
    for item in SCREEN_DATA:
        mouse.move_mouse(item['x_mouse'], item['y_mouse'])
        if metka.search_bar(item['screen_area'], DB):
            image_name = str(math.floor(time.time())) + ".png"
            image_path = os.path.join(IMAGES_FOLDER,
                                      str(datetime.datetime.now().date()),
                                      str(item['screen_area']), image_name)
            last_row_action = session_log.get_last_row_action_from_log_session(
                item['screen_area'], DB)
            if last_row_action in ('push', 'fold', 'end'):
                image_processing.imaging(item['x_coordinate'],
                                         item['y_coordinate'], item['width'],
                                         item['height'], image_path,
                                         item['screen_area'], DB)
                hand = image_processing.search_cards(item['screen_area'], DECK,
                                                     4, DB)
                introduction.check_conditions_before_insert(
                    hand, item['screen_area'], STACK_COLLECTION, image_name,
                    FOLDER_NAME, DB)
                introduction.get_decision(item['screen_area'], DB)
            elif last_row_action in ('open', 'call', 'check'):
                introduction.action_after_open(
                    item['x_coordinate'], item['y_coordinate'], item['width'],
                    item['height'], image_path, item['screen_area'],
                    last_row_action, image_name, FOLDER_NAME, DECK,
                    STACK_COLLECTION, DB)
            elif last_row_action == 'cbet':
                postflop.action_after_cbet(item['x_coordinate'],
                                           item['y_coordinate'], item['width'],
                                           item['height'], image_path,
                                           item['screen_area'], DECK,
                                           STACK_COLLECTION, DB)
            elif last_row_action in ('turn_cbet', 'river_cbet'):
                postflop.action_after_turn_cbet(item['x_coordinate'],
                                                item['y_coordinate'],
                                                item['width'], item['height'],
                                                image_path,
                                                item['screen_area'], DECK,
                                                STACK_COLLECTION, DB)
            elif last_row_action == 'cc_postflop':
                postflop.action_after_cc_postflop(item['screen_area'], DECK,
                                                  item['x_coordinate'],
                                                  item['y_coordinate'],
                                                  item['width'],
                                                  item['height'], image_path,
                                                  STACK_COLLECTION, DB)
            elif last_row_action == 'value_bet':
                postflop.action_after_value_bet(item['screen_area'],
                                                item['x_coordinate'],
                                                item['y_coordinate'],
                                                item['width'], item['height'],
                                                image_path, DB)
            else:
                hand = session_log.get_last_row_from_log_session(
                    item['screen_area'], DB)
                if image_processing.check_current_hand(item['screen_area'],
                                                       hand[0]['hand'], DB):
                    introduction.get_decision(str(item['screen_area']), DB)
                else:
                    session_log.update_action_log_session(
                        'end', str(item['screen_area']), DB)