def determine_pose(player, subformation):
    if player.tag in ['L1', 'L2', 'L3', 'L4', 'C', 'D1', 'D2', 'D3', 'D4']:
        return 'linemanStance'

    if player.tag in ['D5', 'D6', 'D7', 'D8', 'D9', 'D10', 'D11']:
        return 'rbStance'

    if player.tag == 'S1':
        return 'qbStance' if player.y == 2 else 'qbStanceGun'

    subformation_players = list(subformation.players.values())
    backfield_players = su.get_backfield_ordered(subformation_players)
    detached_players = su.get_detached_skill_ordered(subformation_players)

    if player in backfield_players:
        return 'rbStance'
    if player in detached_players:
        return 'wrStance'

    stance_threshold = 5
    if player.y == 1 and player.x <= su.get_rt(
            subformation_players).x + stance_threshold:
        return 'linemanStance'
    if player.y == 1 and player.x >= su.get_lt(
            subformation_players).x - stance_threshold:
        return 'linemanStance'
    return 'rbStance'
Beispiel #2
0
def is_there_te(subformation, side_type, flip):
    side = su.get_side(side_type, list(subformation.players.values()),
                       subformation.hash_mark)
    if flip == 'True':
        side = 'RT' if side == 'LT' else 'LT'
    first_attached = su.get_first_attached(list(subformation.players.values()),
                                           side)
    return first_attached != None and first_attached.y == 1
Beispiel #3
0
def apex(subformation, defense, arguments, optional_arguments):
    side_type = arguments[0]
    apex_type = arguments[1]
    y = int(arguments[2])
    flip = True if arguments[3] == 'True' else False

    players_list = list(subformation.players.values())

    align_side = sutils.get_side(side_type, players_list,
                                 subformation.hash_mark)
    if flip:
        align_side = 'RT' if align_side == 'LT' else 'LT'
    receivers_inside_out = sutils.get_receivers_inside_out(players_list, 'LT') if align_side == 'LT' \
        else sutils.get_receivers_inside_out(players_list, 'RT')
    receivers_outside_in = sutils.get_receivers_outside_in(players_list, 'LT') if align_side == 'LT' \
        else sutils.get_receivers_outside_in(players_list, 'RT')

    if apex_type == 'T_1st':
        if len(receivers_inside_out) >= 1:
            x = (receivers_inside_out[0].x + sutils.get_lt(players_list).x) // 2 if align_side == 'LT' \
                else (receivers_inside_out[0].x + sutils.get_rt(players_list).x) // 2
        else:
            x, y = INVALID_POSITION
    elif apex_type == '3_2':
        if len(receivers_outside_in) >= 3:
            x = (receivers_outside_in[2].x + receivers_outside_in[1].x) // 2
        else:
            x, y = INVALID_POSITION
    else:  # apex_type == '2_1:
        if len(receivers_outside_in) >= 2:
            x = (receivers_outside_in[1].x + receivers_outside_in[0].x) // 2
        else:
            x, y = INVALID_POSITION

    return x, y
Beispiel #4
0
def over_unbalanced_player(subformation, defense, arguments,
                           optional_arguments):
    y = int(arguments[0])
    offset = int(arguments[1])

    players_list = list(subformation.players.values())

    unbalanced_player = sutils.get_unbalanced_player(players_list)
    if not unbalanced_player:
        return INVALID_POSITION

    unbalanced_player_side = sutils.get_unbalanced_side(players_list)
    if unbalanced_player_side == 'LT':
        x = unbalanced_player.x - offset
    else:
        x = unbalanced_player.x + offset

    return x, y
Beispiel #5
0
def first_open_gap(subformation, defense, arguments, optional_arguments):
    side_type = arguments[0]
    y = int(arguments[1])
    flip = True if arguments[2] == 'True' else False

    players_list = list(subformation.players.values())

    align_side = sutils.get_side(side_type, players_list,
                                 subformation.hash_mark)
    if flip:
        align_side = 'RT' if align_side == 'LT' else 'LT'

    inside_lineman_x = sutils.get_center(players_list).x
    if align_side == 'RT':
        outside_lineman_x = sutils.get_rg(players_list).x
        if not is_a_defender_between(defense, inside_lineman_x,
                                     outside_lineman_x, 5):
            return (inside_lineman_x + outside_lineman_x) // 2, y

        inside_lineman_x = outside_lineman_x
        outside_lineman_x = sutils.get_rt(players_list).x
        if not is_a_defender_between(defense, inside_lineman_x,
                                     outside_lineman_x, 5):
            return (inside_lineman_x + outside_lineman_x) // 2, y

        return outside_lineman_x + 2, y

    outside_lineman_x = sutils.get_lg(players_list).x
    if not is_a_defender_between(defense, outside_lineman_x, inside_lineman_x,
                                 5):
        return (inside_lineman_x + outside_lineman_x) // 2, y

    inside_lineman_x = outside_lineman_x
    outside_lineman_x = sutils.get_lt(players_list).x
    if not is_a_defender_between(defense, outside_lineman_x, inside_lineman_x,
                                 5):
        return (inside_lineman_x + outside_lineman_x) // 2, y

    return outside_lineman_x - 2, y
Beispiel #6
0
def over(subformation, defense, arguments, optional_arguments):
    side_type = arguments[0]
    over = arguments[1]
    y = int(arguments[2])
    offset = int(arguments[3])
    flip = True if arguments[4] == 'True' else False

    players_list = list(subformation.players.values())

    align_side = sutils.get_side(side_type, players_list,
                                 subformation.hash_mark)
    if flip:
        align_side = 'RT' if align_side == 'LT' else 'LT'

    player_direction_outside_accross = 'right_to_left' if align_side == 'RT' else 'left_to_right'
    receivers_outside_across = sutils.get_skill_ordered(
        players_list, player_direction_outside_accross)

    offset = offset if align_side == 'RT' else -offset

    player_defender_is_over = None
    if over == '#1':
        player_defender_is_over = receivers_outside_across[0]
    elif over == '#2':
        player_defender_is_over = receivers_outside_across[1]
    elif over == '#3':
        player_defender_is_over = receivers_outside_across[2]
    elif over == '#4':
        player_defender_is_over = receivers_outside_across[3]
    elif over == 'last_attached':
        player_defender_is_over = sutils.get_outside_most_attached_or_tackle(
            players_list, align_side)
    elif over == 'first_attached':
        player_defender_is_over = sutils.get_first_attached(
            players_list, align_side)
    elif over == 'los_between_2_1':
        player_defender_is_over = receivers_outside_across[
            1] if receivers_outside_across[
                1].y == 1 else receivers_outside_across[0]
    elif over == 'non_los_between_2_1':
        player_defender_is_over = receivers_outside_across[
            1] if receivers_outside_across[
                1].y != 1 else receivers_outside_across[0]
    elif over == 'los_between_3_2':
        player_defender_is_over = receivers_outside_across[
            2] if receivers_outside_across[
                2].y == 1 else receivers_outside_across[1]
    elif over == 'non_los_between_3_2':
        player_defender_is_over = receivers_outside_across[
            2] if receivers_outside_across[
                2].y != 1 else receivers_outside_across[1]

    x = player_defender_is_over.x + offset

    if 'back_off_if_occupied' in optional_arguments:
        min_x, max_x = (
            player_defender_is_over.x - 5, player_defender_is_over.x +
            1) if align_side == 'LT' else (player_defender_is_over.x - 1,
                                           player_defender_is_over.x + 5)
        if is_a_defender_between(defense, min_x, max_x, 3):
            y = 5

    if 'back_off_further_if_occupied' in optional_arguments:
        min_x, max_x = (
            player_defender_is_over.x - 5, player_defender_is_over.x +
            1) if align_side == 'LT' else (player_defender_is_over.x - 1,
                                           player_defender_is_over.x + 5)
        if is_a_defender_between(defense, min_x, max_x, 3):
            y = 7

    if 'back_off_wing' in optional_arguments and y < 2 and player_defender_is_over.y > 1:
        y = 2

    return x, y
Beispiel #7
0
def tech_alignment(subformation, defense, arguments, optional_arguments):
    side_type = arguments[0]
    alignment = arguments[1]
    y = int(arguments[2])
    flip = True if arguments[3] == 'True' else False

    players_list = list(subformation.players.values())

    align_side = sutils.get_side(side_type, players_list,
                                 subformation.hash_mark)
    if flip:
        align_side = 'RT' if align_side == 'LT' else 'LT'

    offset = -1 if 'i' in alignment else 1
    offset = offset if align_side == 'RT' else offset * -1
    if alignment in ['0', '2', '4', '6', '8']:
        offset = 0
    # Get alignment player
    if alignment in ['0', '1']:
        align_player = sutils.get_center(players_list)
    elif alignment in ['2i', '2', '3']:
        align_player = sutils.get_lg(
            players_list) if align_side == 'LT' else sutils.get_rg(
                players_list)
    elif alignment in ['4i', '4', '5']:
        align_player = sutils.get_lt(
            players_list) if align_side == 'LT' else sutils.get_rt(
                players_list)
    elif alignment in ['6i', '6', '7']:
        align_player = sutils.get_first_attached(players_list, 'LT')\
            if align_side == 'LT' else sutils.get_first_attached(players_list, 'RT')
        ghost_distance_multiplier = 1
    elif alignment in ['8i', '8', '9']:
        align_player = sutils.get_second_attached(players_list, 'LT') \
            if align_side == 'LT' else sutils.get_second_attached(players_list, 'RT')
        ghost_distance_multiplier = 2

    if align_player:
        x = align_player.x + offset
    else:
        x = sutils.get_rt(players_list).x + GHOST_DISTANCE * ghost_distance_multiplier \
            if align_side == 'RT' else \
            sutils.get_lt(players_list).x - GHOST_DISTANCE * ghost_distance_multiplier

    if 'slide_in_if_covered' in optional_arguments:
        min_x, max_x = (x - 5, x + 1) if align_side == 'LT' else (x - 1, x + 5)
        if is_a_defender_between(defense, min_x, max_x, 1):
            x = x + 3 if align_side == 'LT' else x - 3

    return x, y
Beispiel #8
0
def num_receivers(subformation, side_type, flip):
    side = su.get_side(side_type, list(subformation.players.values()),
                       subformation.hash_mark)
    if flip == 'True':
        side = 'RT' if side == 'LT' else 'LT'
    return su.get_num_receivers(list(subformation.players.values()), side)
Beispiel #9
0
def surface(subformation, side_type, flip):
    side = su.get_side(side_type, list(subformation.players.values()),
                       subformation.hash_mark)
    if flip == 'True':
        side = 'RT' if side == 'LT' else 'LT'
    return su.get_surface_structure(list(subformation.players.values()), side)
Beispiel #10
0
def formation_structure(subformation):
    return su.get_formation_structure(list(subformation.players.values()))
Beispiel #11
0
def num_backs(subformation):
    return len(su.get_backfield_ordered(list(
        subformation.players.values()))) - 1