/** * This function is used when we want to create a new file * with a board and a player object * * b1 - the board we want to write to the newly created file * puzzle_number - used to generate a valid file name(holds the number of puzzle) * player - The player object we want to write to that file */ void Files::create_new_puzzle_file(vector<vector<Piece> > &b1, int puzzle_number, Player &player) { int board_width = b1.size(); string size; //It holds the size of the puzzle size = str_utils.format_puzzle_number(puzzle_number); //This variable holds the correct file name we will create string file_name = FILE_BASE + to_string(board_width) + "x" + to_string(board_width) + "_" + size + ".txt"; //File alredy exists if(file_exists(file_name.c_str())) { //Display an error message to the user cout << "[!!] O ficheiro " << "\"" << file_name << "\" ja existe!" << endl << endl; } else { //If the file doesn't exist, then we create a new file //and the vector of vectors of Piece b1 and the player object are written to that file create_file(file_name.c_str()); //Write the puzzle write_puzzle_data(file_name.c_str(), b1); //Write the player object write_player_data(file_name.c_str(), player); } }
bool_t add_duplicate_player_data(team_data_t *src_team, team_data_t *dst_team, number_1_t new_team_index, player_db_data_t *db_data) { /* Update players of teams whose team index has increased */ update_team_indexes(new_team_index, &db_data->key_data); /* Players */ if (!add_duplicate_players(src_team, dst_team, new_team_index, db_data, dst_team->players, ELEM_COUNT(dst_team->players), sizeof(player_atts_t), sizeof(player_stats_season_t), sizeof(player_stats_career_t))) return FALSE; /* Goalies */ if (!add_duplicate_players(src_team, dst_team, new_team_index, db_data, dst_team->goalies, ELEM_COUNT(dst_team->goalies), sizeof(goalie_atts_t), sizeof(goalie_stats_season_t), sizeof(goalie_stats_career_t))) return FALSE; return write_player_data(db_data); }