예제 #1
0
    def test_system_consistency(self):
        """
        Switching places should leave system in consistent state
        """
        pyherc.vtable['\ufdd0:move'](self.monster_1, Direction.east)

        assert_that(get_character(self.level, (6, 5)), is_(equal_to(self.monster_1)))
        assert_that(get_character(self.level, (5, 5)), is_(equal_to(self.monster_2)))
예제 #2
0
    def test_system_consistency(self):
        """
        Switching places should leave system in consistent state
        """
        pyherc.vtable['\ufdd0:move'](self.monster_1, Direction.east)

        assert_that(get_character(self.level, (6, 5)),
                    is_(equal_to(self.monster_1)))
        assert_that(get_character(self.level, (5, 5)),
                    is_(equal_to(self.monster_2)))
예제 #3
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
예제 #4
0
 def move_or_attack(self, character, direction):
     """
     Move or attack
     """
     level = character.level
     if pyherc.vtable['\ufdd0:is-move-legal'](character, direction):
         pyherc.vtable['\ufdd0:move'](character, direction)
     elif direction != 9:
         loc = character.get_location_at_direction(direction)
         if get_character(level, loc) is not None:
             pyherc.vtable['\ufdd0:attack'](character, direction)
예제 #5
0
파일: moving.py 프로젝트: tuturto/pyherc
 def move_or_attack(self, character, direction):
     """
     Move or attack
     """
     level = character.level
     if pyherc.vtable['\ufdd0:is-move-legal'](character,
                                       direction):
         pyherc.vtable['\ufdd0:move'](character, direction)
     elif direction != 9:
         loc = character.get_location_at_direction(direction)
         if get_character(level, loc) is not None:
             pyherc.vtable['\ufdd0:attack'](character,
                                            direction)
예제 #6
0
파일: spells.py 프로젝트: tuturto/pyherc
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