Complete Records/Leaderboards + Time Trials systems (100%)

RECORDS & LEADERBOARDS (5/5 endpoints - 100%):
- Created LeaderboardsController with 5 endpoints
- GET /synergy/leaderboards/timetrials/{trialId}
- GET /synergy/leaderboards/career/{series}/{event}
- GET /synergy/leaderboards/global/top100
- GET /synergy/leaderboards/player/{synergyId}/records
- GET /synergy/leaderboards/compare/{synergyId1}/{synergyId2}

Added LeaderboardEntry and PersonalRecord models and database tables.
Migration applied: AddLeaderboardsAndRecords

Updated RewardsController.SubmitTimeTrial to track personal bests,
update leaderboards, and award 50 gold bonus for improvements.

Updated ProgressionController.CompleteCareerEvent similarly for
career event personal records.

TIME TRIALS (6/6 endpoints - 100%):
- GET /synergy/rewards/timetrials - List with time remaining
- GET /synergy/rewards/timetrials/{id} - Details with stats
- POST /synergy/rewards/timetrials/{id}/submit - Submit with PB tracking
- GET /synergy/rewards/timetrials/player/{synergyId}/results - History
- POST /synergy/rewards/timetrials/{id}/claim - Claim bonuses
- GET /synergy/leaderboards/timetrials/{id} - Leaderboards (above)

Added navigation properties to TimeTrialResult for easier queries.

Server progress: 66/73 endpoints (90%)
Two complete systems: Records/Leaderboards + Time Trials

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-22 17:49:23 -08:00
parent e839064b35
commit a6167c8249
11 changed files with 2695 additions and 25 deletions

View File

@@ -25,6 +25,8 @@ public class RR3DbContext : DbContext
public DbSet<ModPack> ModPacks { get; set; }
public DbSet<UserSettings> UserSettings { get; set; }
public DbSet<PlayerSave> PlayerSaves { get; set; }
public DbSet<LeaderboardEntry> LeaderboardEntries { get; set; }
public DbSet<PersonalRecord> PersonalRecords { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -308,6 +310,10 @@ public class TimeTrialResult
public bool BeatTarget { get; set; }
public int GoldEarned { get; set; }
public int CashEarned { get; set; }
// Navigation properties
public TimeTrial? TimeTrial { get; set; }
public User? User { get; set; }
}
public class Car
@@ -418,6 +424,39 @@ public class PlayerSave
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
public class LeaderboardEntry
{
public int Id { get; set; }
public string SynergyId { get; set; } = string.Empty;
public string PlayerName { get; set; } = string.Empty;
public string RecordType { get; set; } = string.Empty; // "TimeTrial", "Career", "Multiplayer"
public string RecordCategory { get; set; } = string.Empty;
public string? TrackName { get; set; }
public string? CarName { get; set; }
public double TimeSeconds { get; set; }
public DateTime SubmittedAt { get; set; }
}
public class PersonalRecord
{
public int Id { get; set; }
public string SynergyId { get; set; } = string.Empty;
public string RecordType { get; set; } = string.Empty;
public string RecordCategory { get; set; } = string.Empty;
public string? TrackName { get; set; }
public string? CarName { get; set; }
public double BestTimeSeconds { get; set; }
public DateTime AchievedAt { get; set; }
public DateTime? PreviousBestTime { get; set; }
public double? ImprovementSeconds { get; set; }
public int TotalAttempts { get; set; }
}
// Mod Pack entity - bundles of custom content
public class ModPack
{