Skip to content

Commit

Permalink
Add spaces for missing players in game
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldoylecs committed Sep 30, 2019
1 parent 5d5ddaa commit 06dbfe1
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int get_winning_team(const vector<Property>& properties);
string create_stat_csv(const vector<Player>& players);

int main() {
const string version = "1.2";
const string version = "1.3";
const string default_file_name = "player_stats";
const string file_extension = ".csv";
vector<Player> players;
Expand Down Expand Up @@ -69,7 +69,8 @@ int main() {
// and stores each player into a map. If the player already exists, the
// stats are added together and stored.
for (filesystem::path path : filesystem::directory_iterator(replay_dir)) {
string replay_path = path.u8string();
int const players_on_team = 6;
string const replay_path = path.u8string();
cout << "Parsing " << replay_path << "\n";

ReplayFile replay(replay_path);
Expand All @@ -82,8 +83,12 @@ int main() {
Player player(player_info);
player_stat_records.push_back(player);
}
set_mvp(player_stat_records, winning_team);

for (int i = players_on_team - player_stats.size(); i > 0; --i) {
player_stat_records.emplace_back(Player());
}

set_mvp(player_stat_records, winning_team);
players.insert(
players.begin(),
player_stat_records.begin(),
Expand Down Expand Up @@ -153,9 +158,13 @@ string create_stat_csv(const vector<Player>& players) {
csv << "Player Stats generated by RocketAnalyticsPlayerStatsParser.\n" <<
"Unique ID,Team,Name,Platform,Online ID,Games Played,MVPs,Score," <<
"Goals,Assists,Saves,Shots\n";

string const empty_row = ",,,,,,,,,,,\n";
int count = 1;
for (auto const& player : players) {
if (player.onlineID == "") {
csv << empty_row;
continue;
}
csv <<
count << ",," <<
player.name << "," <<
Expand Down

0 comments on commit 06dbfe1

Please sign in to comment.