From b428b35f3dd9ecc6f14dad5c13634b69a6c256e0 Mon Sep 17 00:00:00 2001 From: Kat <30480654+Metraberryy@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:13:41 -0800 Subject: [PATCH] a few fixes related to highscore notifications (#1086) --- .../Controllers/Slots/ScoreController.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs index 8a859fd73..a7c41dd6e 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs @@ -152,7 +152,9 @@ public async Task SubmitScore(string slotType, int id, int childI this.database.Scores.Add(existingScore); } - if (score.Points > existingScore.Points) + bool personalBest = score.Points > existingScore.Points; + + if (personalBest) { existingScore.Points = score.Points; existingScore.Timestamp = TimeHelper.TimestampMillis; @@ -172,12 +174,14 @@ public async Task SubmitScore(string slotType, int id, int childI TargetPlayerIds = null, }); - if (score.Type == 1 && scores.YourRank == 1 && scores.Total > 1) + // if this is a PB, singleplayer, at the top of the leaderboard (not scores.YourRank==1 because it might be tied), and there is at least one other score, + // send a notification to the user with the previous highscore + if (personalBest && score.Type == 1 && scores.Scores[0].UserId == token.UserId && scores.Total > 1) { GameScore? second = scores.Scores[1]; UserEntity? user = await this.database.UserFromGameToken(token); - await this.database.SendNotification(second.UserId, $"{user?.InfoXml} beat your highscore ({second.Points}) on {slot.InfoXml} with a score of {score.Points}.", true); + await this.database.SendNotification(second.UserId, $"{user?.InfoXml} beat your highscore ({second.Points}) on {slot.InfoXml} with a score of {score.Points}.", false); } return this.Ok(scores);