| Total Complexity | 4 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from intelligine.synergy.event.move.direction import get_position_with_direction_decal |
||
| 6 | class HostFeeler: |
||
| 7 | |||
| 8 | def __init__(self, context, object_id): |
||
| 9 | self._context = context |
||
| 10 | self._object_id = object_id |
||
| 11 | self._current_position = context.metas.value.get(POSITION, self._object_id) |
||
| 12 | |||
| 13 | def direction_is_free(self, direction_of_home): |
||
| 14 | position_will_be = get_position_with_direction_decal(direction_of_home, self._current_position) |
||
| 15 | return self._context.position_is_penetrable(position_will_be) |
||
| 16 | |||
| 17 | def position_is_free(self, position): |
||
| 18 | threed_position = (0, position[0], position[1]) |
||
| 19 | points_distance = distance_from_points(threed_position, self._current_position) |
||
| 20 | if points_distance > 1: |
||
| 21 | raise Exception("Can't feel so far (%s to %s: %s)" % (str(self._current_position), |
||
| 22 | str(position), |
||
| 23 | str(points_distance))) |
||
| 24 | return self._context.position_is_penetrable(threed_position) |
||
| 25 |