@@ -104,24 +104,33 @@ def __init__(self,replay):
104104 mapsio = StringIO (replayMap .minimap )
105105 im = PIL_open (mapsio )
106106 ##remove black box around minimap
107- cropped = im .crop (im .getbbox ())
108- cropsize = cropped .size
107+
108+ # https://github.com/jonomon/sc2reader/commit/2a793475c0358989e7fda4a75642035a810e2274
109+ # cropped = im.crop(im.getbbox())
110+ # cropsize = cropped.size
111+
112+ cropsizeX = replay .map .map_info .camera_right - replay .map .map_info .camera_left
113+ cropsizeY = replay .map .map_info .camera_top - replay .map .map_info .camera_bottom
114+ cropsize = (cropsizeX ,cropsizeY )
115+
109116 self .map_height = 100.0
110117 # resize height to MAPHEIGHT, and compute new width that
111118 # would preserve aspect ratio
112119 self .map_width = int (cropsize [0 ] * (float (self .map_height ) / cropsize [1 ]))
113120 self .mapSize = self .map_height * self .map_width
121+
114122 ## the following parameters are only needed if minimaps have to be printed
115- minimapSize = ( self .map_width ,int (self .map_height ) )
116- self .minimap_image = cropped .resize (minimapSize , ANTIALIAS )
123+ # minimapSize = ( self.map_width,int(self.map_height) )
124+ # self.minimap_image = cropped.resize(minimapSize, ANTIALIAS)
125+
117126 mapOffsetX = replayMap .map_info .camera_left
118127 mapOffsetY = replayMap .map_info .camera_bottom
119128 mapCenter = [mapOffsetX + cropsize [0 ]/ 2.0 , mapOffsetY + cropsize [1 ]/ 2.0 ]
120129 # this is the center of the minimap image, in pixel coordinates
121130 imageCenter = [(self .map_width / 2 ), self .map_height / 2 ]
122131 # this is the scaling factor to go from the SC2 coordinate
123132 # system to pixel coordinates
124- self .image_scale = float (self .map_height ) / cropsize [0 ]
133+ self .image_scale = float (self .map_height ) / cropsize [1 ]
125134 self .transX = imageCenter [0 ] + self .image_scale * (mapCenter [0 ])
126135 self .transY = imageCenter [1 ] + self .image_scale * (mapCenter [1 ])
127136
@@ -172,15 +181,15 @@ def remove_from_list(self,unit_id,time_frame):
172181 cgu_per_player = self .creep_gen_units [player_id ] [length_cgu_list - 1 ]
173182 creep_generating_died = filter (lambda x :x [0 ]== unit_id ,cgu_per_player )
174183 for creep_generating_died_unit in creep_generating_died :
175- new_cgu_per_player = filter (lambda x :x != creep_generating_died_unit , cgu_per_player )
184+ new_cgu_per_player = list ( filter (lambda x :x != creep_generating_died_unit , cgu_per_player ) )
176185 self .creep_gen_units [player_id ].append (new_cgu_per_player )
177186 self .creep_gen_units_times [player_id ].append (time_frame )
178187
179188 def cgu_gen_times_to_chunks (self ,cgu_time_list ):
180189 ## this function returns the index and value of every cgu time
181190 maximum_cgu_time = max (cgu_time_list )
182191 for i in range (0 , maximum_cgu_time ):
183- a = filter (lambda ( x , y ): int ( y / 60 ) == i , enumerate (cgu_time_list ))
192+ a = list ( filter (lambda x_y : x_y [ 1 ] // 60 == i , enumerate (cgu_time_list ) ))
184193 if len (a )> 0 :
185194 yield a
186195
@@ -202,7 +211,7 @@ def reduce_cgu_per_minute(self,player_id):
202211 #the most cgus every minute will be used to represent that minute
203212 cgu_per_minute1 , cgu_per_minute2 = tee (self .cgu_gen_times_to_chunks (self .creep_gen_units_times [player_id ]))
204213 cgu_unit_max_per_minute = self .cgu_in_min_to_cgu_units (player_id ,cgu_per_minute1 )
205- minutes = map (lambda x :int (x [0 ][1 ]/ 60 )* 60 , cgu_per_minute2 )
214+ minutes = map (lambda x :int (x [0 ][1 ]// 60 )* 60 , cgu_per_minute2 )
206215 self .creep_gen_units [player_id ] = list (cgu_unit_max_per_minute )
207216 self .creep_gen_units_times [player_id ] = list (minutes )
208217
@@ -216,7 +225,7 @@ def get_creep_spread_area(self,player_id):
216225 cgu_radius = self .convert_cgu_radius_event_to_map_coord (cgu_radius )
217226 creep_area_positions = self .cgu_radius_to_map_positions (cgu_radius ,self .radius_to_coordinates )
218227 cgu_event_time = self .creep_gen_units_times [player_id ][index ]
219- cgu_event_time_str = str (int (cgu_event_time / 60 ))+ ":" + str (cgu_event_time % 60 )
228+ cgu_event_time_str = str (int (cgu_event_time // 60 ))+ ":" + str (cgu_event_time % 60 )
220229 if self .debug :
221230 self .print_image (creep_area_positions ,player_id ,cgu_event_time_str )
222231 creep_area = len (creep_area_positions )
@@ -278,6 +287,6 @@ def convert_cgu_radius_event_to_map_coord(self,cgu_radius):
278287 return cgu_radius_new
279288
280289 def convert_event_coord_to_map_coord (self ,x ,y ):
281- imageX = int (self .map_height - self .transX + self .image_scale * x )
290+ imageX = int (self .map_width - self .transX + self .image_scale * x )
282291 imageY = int (self .transY - self .image_scale * y )
283292 return imageX , imageY
0 commit comments