Ejemplo n.º 1
0
def opponent():
    actions.move_cursor(
        [randint(defines.origin[0], defines.game_screen_res[0]), randint(defines.origin[1], defines.game_screen_res[1])]
    )
    logging.info("[ENTER] opponent")
Ejemplo n.º 2
0
def opponent():
    actions.move_cursor([
        randint(defines.origin[0], defines.game_screen_res[0]),
        randint(defines.origin[1], defines.game_screen_res[1])
    ])
    logging.info("[ENTER] opponent")
Ejemplo n.º 3
0
def player():
    global src
    global NEW_GAME, opponent_char, player_char, stage, current_decknum
    logging.info("[ENTER] player")
    control_success = (
        True
    )  # keep track of whether or not the bot was able to control the mouse.  If not the user is attempting to use it
    actions.pause_pensively(1)

    if NEW_GAME:
        src = vision.screen_cap()
        stage = vision.get_image_info_sift(src, stage_descs, c(defines.stage_box))
        NEW_GAME = False

    # logging.info("------GET MATCH INFO------")
    src = vision.screen_cap()
    if player_char == None:
        try:
            player_char = vision.get_image_info_sift(src, character_descs, c(defines.player_box))
        except:
            player_char = None
    if stage == None:
        try:
            stage = vision.get_image_info_sift(src, stage_descs, c(defines.stage_box))
        except:
            stage = None

    # logging.info("---ATTACK WITH CHARACTER---")
    actions.pause_pensively(0.25)
    src = vision.screen_cap()
    player_attack = vision.color_range_reduced_mids(src, c(defines.reduced_player_box), color="green")
    if player_attack and control_success:
        control_success = actions.move_and_leftclick(c(defines.neutral_minion))
        control_success = actions.move_and_leftclick(c(defines.player_hero))
        # actions.move_cursor([player_attack[0][0],player_attack[0][1]+10])
        actions.pause_pensively(0.1)
        src = vision.screen_cap()
        enemy = []
        enemy.extend(vision.color_range_reduced_mids(src, c(defines.reduced_opponent_box1), color="red"))
        enemy.extend(vision.color_range_reduced_mids(src, c(defines.reduced_opponent_box2), color="red"))
        enemy_minions = vision.get_taunt_minions(src, c(defines.enemy_minions_box_taunts))
        if enemy_minions:
            e_m = randint(0, len(enemy_minions) - 1)  # attack a random taunt minion

        if enemy_minions:
            control_success = actions.move_and_leftclick(enemy_minions[e_m])
        elif enemy:
            control_success = actions.move_and_leftclick(c(defines.opponent_hero))
        else:
            # something's wrong, try to attack any minion
            actions.pause_pensively(6)
            enemy_minions = vision.color_range_reduced_mids(src, c(defines.reduced_enemy_minions_box), color="red")
            if enemy_minions:
                control_success = actions.move_and_leftclick(enemy_minions[0])
        control_success = actions.move_and_leftclick(c(defines.neutral))

    # logging.info("------PLAY CARDS------")
    player_cards = vision.get_playable_cards(src, c(defines.hand_box))
    player_cards_combo = vision.get_playable_cards(src, c(defines.hand_box), color="yellow")
    if player_cards_combo and player_char == "rogue":  # active combo cards are played before non-combo cards
        player_cards = player_cards_combo
    while player_cards and control_success:
        control_success = actions.move_and_leftclick(player_cards[weighted_randint(len(player_cards))])
        actions.move_cursor(c(defines.nuetral_targeting))
        src = vision.screen_cap()
        targeting = vision.color_range_reduced_mids(src, c(defines.nuetral_targeting_box), color="red_targeting")
        if targeting:
            if defines.TARGETING[current_decknum] == defines.Target.OPPONENT_HERO:
                control_success = actions.move_and_leftclick(c(defines.opponent_hero))
        if defines.TARGETING[current_decknum] == defines.Target.OPPONENT_HERO:
            actions.move_and_leftclick(c(defines.play_card[randint(0, len(defines.play_card) - 1)]))
            actions.move_cursor(c(defines.nuetral_targeting))
            src = vision.screen_cap()
            targeting = vision.color_range_reduced_mids(src, c(defines.nuetral_targeting_box), color="red_targeting")
            if targeting:
                if defines.TARGETING[current_decknum] == defines.Target.OPPONENT_HERO:
                    control_success = actions.move_and_leftclick(c(defines.opponent_hero))

        control_success = actions.move_and_rightclick(c(defines.neutral_minion))
        actions.pause_pensively(1.5)
        src = vision.screen_cap()
        player_cards = vision.get_playable_cards(src, c(defines.hand_box))
        player_cards_combo = vision.get_playable_cards(src, c(defines.hand_box), color="yellow")
        if player_cards_combo:  # active combo cards are played before non-combo cards
            player_cards = player_cards_combo

        if not actions.check_game("Hearthstone"):
            break

    # logging.info("------PLAY ABILITY------")
    actions.pause_pensively(0.50)
    src = vision.screen_cap()
    player_ability = vision.color_range_reduced_mids(src, c(defines.reduced_ability_box), color="green")
    if player_ability and player_char and control_success:
        if player_char == "mage":
            control_success = actions.move_and_leftclick(c(defines.player_ability))
            control_success = actions.move_and_leftclick(c(defines.opponent_hero))
        elif player_char == "priest":
            control_success = actions.move_and_leftclick(c(defines.player_ability))
            control_success = actions.move_and_leftclick(c(defines.player_hero))
        else:
            control_success = actions.move_and_leftclick(c(defines.player_ability))
            control_success = actions.move_and_leftclick(c(defines.neutral_minion))
            control_success = actions.move_and_rightclick(c(defines.neutral_minion))
        actions.pause_pensively(2)
    player_ability = 0
    # logging.info("---ATTACK WITH MINIONS---")
    src = vision.screen_cap()
    player_minions = vision.color_range_reduced_mids(
        src, c(defines.reduced_player_minions_box), color="green", min_threshold=45, max_threshold=200
    )
    while player_minions and control_success:
        p_m = False
        no_enemy_taunts_detected = True
        min_subset = [False, 99]
        src = vision.screen_cap()
        enemy_minions = vision.get_taunt_minions(src, c(defines.enemy_minions_box_taunts))

        if enemy_minions:
            no_enemy_taunts_detected = False
            if defines.RANDOM_ATTACKS or defines.ref_game_screen_res_list[defines.GAME_SCREEN_RES] == [1400, 1050]:
                p_m = player_minions[randint(0, len(player_minions) - 1)]  # attack with a random minion
                e_m = enemy_minions[randint(0, len(enemy_minions) - 1)]  # attack a random taunt minion
            else:
                if control_success:
                    player_minions_data = vision.all_minion_data(
                        src,
                        defines.player_minion_data_split,
                        defines.c(defines.player_minions_box),
                        minions_box_playable=defines.c(defines.reduced_player_minions_box),
                        stage=stage,
                    )
                    enemy_minions_data = vision.all_minion_data(
                        src,
                        defines.enemy_minion_data_split,
                        defines.c(defines.enemy_minions_box),
                        minions_box_taunts_reduced=c(defines.reduced_enemy_minions_box),
                        minions_box_taunts=defines.c(defines.enemy_minions_box_taunts),
                        stage=stage,
                        reduced_color="red",
                    )
                    # print ''
                    # for i in range(0,len(enemy_minions_data)):
                    #    print enemy_minions_data[i]
                    # print ""
                    # for i in range(0,len(player_minions_data)):
                    #    print player_minions_data[i]

                    playable_minions = []
                    for player_minion in player_minions_data:
                        if player_minion["playable"] == True:
                            playable_minions.append(player_minion)
                    if playable_minions == []:
                        break

                    taunt_minions = []
                    for enemy_minion in enemy_minions_data:
                        if enemy_minion["taunt"] == True:
                            taunt_minions.append(enemy_minion)
                    subsets = []
                    for L in range(0, len(playable_minions) + 1):
                        for subset in combinations(playable_minions, L):
                            attack_total = 0
                            for individual in subset:
                                if "attack" in individual:
                                    if individual["attack"] != " ":
                                        attack_total += int(individual["attack"])
                            if subset:
                                subsets.append([subset, attack_total])

                    min_subset = [False, 99]
                    # max_taunt  = 0
                    min_difference = 99
                    for taunt_minion in taunt_minions:
                        # if taunt_minion['defense']>max_taunt[0]:
                        #    max_taunt=taunt_minion['defense']

                        if "defense" in taunt_minion:
                            if taunt_minion["defense"] == " ":
                                taunt_minion["defense"] = "5"
                        else:
                            taunt_minion["defense"] = "5"

                        for subset in subsets:
                            difference = abs(subset[1] - int(taunt_minion["defense"]))
                            if (
                                subset[1] >= taunt_minion["defense"]
                                and difference < min_difference
                                and (subset[1] < min_subset[1] or len(subset) < len(min_subset))
                            ):  # attack_total > taunt defense
                                min_subset = subset
                                min_difference = difference
                                p_m = min_subset[0][0]["coord"]
                                e_m = taunt_minion["coord"]

                    if p_m == False:
                        p_m = player_minions[randint(0, len(player_minions) - 1)]  # attack with a random minion
                        e_m = enemy_minions[randint(0, len(enemy_minions) - 1)]  # attack a random taunt minion
                    # print 'Use subset: ',min_subset
        else:
            no_enemy_taunts_detected = True
            if len(player_minions) > 1:
                p_m = player_minions[randrange(0, len(player_minions) - 1)]
            else:
                p_m = player_minions[0]

        control_success = actions.move_and_leftclick(p_m)
        actions.move_cursor(
            [p_m[0], p_m[1] + int(150 * float(defines.game_screen_res[1]) / float(defines.ref_game_screen_res[1]))]
        )
        actions.pause_pensively(0.2)

        src = vision.screen_cap()
        enemy = []
        enemy_freeze = None
        enemy.extend(vision.color_range_reduced_mids(src, c(defines.reduced_opponent_box1), color="red"))
        enemy.extend(vision.color_range_reduced_mids(src, c(defines.reduced_opponent_box2), color="red"))
        enemy_freeze = vision.color_range_reduced_mids(src, c(defines.reduced_opponent_box1), color="blue")
        enemy_minions = vision.get_taunt_minions(src, c(defines.enemy_minions_box_taunts))
        if enemy_minions and no_enemy_taunts_detected:  # something wrong has happened, try a bunch of stuff
            control_success = actions.move_and_leftclick(c(defines.opponent_hero))
            actions.pause_pensively(2)
            control_success = actions.move_and_leftclick(p_m)
            actions.move_cursor(
                [p_m[0], p_m[1] + int(150 * float(defines.game_screen_res[1]) / float(defines.ref_game_screen_res[1]))]
            )
            actions.pause_pensively(0.2)
            e_m = enemy_minions[randint(0, len(enemy_minions) - 1)]  # attack a random taunt minion
            control_success = actions.move_and_leftclick(e_m)
            control_success = actions.move_and_rightclick(c(defines.neutral_minion))
            actions.pause_pensively(2.5)
        elif enemy_minions:
            control_success = actions.move_and_leftclick(e_m)
            control_success = actions.move_and_leftclick(c(defines.opponent_hero))
            control_success = actions.move_and_rightclick(c(defines.neutral_minion))
            actions.pause_pensively(2.5)
        elif enemy:
            control_success = actions.move_and_leftclick(c(defines.opponent_hero))
        elif enemy_freeze:
            control_success = actions.move_and_leftclick(c(defines.opponent_hero))
        else:
            # something's wrong, try to attack any minion
            actions.pause_pensively(6)
            enemy_minions = vision.color_range_reduced_mids(src, c(defines.reduced_enemy_minions_box), color="red")
            if enemy_minions:
                e_m = enemy_minions[randint(0, len(enemy_minions) - 1)]  # attack a random taunt minion
                control_success = actions.move_and_leftclick(e_m)
                control_success = actions.move_and_rightclick(c(defines.neutral_minion))
                actions.pause_pensively(2.5)
            else:
                actions.pause_pensively(6)
        control_success = actions.move_and_rightclick(c(defines.neutral_minion))
        src = vision.screen_cap()
        state_name = vision.get_state_sift(
            src,
            state_descs,
            ignore_list=[
                "versus.png",
                "defeat.png",
                "finding_opponent.png",
                "gold.png",
                "opponent_still_choosing.png",
                "starting_hand.png",
                "rank.png",
                "victory.png",
            ],
        )
        if state_name == "play":
            break
        if not actions.check_game("Hearthstone"):
            break
        player_minions = vision.color_range_reduced_mids(
            src, c(defines.reduced_player_minions_box), color="green", min_threshold=45, max_threshold=200
        )

    # logging.info("------PLAY INFO CHECK-------")
    actions.pause_pensively(0.25)
    src = vision.screen_cap()
    state_name = vision.get_state_sift(src, state_descs)
    player_cards = vision.get_playable_cards(src, c(defines.hand_box))
    player_ability = vision.color_range_reduced_mids(src, c(defines.reduced_ability_box), color="green")

    if (
        player_ability
    ):  # player ability still shows up even though we've past that section above, chances are the character is wrong
        try:
            player_char = vision.get_image_info_sift(src, character_descs, c(defines.player_box))
        except:
            player_char = None

    player_minions = vision.color_range_reduced_mids(
        src, c(defines.reduced_player_minions_box), color="green", min_threshold=45, max_threshold=200
    )
    player_attack = vision.color_range_reduced_mids(src, c(defines.reduced_player_box), color="green")
    if (
        (player_cards == [] and player_ability == [] and player_minions == [] and player_attack == [])
        or player_cards == None
        or player_ability == None
        or player_minions == None
        or player_attack == None
        and control_success
        and (
            state_name == defines.State.PLAYER
            or state_name == defines.State.OPPONENT
            or state_name == defines.State.PLAYER_GREEN
        )
    ):
        # logging.info("---END TURN---")
        control_success = actions.move_and_leftclick(c(defines.neutral))
        player_turn_green_check = vision.color_range_reduced_mids(src, c(defines.turn_box), color="green")
        if player_turn_green_check != [] and player_turn_green_check != None and control_success:
            control_success = actions.move_and_leftclick(c(defines.turn_button))
            control_success = actions.move_and_leftclick(c(defines.neutral))
        else:
            actions.pause_pensively(5)
            player_end()
Ejemplo n.º 4
0
def player():
    global src
    global NEW_GAME, opponent_char, player_char, stage, current_decknum
    logging.info("[ENTER] player")
    control_success = True  #keep track of whether or not the bot was able to control the mouse.  If not the user is attempting to use it
    actions.pause_pensively(1)

    if NEW_GAME:
        src = vision.screen_cap()
        stage = vision.get_image_info_sift(src, stage_descs,
                                           c(defines.stage_box))
        NEW_GAME = False

    #logging.info("------GET MATCH INFO------")
    src = vision.screen_cap()
    if player_char == None:
        try:
            player_char = vision.get_image_info_sift(src, character_descs,
                                                     c(defines.player_box))
        except:
            player_char = None
    if stage == None:
        try:
            stage = vision.get_image_info_sift(src, stage_descs,
                                               c(defines.stage_box))
        except:
            stage = None

    #logging.info("---ATTACK WITH CHARACTER---")
    actions.pause_pensively(0.25)
    src = vision.screen_cap()
    player_attack = vision.color_range_reduced_mids(
        src, c(defines.reduced_player_box), color='green')
    if player_attack and control_success:
        control_success = actions.move_and_leftclick(c(defines.neutral_minion))
        control_success = actions.move_and_leftclick(c(defines.player_hero))
        #actions.move_cursor([player_attack[0][0],player_attack[0][1]+10])
        actions.pause_pensively(0.1)
        src = vision.screen_cap()
        enemy = []
        enemy.extend(
            vision.color_range_reduced_mids(src,
                                            c(defines.reduced_opponent_box1),
                                            color='red'))
        enemy.extend(
            vision.color_range_reduced_mids(src,
                                            c(defines.reduced_opponent_box2),
                                            color='red'))
        enemy_minions = vision.get_taunt_minions(
            src, c(defines.enemy_minions_box_taunts))
        if enemy_minions:
            e_m = randint(0,
                          len(enemy_minions) -
                          1)  #attack a random taunt minion

        if enemy_minions:
            control_success = actions.move_and_leftclick(enemy_minions[e_m])
        elif enemy:
            control_success = actions.move_and_leftclick(
                c(defines.opponent_hero))
        else:
            #something's wrong, try to attack any minion
            actions.pause_pensively(6)
            enemy_minions = vision.color_range_reduced_mids(
                src, c(defines.reduced_enemy_minions_box), color='red')
            if enemy_minions:
                control_success = actions.move_and_leftclick(enemy_minions[0])
        control_success = actions.move_and_leftclick(c(defines.neutral))

    #logging.info("------PLAY CARDS------")
    player_cards = vision.get_playable_cards(src, c(defines.hand_box))
    player_cards_combo = vision.get_playable_cards(src,
                                                   c(defines.hand_box),
                                                   color='yellow')
    if player_cards_combo and player_char == 'rogue':  #active combo cards are played before non-combo cards
        player_cards = player_cards_combo
    while player_cards and control_success:
        control_success = actions.move_and_leftclick(
            player_cards[weighted_randint(len(player_cards))])
        actions.move_cursor(c(defines.nuetral_targeting))
        src = vision.screen_cap()
        targeting = vision.color_range_reduced_mids(
            src, c(defines.nuetral_targeting_box), color='red_targeting')
        if targeting:
            if defines.TARGETING[
                    current_decknum] == defines.Target.OPPONENT_HERO:
                control_success = actions.move_and_leftclick(
                    c(defines.opponent_hero))
        if defines.TARGETING[current_decknum] == defines.Target.OPPONENT_HERO:
            actions.move_and_leftclick(
                c(defines.play_card[randint(0,
                                            len(defines.play_card) - 1)]))
            actions.move_cursor(c(defines.nuetral_targeting))
            src = vision.screen_cap()
            targeting = vision.color_range_reduced_mids(
                src, c(defines.nuetral_targeting_box), color='red_targeting')
            if targeting:
                if defines.TARGETING[
                        current_decknum] == defines.Target.OPPONENT_HERO:
                    control_success = actions.move_and_leftclick(
                        c(defines.opponent_hero))

        control_success = actions.move_and_rightclick(c(
            defines.neutral_minion))
        actions.pause_pensively(1.5)
        src = vision.screen_cap()
        player_cards = vision.get_playable_cards(src, c(defines.hand_box))
        player_cards_combo = vision.get_playable_cards(src,
                                                       c(defines.hand_box),
                                                       color='yellow')
        if player_cards_combo:  #active combo cards are played before non-combo cards
            player_cards = player_cards_combo

        if not actions.check_game('Hearthstone'):
            break

    #logging.info("------PLAY ABILITY------")
    actions.pause_pensively(0.50)
    src = vision.screen_cap()
    player_ability = vision.color_range_reduced_mids(
        src, c(defines.reduced_ability_box), color='green')
    if player_ability and player_char and control_success:
        if player_char == 'mage':
            control_success = actions.move_and_leftclick(
                c(defines.player_ability))
            control_success = actions.move_and_leftclick(
                c(defines.opponent_hero))
        elif player_char == 'priest':
            control_success = actions.move_and_leftclick(
                c(defines.player_ability))
            control_success = actions.move_and_leftclick(c(
                defines.player_hero))
        else:
            control_success = actions.move_and_leftclick(
                c(defines.player_ability))
            control_success = actions.move_and_leftclick(
                c(defines.neutral_minion))
            control_success = actions.move_and_rightclick(
                c(defines.neutral_minion))
        actions.pause_pensively(2)
    player_ability = 0
    #logging.info("---ATTACK WITH MINIONS---")
    src = vision.screen_cap()
    player_minions = vision.color_range_reduced_mids(
        src,
        c(defines.reduced_player_minions_box),
        color='green',
        min_threshold=45,
        max_threshold=200)
    while player_minions and control_success:
        p_m = False
        no_enemy_taunts_detected = True
        min_subset = [False, 99]
        src = vision.screen_cap()
        enemy_minions = vision.get_taunt_minions(
            src, c(defines.enemy_minions_box_taunts))

        if enemy_minions:
            no_enemy_taunts_detected = False
            if defines.RANDOM_ATTACKS or defines.ref_game_screen_res_list[
                    defines.GAME_SCREEN_RES] == [1400, 1050]:
                p_m = player_minions[randint(0,
                                             len(player_minions) -
                                             1)]  #attack with a random minion
                e_m = enemy_minions[randint(0,
                                            len(enemy_minions) -
                                            1)]  #attack a random taunt minion
            else:
                if control_success:
                    player_minions_data = vision.all_minion_data(
                        src,
                        defines.player_minion_data_split,
                        defines.c(defines.player_minions_box),
                        minions_box_playable=defines.c(
                            defines.reduced_player_minions_box),
                        stage=stage)
                    enemy_minions_data = vision.all_minion_data(
                        src,
                        defines.enemy_minion_data_split,
                        defines.c(defines.enemy_minions_box),
                        minions_box_taunts_reduced=c(
                            defines.reduced_enemy_minions_box),
                        minions_box_taunts=defines.c(
                            defines.enemy_minions_box_taunts),
                        stage=stage,
                        reduced_color='red')
                    #print ''
                    #for i in range(0,len(enemy_minions_data)):
                    #    print enemy_minions_data[i]
                    #print ""
                    #for i in range(0,len(player_minions_data)):
                    #    print player_minions_data[i]

                    playable_minions = []
                    for player_minion in player_minions_data:
                        if player_minion['playable'] == True:
                            playable_minions.append(player_minion)
                    if playable_minions == []:
                        break

                    taunt_minions = []
                    for enemy_minion in enemy_minions_data:
                        if enemy_minion['taunt'] == True:
                            taunt_minions.append(enemy_minion)
                    subsets = []
                    for L in range(0, len(playable_minions) + 1):
                        for subset in combinations(playable_minions, L):
                            attack_total = 0
                            for individual in subset:
                                if 'attack' in individual:
                                    if individual['attack'] != ' ':
                                        attack_total += int(
                                            individual['attack'])
                            if subset:
                                subsets.append([subset, attack_total])

                    min_subset = [False, 99]
                    #max_taunt  = 0
                    min_difference = 99
                    for taunt_minion in taunt_minions:
                        #if taunt_minion['defense']>max_taunt[0]:
                        #    max_taunt=taunt_minion['defense']

                        if 'defense' in taunt_minion:
                            if taunt_minion['defense'] == ' ':
                                taunt_minion['defense'] = '5'
                        else:
                            taunt_minion['defense'] = '5'

                        for subset in subsets:
                            difference = abs(subset[1] -
                                             int(taunt_minion['defense']))
                            if subset[1] >= taunt_minion[
                                    'defense'] and difference < min_difference and (
                                        subset[1] < min_subset[1]
                                        or len(subset) < len(min_subset)
                                    ):  #attack_total > taunt defense
                                min_subset = subset
                                min_difference = difference
                                p_m = min_subset[0][0]['coord']
                                e_m = taunt_minion['coord']

                    if p_m == False:
                        p_m = player_minions[randint(
                            0,
                            len(player_minions) -
                            1)]  #attack with a random minion
                        e_m = enemy_minions[randint(
                            0,
                            len(enemy_minions) -
                            1)]  #attack a random taunt minion
                    #print 'Use subset: ',min_subset
        else:
            no_enemy_taunts_detected = True
            if len(player_minions) > 1:
                p_m = player_minions[randrange(0, len(player_minions) - 1)]
            else:
                p_m = player_minions[0]

        control_success = actions.move_and_leftclick(p_m)
        actions.move_cursor([
            p_m[0], p_m[1] + int(150 * float(defines.game_screen_res[1]) /
                                 float(defines.ref_game_screen_res[1]))
        ])
        actions.pause_pensively(0.2)

        src = vision.screen_cap()
        enemy = []
        enemy_freeze = None
        enemy.extend(
            vision.color_range_reduced_mids(src,
                                            c(defines.reduced_opponent_box1),
                                            color='red'))
        enemy.extend(
            vision.color_range_reduced_mids(src,
                                            c(defines.reduced_opponent_box2),
                                            color='red'))
        enemy_freeze = vision.color_range_reduced_mids(
            src, c(defines.reduced_opponent_box1), color='blue')
        enemy_minions = vision.get_taunt_minions(
            src, c(defines.enemy_minions_box_taunts))
        if enemy_minions and no_enemy_taunts_detected:  #something wrong has happened, try a bunch of stuff
            control_success = actions.move_and_leftclick(
                c(defines.opponent_hero))
            actions.pause_pensively(2)
            control_success = actions.move_and_leftclick(p_m)
            actions.move_cursor([
                p_m[0], p_m[1] + int(150 * float(defines.game_screen_res[1]) /
                                     float(defines.ref_game_screen_res[1]))
            ])
            actions.pause_pensively(0.2)
            e_m = enemy_minions[randint(0,
                                        len(enemy_minions) -
                                        1)]  #attack a random taunt minion
            control_success = actions.move_and_leftclick(e_m)
            control_success = actions.move_and_rightclick(
                c(defines.neutral_minion))
            actions.pause_pensively(2.5)
        elif enemy_minions:
            control_success = actions.move_and_leftclick(e_m)
            control_success = actions.move_and_leftclick(
                c(defines.opponent_hero))
            control_success = actions.move_and_rightclick(
                c(defines.neutral_minion))
            actions.pause_pensively(2.5)
        elif enemy:
            control_success = actions.move_and_leftclick(
                c(defines.opponent_hero))
        elif enemy_freeze:
            control_success = actions.move_and_leftclick(
                c(defines.opponent_hero))
        else:
            #something's wrong, try to attack any minion
            actions.pause_pensively(6)
            enemy_minions = vision.color_range_reduced_mids(
                src, c(defines.reduced_enemy_minions_box), color='red')
            if enemy_minions:
                e_m = enemy_minions[randint(0,
                                            len(enemy_minions) -
                                            1)]  #attack a random taunt minion
                control_success = actions.move_and_leftclick(e_m)
                control_success = actions.move_and_rightclick(
                    c(defines.neutral_minion))
                actions.pause_pensively(2.5)
            else:
                actions.pause_pensively(6)
        control_success = actions.move_and_rightclick(c(
            defines.neutral_minion))
        src = vision.screen_cap()
        state_name = vision.get_state_sift(
            src,
            state_descs,
            ignore_list=[
                'versus.png', 'defeat.png', 'finding_opponent.png', 'gold.png',
                'opponent_still_choosing.png', 'starting_hand.png', 'rank.png',
                'victory.png'
            ])
        if state_name == 'play':
            break
        if not actions.check_game('Hearthstone'):
            break
        player_minions = vision.color_range_reduced_mids(
            src,
            c(defines.reduced_player_minions_box),
            color='green',
            min_threshold=45,
            max_threshold=200)

    #logging.info("------PLAY INFO CHECK-------")
    actions.pause_pensively(0.25)
    src = vision.screen_cap()
    state_name = vision.get_state_sift(src, state_descs)
    player_cards = vision.get_playable_cards(src, c(defines.hand_box))
    player_ability = vision.color_range_reduced_mids(
        src, c(defines.reduced_ability_box), color='green')

    if player_ability:  #player ability still shows up even though we've past that section above, chances are the character is wrong
        try:
            player_char = vision.get_image_info_sift(src, character_descs,
                                                     c(defines.player_box))
        except:
            player_char = None

    player_minions = vision.color_range_reduced_mids(
        src,
        c(defines.reduced_player_minions_box),
        color='green',
        min_threshold=45,
        max_threshold=200)
    player_attack = vision.color_range_reduced_mids(
        src, c(defines.reduced_player_box), color='green')
    if (
            player_cards == [] and player_ability == []
            and player_minions == [] and player_attack == []
    ) or player_cards == None or player_ability == None or player_minions == None or player_attack == None and control_success and (
            state_name == defines.State.PLAYER
            or state_name == defines.State.OPPONENT
            or state_name == defines.State.PLAYER_GREEN):
        #logging.info("---END TURN---")
        control_success = actions.move_and_leftclick(c(defines.neutral))
        player_turn_green_check = vision.color_range_reduced_mids(
            src, c(defines.turn_box), color='green')
        if player_turn_green_check != [] and player_turn_green_check != None and control_success:
            control_success = actions.move_and_leftclick(c(
                defines.turn_button))
            control_success = actions.move_and_leftclick(c(defines.neutral))
        else:
            actions.pause_pensively(5)
            player_end()