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

@@ -40,6 +40,8 @@ public class CareerEventCompletion
public string EventName { get; set; } = string.Empty;
public int StarsEarned { get; set; } // 1-3 stars
public double RaceTime { get; set; }
public string? TrackName { get; set; }
public string? CarName { get; set; }
}
// Standard Synergy API response wrapper
@@ -202,3 +204,127 @@ public class SaveDataResponse
public long LastModified { get; set; }
public bool Success { get; set; }
}
// ==================== LEADERBOARDS & RECORDS ====================
public class LeaderboardEntry
{
public int Id { get; set; }
public string SynergyId { get; set; } = string.Empty;
public string PlayerName { get; set; } = string.Empty;
// What this record is for
public string RecordType { get; set; } = string.Empty; // "TimeTrial", "Career", "Multiplayer"
public string RecordCategory { get; set; } = string.Empty; // Time trial ID, series name, etc.
public string? TrackName { get; set; }
public string? CarName { get; set; }
// The actual record
public double TimeSeconds { get; set; }
public DateTime SubmittedAt { get; set; }
// Rankings (computed at query time)
public int? GlobalRank { get; set; }
public int? CountryRank { get; set; }
}
public class PersonalRecord
{
public int Id { get; set; }
public string SynergyId { get; set; } = string.Empty;
// What record this is
public string RecordType { get; set; } = string.Empty; // "TimeTrial", "Career"
public string RecordCategory { get; set; } = string.Empty; // Specific trial/event
public string? TrackName { get; set; }
public string? CarName { get; set; }
// The record
public double BestTimeSeconds { get; set; }
public DateTime AchievedAt { get; set; }
public DateTime? PreviousBestTime { get; set; }
public double? ImprovementSeconds { get; set; }
// Stats
public int TotalAttempts { get; set; }
}
public class LeaderboardResponse
{
public string RecordType { get; set; } = string.Empty;
public string RecordCategory { get; set; } = string.Empty;
public int TotalEntries { get; set; }
public List<LeaderboardEntryDto> Entries { get; set; } = new();
public LeaderboardEntryDto? PlayerEntry { get; set; } // Requesting player's rank
}
public class LeaderboardEntryDto
{
public int Rank { get; set; }
public string PlayerName { get; set; } = string.Empty;
public string SynergyId { get; set; } = string.Empty;
public double TimeSeconds { get; set; }
public string FormattedTime { get; set; } = string.Empty; // "1:23.456"
public DateTime SubmittedAt { get; set; }
public string? CarName { get; set; }
public bool IsCurrentPlayer { get; set; }
}
public class PersonalRecordsResponse
{
public string SynergyId { get; set; } = string.Empty;
public string PlayerName { get; set; } = string.Empty;
public int TotalRecords { get; set; }
public List<PersonalRecordDto> TimeTrialRecords { get; set; } = new();
public List<PersonalRecordDto> CareerRecords { get; set; } = new();
}
public class PersonalRecordDto
{
public string RecordCategory { get; set; } = string.Empty;
public string? TrackName { get; set; }
public string? CarName { get; set; }
public double BestTimeSeconds { get; set; }
public string FormattedTime { get; set; } = string.Empty;
public DateTime AchievedAt { get; set; }
public int TotalAttempts { get; set; }
public int GlobalRank { get; set; }
public double? ImprovementSeconds { get; set; }
}
public class RecordComparisonResponse
{
public PlayerRecordSummary Player1 { get; set; } = new();
public PlayerRecordSummary Player2 { get; set; } = new();
public List<RecordComparison> Comparisons { get; set; } = new();
}
public class PlayerRecordSummary
{
public string SynergyId { get; set; } = string.Empty;
public string PlayerName { get; set; } = string.Empty;
public int TotalRecords { get; set; }
public int BetterRecords { get; set; }
}
public class RecordComparison
{
public string RecordCategory { get; set; } = string.Empty;
public string? TrackName { get; set; }
public double? Player1Time { get; set; }
public double? Player2Time { get; set; }
public string? Winner { get; set; } // "player1", "player2", "tie"
public double? TimeDifference { get; set; }
}
public class RecordSubmissionResponse
{
public bool Success { get; set; }
public bool IsNewPersonalBest { get; set; }
public bool IsNewGlobalRecord { get; set; }
public int GlobalRank { get; set; }
public double? PreviousBestTime { get; set; }
public double? Improvement { get; set; }
public int GoldEarned { get; set; }
public int CashEarned { get; set; }
}