Beispiel #1
0
def targeting_spherical_area(parameters, radius):
    """
    Function to target a spherical area

    .. versionadded:: 0.10
    """
    targets = []
    initial = get_target_in_direction(level=parameters.caster.level,
                                      location=parameters.caster.location,
                                      direction=parameters.direction)

    if initial and initial.previous_target:
        splash_center = initial.previous_target.location
        level = parameters.caster.level

        matrix = get_fov_matrix(splash_center, level, radius)

        x_range = range(splash_center[0] - radius,
                        splash_center[0] + radius + 1)

        y_range = range(splash_center[1] - radius,
                        splash_center[1] + radius + 1)

        for location, is_visible in matrix.items():
            if is_visible:
                creature = get_character(level, location)
                if creature:
                    targets.append(
                        TargetData('character', location, creature, None))
                elif blocks_los(level, location):
                    targets.append(TargetData('wall', location, None, None))
                else:
                    targets.append(TargetData('void', location, None, None))

    return targets
Beispiel #2
0
def targeting_single_target(parameters):
    """
    Function to target a single character in direction

    .. versionadded:: 0.9
    """
    target = get_target_in_direction(level=parameters.caster.level,
                                     location=parameters.caster.location,
                                     direction=parameters.direction)
    if target:
        return [target]
    else:
        return []
Beispiel #3
0
def targeting_single_target(parameters):
    """
    Function to target a single character in direction

    .. versionadded:: 0.9
    """
    target = get_target_in_direction(level=parameters.caster.level,
                                     location=parameters.caster.location,
                                     direction=parameters.direction)
    if target:
        return [target]
    else:
        return []
Beispiel #4
0
def targeting_spherical_area(parameters, radius):
    """
    Function to target a spherical area

    .. versionadded:: 0.10
    """
    targets = []
    initial = get_target_in_direction(level=parameters.caster.level,
                                      location=parameters.caster.location,
                                      direction=parameters.direction)

    if initial and initial.previous_target:
        splash_center = initial.previous_target.location
        level = parameters.caster.level

        matrix = get_fov_matrix(splash_center,
                                level,
                                radius)

        x_range = range(splash_center[0] - radius,
                        splash_center[0] + radius + 1)

        y_range = range(splash_center[1] - radius,
                        splash_center[1] + radius + 1)

        for location, is_visible in matrix.items():
            if is_visible:
                creature = get_character(level, location)
                if creature:
                    targets.append(TargetData('character',
                                              location,
                                              creature,
                                              None))
                elif blocks_los(level, location):
                    targets.append(TargetData('wall',
                                              location,
                                              None,
                                              None))
                else:
                    targets.append(TargetData('void',
                                              location,
                                              None,
                                              None))

    return targets