@@ -79,7 +79,7 @@ def empty_func(self):
7979 def new_game_easy (self ):
8080 self .FIELD_WIDTH = 9
8181 self .FIELD_HEIGHT = 9
82- self .MINES_MAX = 10
82+ self .MINES_MAX = 3
8383
8484 def new_game_mid (self ):
8585 self .FIELD_WIDTH = 16
@@ -246,7 +246,7 @@ def next_mark(self, x, y):
246246 self .flagged_cells -= 1
247247
248248 def store_played_games (self ):
249- if self .MINES_MAX == 10 :
249+ if self .MINES_MAX == 3 :
250250 nome = self .controller .get_text_input ("Noobie mode" , "Insert your name" )
251251 time = self .seconds_from_start
252252 self .playersEasy .append (Player (nome , time ))
@@ -293,55 +293,42 @@ def create_file(self, model):
293293
294294class To_json (TypeFile ):
295295 def create_file (self , model ):
296- print ( "OK" )
296+ json_dict = {}
297297 if len (model .playersEasy ) != 0 :
298- easy_dict = {
299- "GameMode" : "Easy" ,
300- "NamePlayer" : "PlayTime"
301- }
298+ easy_dict = {"NamePlayer" : "PlayTime" }
302299 for player in model .playersEasy :
303300 easy_dict [player .get_nome ()] = player .get_time ()
304- json_obj = json .dumps (easy_dict , indent = 4 )
305- with open ("historico.json" , "a" ) as outfile :
306- outfile .write (json_obj )
301+ json_dict ["Easy" ] = easy_dict
302+
307303 if len (model .playersMid ) != 0 :
308- mid_dict = {
309- "GameMode" : "Mid" ,
310- "NamePlayer" : "PlayTime"
311- }
304+ mid_dict = {"NamePlayer" : "PlayTime" }
312305 for player in model .playersMid :
313306 mid_dict [player .get_nome ()] = player .get_time ()
314- json_obj = json .dumps (mid_dict , indent = 4 )
315- with open ("historico.json" , "a" ) as outfile :
316- outfile .write (json_obj )
307+ json_dict ["Mid" ] = mid_dict
308+
317309 if len (model .playersHard ) != 0 :
318- hard_dict = {
319- "GameMode" : "Hard" ,
320- "NamePlayer" : "PlayTime"
321- }
310+ hard_dict = {"NamePlayer" : "PlayTime" }
322311 for player in model .playersHard :
323312 hard_dict [player .get_nome ()] = player .get_time ()
324- json_obj = json .dumps (hard_dict , indent = 4 )
325- with open ("historico.json" , "a" ) as outfile :
326- outfile .write (json_obj )
313+ json_dict ["Hard" ] = hard_dict
314+
327315 if len (model .playersRandom ) != 0 :
328- rand_dict = {
329- "GameMode" : "Random" ,
330- "NamePlayer" : "PlayTime"
331- }
316+ rand_dict = {"NamePlayer" : "PlayTime" }
332317 for player in model .playersRandom :
333318 rand_dict [player .get_nome ()] = player .get_time ()
334- json_obj = json .dumps (rand_dict , indent = 4 )
335- with open ("historico.json" , "a" ) as outfile :
336- outfile .write (json_obj )
319+ json_dict ["Random" ] = rand_dict
320+
321+ json_obj = json .dumps (json_dict , indent = 4 )
322+ with open ("historico.json" , "a" ) as outfile :
323+ outfile .write (json_obj )
337324
338325
339326class To_csv (TypeFile ):
340327 def create_file (self , model ):
341328 pass
342329
343330
344- class To_xml (TypeFile ):
331+ class To_txt (TypeFile ):
345332 def create_file (self , model ):
346333 pass
347334
0 commit comments