def end(username, answers_list, game_dict, game_type): """ takes care of the game end logic: adds the game to the DB :param username: :param answers_list: :param game_dict: :param game_type: :return: """ if DebuggingConventions.DEBUGGING_GAME_END: print( "Game ended with the following stats:\n\tusername: {}\n\tanswers_list{}\n\tgame_type: {}" .format(username, answers_list, game_type)) final_score = calculate_final_score( answers_list, game_dict, Conventions.GAME_TYPES_CODE_FROM_VIEW_TO_STRING[game_type]) if not DebuggingConventions.TESTING_VIEW: # get user ID user_id = load_user_id_only_by_name(username) # save the game Queries.add_game( Conventions.GAME_TYPES_CODE_FROM_VIEW_TO_STRING[game_type], final_score, user_id) # return final score return final_score else: return Conventions.MOCK_GAME_SCORE
def end(username, answers_list, game_dict, game_type): if DEBUGGING_GAME_END: print( "Game ended with the following stats:\n\tusername: {}\n\tanswers_list{}\n\tgame_type: {}" .format(username, answers_list, game_type)) final_score = calculate_final_score( answers_list, game_dict, GAME_TYPES_CODE_FROM_VIEW_TO_STRING[game_type]) if not TESTING_VIEW: # get user ID user_id = load_user_id_only_by_name(username) # save the game Queries.add_game(GAME_TYPES_CODE_FROM_VIEW_TO_STRING[game_type], final_score, user_id) # return final score return final_score else: return MOCK_GAME_SCORE