From d918b4815941beb84b34c985b5e99dcc8499d239 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 30 Apr 2019 20:29:21 +0200 Subject: [PATCH] Minor refactorings / re-namings. --- new/plomrogue/mapping.py | 7 ++++--- new/plomrogue/things.py | 14 ++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/new/plomrogue/mapping.py b/new/plomrogue/mapping.py index bec311b..9826e68 100644 --- a/new/plomrogue/mapping.py +++ b/new/plomrogue/mapping.py @@ -90,7 +90,7 @@ class MapGeometry(): pos_x = pos[1].x + (maps_size.x * pos[0].x) - offset.x return YX(pos_y, pos_x) - def absolutize_coordinate(self, map_size, big_yx, little_yx): + def correct_double_coordinate(self, map_size, big_yx, little_yx): def adapt_axis(axis): maps_crossed = little_yx[axis] // map_size[axis] @@ -105,8 +105,9 @@ class MapGeometry(): def move(self, start_pos, direction, map_size): mover = getattr(self, 'move_' + direction) big_yx, little_yx = start_pos - unadapted_target = mover(little_yx) - return self.absolutize_coordinate(map_size, big_yx, unadapted_target) + uncorrected_target = mover(little_yx) + return self.correct_double_coordinate(map_size, big_yx, + uncorrected_target) diff --git a/new/plomrogue/things.py b/new/plomrogue/things.py index 2e97541..5d1c7bc 100644 --- a/new/plomrogue/things.py +++ b/new/plomrogue/things.py @@ -254,11 +254,10 @@ class ThingAnimate(Thing): def get_surroundings_offset(self): if self._surroundings_offset is not None: return self._surroundings_offset - offset = YX(self.position[0].y * self.game.map_size.y + - self.position[1].y - self._radius, - self.position[0].x * self.game.map_size.x + - self.position[1].x - self._radius) - self._surroundings_offset = offset + y_long = self.position[0].y * self.game.map_size.y + self.position[1].y + x_long = self.position[0].x * self.game.map_size.x + self.position[1].x + yx_to_origin = YX(y_long, x_long) + self._surroundings_offset = yx_to_origin - YX(self._radius, self._radius) return self._surroundings_offset def get_surrounding_map(self): @@ -267,9 +266,8 @@ class ThingAnimate(Thing): self._surrounding_map = Map(size=YX(self._radius*2+1, self._radius*2+1)) offset = self.get_surroundings_offset() for pos in self._surrounding_map: - offset_pos = pos + offset - absolutize = self.game.map_geometry.absolutize_coordinate - big_yx, small_yx = absolutize(self.game.map_size, (0,0), offset_pos) + correct = self.game.map_geometry.correct_double_coordinate + big_yx, small_yx = correct(self.game.map_size, (0,0), pos + offset) map_ = self.game.get_map(big_yx, False) if map_ is None: map_ = Map(size=self.game.map_size) -- 2.30.2