Esempio n. 1
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
Esempio n. 2
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
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'
Esempio n. 4
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