-class MapHex(game_common.Map):
-
- def list_terrain_to_lines(self, terrain_as_list, center, size):
- new_terrain_list = [' ']
- x = 0
- y = 0
- for c in terrain_as_list:
- new_terrain_list += [c, ' ']
- x += 1
- if x == self.size[1]:
- new_terrain_list += ['\n']
- x = 0
- y += 1
- if y % 2 == 0:
- new_terrain_list += [' ']
- map_lines = ''.join(new_terrain_list).split('\n')
- if len(map_lines) > size[0] and center[0] > size[0] / 2:
- diff = len(map_lines) - size[0]
- if center[0] > len(map_lines) - size[0] / 2:
- map_lines = map_lines[diff:]
- else:
- start = center[0] - int(size[0] / 2)
- map_lines = map_lines[start:start + size[0]]
- if self.size[1]*2 > size[1] and center[1]*4 > size[1]:
- if center[1]*2 > self.size[1]*2 - size[1] / 2:
- cut_start = self.size[1] * 2 - size[1]
- cut_end = None
- else:
- cut_start = center[1]*2 - int(size[1] / 2)
- cut_end = cut_start + size[1]
- map_lines = [line[cut_start:cut_end] for line in map_lines]
+class MapHex(Map):
+
+ def format_to_view(self, map_string, center, size):
+
+ def map_string_to_lines(map_string):
+ map_view_chars = [' ']
+ x = 0
+ y = 0
+ for c in map_string:
+ map_view_chars += [c, ' ']
+ x += 1
+ if x == self.size[1]:
+ map_view_chars += ['\n']
+ x = 0
+ y += 1
+ if y % 2 == 0:
+ map_view_chars += [' ']
+ return ''.join(map_view_chars).split('\n')
+
+ map_lines = map_string_to_lines(map_string)
+ self.y_cut(map_lines, center[0], size[0])
+ self.x_cut(map_lines, center[1] * 2, size[1])