mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-09 06:41:28 +00:00
Only update score timestamps when you get more points
This commit is contained in:
parent
9f5a85d600
commit
f0a1826b85
2 changed files with 171 additions and 8 deletions
|
@ -136,14 +136,10 @@ public class ScoreController : ControllerBase
|
|||
.Where(s => s.UserId == token.UserId)
|
||||
.Where(s => s.Type == score.Type)
|
||||
.FirstOrDefaultAsync();
|
||||
if (existingScore != null)
|
||||
|
||||
if (existingScore == null)
|
||||
{
|
||||
existingScore.Points = Math.Max(existingScore.Points, score.Points);
|
||||
existingScore.Timestamp = TimeHelper.TimestampMillis;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScoreEntity playerScore = new()
|
||||
existingScore = new ScoreEntity
|
||||
{
|
||||
UserId = token.UserId,
|
||||
Type = score.Type,
|
||||
|
@ -152,7 +148,13 @@ public class ScoreController : ControllerBase
|
|||
ChildSlotId = childId,
|
||||
Timestamp = TimeHelper.TimestampMillis,
|
||||
};
|
||||
this.database.Scores.Add(playerScore);
|
||||
this.database.Scores.Add(existingScore);
|
||||
}
|
||||
|
||||
if (score.Points > existingScore.Points)
|
||||
{
|
||||
existingScore.Points = score.Points;
|
||||
existingScore.Timestamp = TimeHelper.TimestampMillis;
|
||||
}
|
||||
|
||||
await this.database.SaveChangesAsync();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue