Commit 4c7aec6a authored by Ahmad Reza's avatar Ahmad Reza
Browse files

the method check_coords is renamed to check_values_are_coordinates

parent b1014a79
...@@ -91,7 +91,7 @@ class Particle(matter.Matter): ...@@ -91,7 +91,7 @@ class Particle(matter.Matter):
""" """
direction_coord = get_coords_in_direction(self.coords, direction) direction_coord = get_coords_in_direction(self.coords, direction)
direction, direction_coord = self.check_within_border(direction, direction_coord) direction, direction_coord = self.check_within_border(direction, direction_coord)
if check_coords(direction_coord[0], direction_coord[1]): if check_values_are_coordinates(direction_coord[0], direction_coord[1]):
if self.coords in self.world.particle_map_coords: if self.coords in self.world.particle_map_coords:
del self.world.particle_map_coords[self.coords] del self.world.particle_map_coords[self.coords]
...@@ -520,7 +520,7 @@ class Particle(matter.Matter): ...@@ -520,7 +520,7 @@ class Particle(matter.Matter):
logging.info("particle with id %s is", self.get_id()) logging.info("particle with id %s is", self.get_id())
if x is not None and y is not None: if x is not None and y is not None:
coords = (x, y) coords = (x, y)
if check_coords(x,y): if check_values_are_coordinates(x,y):
logging.info("Going to create a tile on position \(%i , %i\)", x,y ) logging.info("Going to create a tile on position \(%i , %i\)", x,y )
if self.world.add_tile(coords[0], coords[1], color, alpha) == True: if self.world.add_tile(coords[0], coords[1], color, alpha) == True:
self.world.tile_map_coords[coords[0], coords[1]].created = True self.world.tile_map_coords[coords[0], coords[1]].created = True
...@@ -701,7 +701,7 @@ class Particle(matter.Matter): ...@@ -701,7 +701,7 @@ class Particle(matter.Matter):
:return: True: successful taken; False: unsuccessful taken :return: True: successful taken; False: unsuccessful taken
""" """
if self.carried_particle is None and self.carried_tile is None: if self.carried_particle is None and self.carried_tile is None:
if check_coords(x, y): if check_values_are_coordinates(x, y):
coords = (x, y) coords = (x, y)
if coords in self.world.tile_map_coords: if coords in self.world.tile_map_coords:
self.carried_tile = self.world.tile_map_coords[coords] self.carried_tile = self.world.tile_map_coords[coords]
...@@ -781,7 +781,7 @@ class Particle(matter.Matter): ...@@ -781,7 +781,7 @@ class Particle(matter.Matter):
:param y: y coordinate :param y: y coordinate
""" """
if self.carried_tile is not None: if self.carried_tile is not None:
if check_coords(x, y): if check_values_are_coordinates(x, y):
coords = (x, y) coords = (x, y)
if coords not in self.world.get_tile_map_coords(): if coords not in self.world.get_tile_map_coords():
try: # cher: insert so to overcome the AttributeError try: # cher: insert so to overcome the AttributeError
...@@ -859,7 +859,7 @@ class Particle(matter.Matter): ...@@ -859,7 +859,7 @@ class Particle(matter.Matter):
""" """
coords = (0, 0) coords = (0, 0)
if x is not None and y is not None: if x is not None and y is not None:
if check_coords(x, y): if check_values_are_coordinates(x, y):
coords = (x, y) coords = (x, y)
logging.info("Going to create a particle on position %s", str(coords)) logging.info("Going to create a particle on position %s", str(coords))
new_particle = self.world.add_particle(coords[0], coords[1], color, alpha) new_particle = self.world.add_particle(coords[0], coords[1], color, alpha)
...@@ -934,7 +934,7 @@ class Particle(matter.Matter): ...@@ -934,7 +934,7 @@ class Particle(matter.Matter):
:return: True: Deleting successful; False: Deleting unsuccessful :return: True: Deleting successful; False: Deleting unsuccessful
""" """
if x is not None and y is not None: if x is not None and y is not None:
if check_coords(x, y): if check_values_are_coordinates(x, y):
coords = (x, y) coords = (x, y)
if self.world.remove_particle_on(coords): if self.world.remove_particle_on(coords):
logging.info("Deleted particle with particle on coords %s", str(coords)) logging.info("Deleted particle with particle on coords %s", str(coords))
...@@ -1035,7 +1035,7 @@ class Particle(matter.Matter): ...@@ -1035,7 +1035,7 @@ class Particle(matter.Matter):
:return: True: Successful taken; False: Cannot be taken or wrong Coordinates :return: True: Successful taken; False: Cannot be taken or wrong Coordinates
""" """
if self.carried_particle is None and self.carried_tile is None: if self.carried_particle is None and self.carried_tile is None:
if check_coords(x, y): if check_values_are_coordinates(x, y):
coords = (x, y) coords = (x, y)
if coords in self.world.particle_map_coords: if coords in self.world.particle_map_coords:
self.carried_particle = self.world.particle_map_coords[coords] self.carried_particle = self.world.particle_map_coords[coords]
...@@ -1113,7 +1113,7 @@ class Particle(matter.Matter): ...@@ -1113,7 +1113,7 @@ class Particle(matter.Matter):
:param x: x coordinate :param x: x coordinate
:param y: y coordinate :param y: y coordinate
""" """
if self.carried_particle is not None and x is not None and y is not None and check_coords(x, y): if self.carried_particle is not None and x is not None and y is not None and check_values_are_coordinates(x, y):
coords = (x, y) coords = (x, y)
if coords not in self.world.particle_map_coords: if coords not in self.world.particle_map_coords:
try: # cher: insert so to overcome the AttributeError try: # cher: insert so to overcome the AttributeError
...@@ -1196,7 +1196,7 @@ class Particle(matter.Matter): ...@@ -1196,7 +1196,7 @@ class Particle(matter.Matter):
""" """
coords = (0, 0) coords = (0, 0)
if x is not None and y is not None: if x is not None and y is not None:
if check_coords(x, y): if check_values_are_coordinates(x, y):
coords = (x, y) coords = (x, y)
logging.info("Going to create a marker on position %s", str(coords)) logging.info("Going to create a marker on position %s", str(coords))
new_marker = self.world.add_marker(coords[0], coords[1], color, alpha) new_marker = self.world.add_marker(coords[0], coords[1], color, alpha)
...@@ -1271,7 +1271,7 @@ class Particle(matter.Matter): ...@@ -1271,7 +1271,7 @@ class Particle(matter.Matter):
:return: True: Deleting successful; False: Deleting unsuccessful :return: True: Deleting successful; False: Deleting unsuccessful
""" """
if x is not None and y is not None: if x is not None and y is not None:
if check_coords(x, y): if check_values_are_coordinates(x, y):
coords = (x, y) coords = (x, y)
if self.world.remove_marker_on(coords): if self.world.remove_marker_on(coords):
logging.info("Deleted marker oords %s", str(coords)) logging.info("Deleted marker oords %s", str(coords))
......
...@@ -85,7 +85,7 @@ def direction_in_range(direction): ...@@ -85,7 +85,7 @@ def direction_in_range(direction):
return direction % 6 return direction % 6
def check_coords(coords_x, coords_y): def check_values_are_coordinates(coords_x, coords_y):
""" """
Checks if the given coordinates are matching the Checks if the given coordinates are matching the
hexagon coordinates hexagon coordinates
......
...@@ -273,7 +273,7 @@ class World: ...@@ -273,7 +273,7 @@ class World:
if alpha < 0 or alpha >1: if alpha < 0 or alpha >1:
alpha = 1 alpha = 1
if len(self.particles) < self.config_data.max_particles: if len(self.particles) < self.config_data.max_particles:
if check_coords(x,y) == True: if check_values_are_coordinates(x,y) == True:
if (x,y) not in self.get_particle_map_coords(): if (x,y) not in self.get_particle_map_coords():
self.particle_id_counter += 1 self.particle_id_counter += 1
new_particle = particle.Particle(self, x, y, color, alpha, self.particle_id_counter) new_particle = particle.Particle(self, x, y, color, alpha, self.particle_id_counter)
...@@ -357,7 +357,7 @@ class World: ...@@ -357,7 +357,7 @@ class World:
""" """
if alpha < 0 or alpha >1: if alpha < 0 or alpha >1:
alpha = 1 alpha = 1
if check_coords(x,y) == True: if check_values_are_coordinates(x,y) == True:
if (x,y) not in self.tile_map_coords: if (x,y) not in self.tile_map_coords:
self.new_tile=tile.Tile(self, x, y, color, alpha) self.new_tile=tile.Tile(self, x, y, color, alpha)
print("Before adding ", len(self.tiles) ) print("Before adding ", len(self.tiles) )
...@@ -386,7 +386,7 @@ class World: ...@@ -386,7 +386,7 @@ class World:
:param y: the y coordinates on which the tile should be added :param y: the y coordinates on which the tile should be added
:return: True: Successful added; False: Unsuccsessful :return: True: Successful added; False: Unsuccsessful
""" """
if check_coords(x, y) == True: if check_values_are_coordinates(x, y) == True:
if (x, y) not in self.tile_map_coords: if (x, y) not in self.tile_map_coords:
self.new_tile = tile.Tile(self, x, y, color, alpha) self.new_tile = tile.Tile(self, x, y, color, alpha)
self.tiles.append(self.new_tile) self.tiles.append(self.new_tile)
...@@ -466,7 +466,7 @@ class World: ...@@ -466,7 +466,7 @@ class World:
""" """
if alpha < 0 or alpha >1: if alpha < 0 or alpha >1:
alpha = 1 alpha = 1
if check_coords(x, y) == True: if check_values_are_coordinates(x, y) == True:
if (x, y) not in self.marker_map_coords: if (x, y) not in self.marker_map_coords:
self.new_marker = marker.Marker(self, x, y, color, alpha) self.new_marker = marker.Marker(self, x, y, color, alpha)
self.markers.append(self.new_marker) self.markers.append(self.new_marker)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment