# Path: tools.py
# def time_it(name, func):
#     start = time.clock()
#     result = func()
#     elapsed = time.clock() - start
#     print name + ": " + str(elapsed)
#     return result


import cPickle as pickle
import os
from genericpath import isfile
from os import getcwd, listdir
from tools import time_it

__author__ = 'co'


def load_first_game():
    save_file = open(get_save_files()[0], 'rb')
    print save_file
    game_state = time_it("load", (lambda: pickle.load(save_file)))
    save_file.close()
    return game_state


def get_save_file_name():
    save_file = "game.sav"
    return save_file


def save(game_state):
    game_state.draw_loading_screen("Saving...")
    save_file = open(get_save_file_name(), 'wb')

# Path: tools.py
# def time_it(name, func):
#     start = time.clock()
#     result = func()
#     elapsed = time.clock() - start
#     print name + ": " + str(elapsed)
#     return result


# Path: save.py
import cPickle as pickle
import os
from genericpath import isfile
from os import getcwd, listdir
from tools import time_it


__author__ = 'co'


def load_first_game():
    save_file = open(get_save_files()[0], 'rb')
    print save_file
    game_state = time_it("load", (lambda: pickle.load(save_file)))
    save_file.close()
    return game_state


def get_save_file_name():
    save_file = "game.sav"
    return save_file


def save(game_state):
    game_state.draw_loading_screen("Saving...")
    save_file = open(get_save_file_name(), 'wb')

    time_it("save", lambda: pickle.dump(game_state, save_file, -1))