Skip to content

Commit 8f22a35

Browse files
committed
Fix player summary counting rounds played wrong
1 parent 07e12d4 commit 8f22a35

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Server/Api/DataController.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ [FromQuery] string guid
5252

5353
var charactersPlayed = new List<CharacterData>();
5454
var totalPlaytime = TimeSpan.Zero;
55-
var totalRoundsPlayed = 0;
56-
var totalAntagRoundsPlayed = 0;
55+
var totalRoundsPlayed = new List<int>();
56+
var totalAntagRoundsPlayed = new List<int>();
5757
var lastSeen = DateTime.MinValue;
5858
var jobCount = new List<JobCountData>();
5959

@@ -142,9 +142,19 @@ [FromQuery] string guid
142142
{
143143
Log.Warning("Unable to parse duration {Duration} for replay with ID {ReplayId}", replay.Duration, replay.Id);
144144
}
145+
146+
if (!totalRoundsPlayed.Contains(replay.Id))
147+
{
148+
totalRoundsPlayed.Add(replay.Id);
149+
}
145150

146-
totalRoundsPlayed++;
147-
totalAntagRoundsPlayed += replay.RoundEndPlayers.Any(p => p.PlayerGuid == playerGuid && p.Antag) ? 1 : 0; // If the player is an antag, increment the count.
151+
if (replay.RoundEndPlayers.Any(p => p.PlayerGuid == playerGuid && p.Antag))
152+
{
153+
if (!totalAntagRoundsPlayed.Contains(replay.Id))
154+
{
155+
totalAntagRoundsPlayed.Add(replay.Id);
156+
}
157+
}
148158
}
149159

150160
CollectedPlayerData collectedPlayerData = new()
@@ -157,8 +167,8 @@ [FromQuery] string guid
157167
},
158168
Characters = charactersPlayed,
159169
TotalEstimatedPlaytime = totalPlaytime,
160-
TotalRoundsPlayed = totalRoundsPlayed,
161-
TotalAntagRoundsPlayed = totalAntagRoundsPlayed,
170+
TotalRoundsPlayed = totalRoundsPlayed.Count,
171+
TotalAntagRoundsPlayed = totalAntagRoundsPlayed.Count,
162172
LastSeen = lastSeen,
163173
JobCount = jobCount
164174
};

0 commit comments

Comments
 (0)