mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-04-19 11:04:51 +00:00
a few fixes related to highscore notifications (#1086)
This commit is contained in:
parent
a528c65445
commit
b428b35f3d
1 changed files with 7 additions and 3 deletions
|
@ -152,7 +152,9 @@ public class ScoreController : ControllerBase
|
|||
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 class ScoreController : ControllerBase
|
|||
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 (<em>{second.Points}</em>) on {slot.InfoXml} with a score of <em>{score.Points}</em>.", true);
|
||||
await this.database.SendNotification(second.UserId, $"{user?.InfoXml} beat your highscore (<em>{second.Points}</em>) on {slot.InfoXml} with a score of <em>{score.Points}</em>.", false);
|
||||
}
|
||||
|
||||
return this.Ok(scores);
|
||||
|
|
Loading…
Add table
Reference in a new issue