Exemple #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
Exemple #2
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