Fix leaderboards for non-adventure levels

This commit is contained in:
Slendy 2022-09-20 16:55:56 -05:00
commit a6c17b0e16
No known key found for this signature in database
GPG key ID: 7288D68361B91428

View file

@ -118,11 +118,11 @@ public class ScoreController : ControllerBase
Type = score.Type, Type = score.Type,
Points = score.Points, Points = score.Points,
SlotId = score.SlotId, SlotId = score.SlotId,
ChildSlotId = score.ChildSlotId ChildSlotId = score.ChildSlotId,
}; };
IQueryable<Score> existingScore = this.database.Scores.Where(s => s.SlotId == playerScore.SlotId) IQueryable<Score> existingScore = this.database.Scores.Where(s => s.SlotId == playerScore.SlotId)
.Where(s => childId != 0 || s.ChildSlotId == childId) .Where(s => s.ChildSlotId == 0 || s.ChildSlotId == childId)
.Where(s => s.PlayerIdCollection == playerScore.PlayerIdCollection) .Where(s => s.PlayerIdCollection == playerScore.PlayerIdCollection)
.Where(s => s.Type == playerScore.Type); .Where(s => s.Type == playerScore.Type);
if (existingScore.Any()) if (existingScore.Any())
@ -213,7 +213,7 @@ public class ScoreController : ControllerBase
// var needed for Anonymous type returned from SELECT // var needed for Anonymous type returned from SELECT
var rankedScores = this.database.Scores var rankedScores = this.database.Scores
.Where(s => s.SlotId == slotId && s.Type == type) .Where(s => s.SlotId == slotId && s.Type == type)
.Where(s => s.ChildSlotId == null || s.ChildSlotId == childId) .Where(s => s.ChildSlotId == 0 || s.ChildSlotId == childId)
.Where(s => playerIds == null || playerIds.Any(id => s.PlayerIdCollection.Contains(id))) .Where(s => playerIds == null || playerIds.Any(id => s.PlayerIdCollection.Contains(id)))
.AsEnumerable() .AsEnumerable()
.OrderByDescending(s => s.Points) .OrderByDescending(s => s.Points)