Files
Daniel Elliott a934f57b52 Add Friends/Social & Multiplayer systems - 95 total endpoints
- Implemented Friends/Social Service (11 endpoints)
  * Friend management (list, add, accept, remove)
  * User search and invitations
  * Gift sending and claiming
  * Clubs/Teams system

- Implemented Multiplayer Service (12 endpoints)
  * Matchmaking (queue, status, leave)
  * Race sessions (create, join, ready, details)
  * Ghost data (upload, download)
  * Race results (submit, view)
  * Competitive rankings (rating, leaderboard)

- Added database entities:
  * Friends, FriendInvitations, Gifts
  * Clubs, ClubMembers
  * MatchmakingQueues, RaceSessions, RaceParticipants
  * GhostData, CompetitiveRatings

- Created migrations:
  * AddFriendsSocialSystem (5 tables)
  * AddMultiplayerSystem (5 tables)

Total: 95 endpoints - 100% EA server replacement ready

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-23 16:55:33 -08:00

695 lines
21 KiB
C#

namespace RR3CommunityServer.Models;
// User Settings for Server Configuration
public class UserSettings
{
public int Id { get; set; }
public string DeviceId { get; set; } = string.Empty;
public string ServerUrl { get; set; } = string.Empty;
public string Mode { get; set; } = "offline"; // "online" or "offline"
public DateTime LastUpdated { get; set; } = DateTime.UtcNow;
}
// Progression request/response models
public class ProgressionUpdate
{
public int? GoldEarned { get; set; }
public int? CashEarned { get; set; }
public int? ExperienceEarned { get; set; }
public int? ReputationEarned { get; set; }
}
public class CarPurchaseRequest
{
public string SynergyId { get; set; } = string.Empty;
public string CarId { get; set; } = string.Empty;
public bool UseGold { get; set; } = false;
}
public class CarUpgradeRequest
{
public string SynergyId { get; set; } = string.Empty;
public string CarId { get; set; } = string.Empty;
public string UpgradeType { get; set; } = string.Empty; // engine, tires, suspension, etc.
}
public class CareerEventCompletion
{
public string SynergyId { get; set; } = string.Empty;
public string SeriesName { get; set; } = string.Empty;
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
public class SynergyResponse<T>
{
public int resultCode { get; set; } = 0; // 0 = success, negative = error
public string? message { get; set; }
public T? data { get; set; }
}
// User models
public class DeviceIdResponse
{
public string deviceId { get; set; } = string.Empty;
public string synergyId { get; set; } = string.Empty;
public long timestamp { get; set; }
}
public class AnonUidResponse
{
public string anonUid { get; set; } = string.Empty;
public long expiresAt { get; set; }
}
// Product/Catalog models
public class CatalogItem
{
public string itemId { get; set; } = string.Empty;
public string sku { get; set; } = string.Empty;
public string name { get; set; } = string.Empty;
public string description { get; set; } = string.Empty;
public string category { get; set; } = string.Empty;
public decimal price { get; set; }
public string currency { get; set; } = "USD";
public Dictionary<string, object> metadata { get; set; } = new();
}
public class CatalogCategory
{
public string categoryId { get; set; } = string.Empty;
public string name { get; set; } = string.Empty;
public List<string> itemIds { get; set; } = new();
}
// DRM models
public class DrmNonceResponse
{
public string nonce { get; set; } = string.Empty;
public long expiresAt { get; set; }
}
public class PurchasedItem
{
public string itemId { get; set; } = string.Empty;
public string sku { get; set; } = string.Empty;
public string orderId { get; set; } = string.Empty;
public long purchaseTime { get; set; }
public string token { get; set; } = string.Empty;
}
public class PurchaseVerificationRequest
{
public string receipt { get; set; } = string.Empty;
public string signature { get; set; } = string.Empty;
public string sku { get; set; } = string.Empty;
public string orderId { get; set; } = string.Empty;
}
// Tracking models
public class TrackingEvent
{
public string eventType { get; set; } = string.Empty;
public long timestamp { get; set; }
public Dictionary<string, object> properties { get; set; } = new();
}
// Director/Service Discovery
public class DirectorResponse
{
public Dictionary<string, string> serverUrls { get; set; } = new()
{
{ "synergy.product", "https://localhost:5001" },
{ "synergy.drm", "https://localhost:5001" },
{ "synergy.user", "https://localhost:5001" },
{ "synergy.tracking", "https://localhost:5001" },
{ "synergy.s2s", "https://localhost:5001" }
};
public string environment { get; set; } = "COMMUNITY";
public string version { get; set; } = "1.0.0";
}
// Configuration models
public class GameConfig
{
public long ServerTime { get; set; }
public string ServerVersion { get; set; } = string.Empty;
public string GameVersion { get; set; } = string.Empty;
public bool MaintenanceMode { get; set; }
public string MessageOfTheDay { get; set; } = string.Empty;
public FeatureFlags FeatureFlags { get; set; } = new();
public ServerUrls Urls { get; set; } = new();
}
public class FeatureFlags
{
public bool MultiplayerEnabled { get; set; }
public bool LeaderboardsEnabled { get; set; }
public bool DailyRewardsEnabled { get; set; }
public bool TimeTrialsEnabled { get; set; }
public bool CustomContentEnabled { get; set; }
public bool SpecialEventsEnabled { get; set; }
public bool AllItemsFree { get; set; }
}
public class ServerUrls
{
public string BaseUrl { get; set; } = string.Empty;
public string AssetsUrl { get; set; } = string.Empty;
public string LeaderboardsUrl { get; set; } = string.Empty;
public string MultiplayerUrl { get; set; } = string.Empty;
}
public class ServerTime
{
public long ServerTimestamp { get; set; }
public long ServerTimeMs { get; set; }
public string Timezone { get; set; } = "UTC";
public bool IsDST { get; set; }
}
public class ServerStatus
{
public string Status { get; set; } = "online";
public string Version { get; set; } = string.Empty;
public bool MaintenanceMode { get; set; }
public int PlayerCount { get; set; }
public long Uptime { get; set; }
public string Message { get; set; } = string.Empty;
}
// Save/Load models
public class PlayerSaveData
{
public string SynergyId { get; set; } = string.Empty;
public string SaveDataJson { get; set; } = string.Empty;
public long Version { get; set; } = 1;
public long LastModified { get; set; }
}
public class SaveDataRequest
{
public string SynergyId { get; set; } = string.Empty;
public string SaveData { get; set; } = string.Empty;
}
public class SaveDataResponse
{
public string SaveData { get; set; } = string.Empty;
public long Version { get; set; }
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; }
}
// ==================== NOTIFICATIONS ====================
public class NotificationDto
{
public int Id { get; set; }
public string Type { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
public bool IsRead { get; set; }
public long CreatedAt { get; set; } // Unix timestamp
public long? ExpiresAt { get; set; }
}
public class NotificationsResponse
{
public List<NotificationDto> Notifications { get; set; } = new();
public int TotalCount { get; set; }
public int UnreadCount { get; set; }
}
public class UnreadCountResponse
{
public int UnreadCount { get; set; }
}
public class MarkReadRequest
{
public string SynergyId { get; set; } = string.Empty;
public List<int>? NotificationIds { get; set; } // null = mark all read
}
public class SendNotificationRequest
{
public string? SynergyId { get; set; } // null = send to all players
public string Type { get; set; } = "system";
public string Title { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
public int? ExpiresInHours { get; set; } // null = never expires
}
// ===== FRIENDS/SOCIAL SYSTEM MODELS =====
// Simple response with just resultCode and message (no data)
public class SimpleResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
}
// Friend DTO
public class FriendDto
{
public int UserId { get; set; }
public string Nickname { get; set; } = string.Empty;
public string SynergyId { get; set; } = string.Empty;
public int Level { get; set; }
public DateTime? LastOnline { get; set; }
public DateTime FriendsSince { get; set; }
}
// Friend list response
public class FriendsListResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public List<FriendDto> Friends { get; set; } = new();
public int TotalCount { get; set; }
}
// Friend invitation DTO
public class FriendInvitationDto
{
public int InvitationId { get; set; }
public int SenderId { get; set; }
public string SenderNickname { get; set; } = string.Empty;
public string SenderSynergyId { get; set; } = string.Empty;
public int SenderLevel { get; set; }
public string Status { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
public DateTime ExpiresAt { get; set; }
}
// Pending invitations response
public class PendingInvitationsResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public List<FriendInvitationDto> Invitations { get; set; } = new();
}
// User search result DTO
public class UserSearchResultDto
{
public int UserId { get; set; }
public string Nickname { get; set; } = string.Empty;
public string SynergyId { get; set; } = string.Empty;
public int Level { get; set; }
public bool IsFriend { get; set; }
public bool HasPendingInvite { get; set; }
}
// User search response
public class UserSearchResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public List<UserSearchResultDto> Users { get; set; } = new();
}
// Gift DTO
public class GiftDto
{
public int GiftId { get; set; }
public int SenderId { get; set; }
public string SenderNickname { get; set; } = string.Empty;
public string GiftType { get; set; } = string.Empty;
public int Amount { get; set; }
public string? Message { get; set; }
public DateTime SentAt { get; set; }
public DateTime ExpiresAt { get; set; }
}
// Pending gifts response
public class PendingGiftsResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public List<GiftDto> Gifts { get; set; } = new();
}
// Send gift request
public class SendGiftRequest
{
public string SynergyId { get; set; } = string.Empty;
public string FriendSynergyId { get; set; } = string.Empty;
public string GiftType { get; set; } = string.Empty;
public int Amount { get; set; }
public string? Message { get; set; }
}
// Claim gift response
public class ClaimGiftResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public string GiftType { get; set; } = string.Empty;
public int Amount { get; set; }
public int NewBalance { get; set; }
}
// Club DTO
public class ClubDto
{
public int ClubId { get; set; }
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string Tag { get; set; } = string.Empty;
public int MemberCount { get; set; }
public int MaxMembers { get; set; }
public bool IsPublic { get; set; }
public bool IsRecruiting { get; set; }
public int TotalPoints { get; set; }
public DateTime CreatedAt { get; set; }
}
// Club list response
public class ClubsListResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public List<ClubDto> Clubs { get; set; } = new();
}
// Club member DTO
public class ClubMemberDto
{
public int UserId { get; set; }
public string Nickname { get; set; } = string.Empty;
public string SynergyId { get; set; } = string.Empty;
public int Level { get; set; }
public string Role { get; set; } = string.Empty;
public int ContributedPoints { get; set; }
public DateTime JoinedAt { get; set; }
}
// Club members response
public class ClubMembersResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public ClubDto Club { get; set; } = new();
public List<ClubMemberDto> Members { get; set; } = new();
}
// Create club request
public class CreateClubRequest
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string Tag { get; set; } = string.Empty;
public bool IsPublic { get; set; } = true;
}
// ===== MULTIPLAYER SYSTEM MODELS =====
// Matchmaking queue request
public class JoinMatchmakingRequest
{
public string SynergyId { get; set; } = string.Empty;
public string CarClass { get; set; } = string.Empty;
public string Track { get; set; } = string.Empty;
public string GameMode { get; set; } = "casual"; // "ranked", "casual"
}
// Matchmaking status response
public class MatchmakingStatusResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public string Status { get; set; } = string.Empty; // "queued", "matched", "cancelled"
public int? QueueId { get; set; }
public int? SessionId { get; set; }
public string? SessionCode { get; set; }
public int? EstimatedWaitSeconds { get; set; }
public DateTime QueuedAt { get; set; }
}
// Create race session request
public class CreateRaceSessionRequest
{
public string SynergyId { get; set; } = string.Empty;
public string Track { get; set; } = string.Empty;
public string CarClass { get; set; } = string.Empty;
public int MaxPlayers { get; set; } = 8;
public bool IsPrivate { get; set; } = false;
}
// Race session DTO
public class RaceSessionDto
{
public int SessionId { get; set; }
public string SessionCode { get; set; } = string.Empty;
public string Track { get; set; } = string.Empty;
public string CarClass { get; set; } = string.Empty;
public int HostUserId { get; set; }
public string HostNickname { get; set; } = string.Empty;
public int CurrentPlayers { get; set; }
public int MaxPlayers { get; set; }
public string Status { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
}
// Race session response
public class RaceSessionResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public RaceSessionDto Session { get; set; } = new();
public List<ParticipantDto> Participants { get; set; } = new();
}
// Participant DTO
public class ParticipantDto
{
public int UserId { get; set; }
public string Nickname { get; set; } = string.Empty;
public string SynergyId { get; set; } = string.Empty;
public string CarId { get; set; } = string.Empty;
public bool IsReady { get; set; }
public int? FinishPosition { get; set; }
public double? RaceTime { get; set; }
}
// Upload ghost request
public class UploadGhostRequest
{
public string SynergyId { get; set; } = string.Empty;
public string Track { get; set; } = string.Empty;
public string CarId { get; set; } = string.Empty;
public double RaceTime { get; set; }
public string TelemetryData { get; set; } = string.Empty; // Base64 or JSON
}
// Ghost data DTO
public class GhostDataDto
{
public int GhostId { get; set; }
public int UserId { get; set; }
public string Nickname { get; set; } = string.Empty;
public string Track { get; set; } = string.Empty;
public string CarId { get; set; } = string.Empty;
public double RaceTime { get; set; }
public string TelemetryData { get; set; } = string.Empty;
public DateTime UploadedAt { get; set; }
}
// Ghost data response
public class GhostDataResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public GhostDataDto? Ghost { get; set; }
}
// Submit race result request
public class SubmitRaceResultRequest
{
public string SynergyId { get; set; } = string.Empty;
public int SessionId { get; set; }
public double RaceTime { get; set; }
public int Position { get; set; }
public string? TelemetryData { get; set; }
}
// Race result response
public class RaceResultResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public int Position { get; set; }
public int RewardGold { get; set; }
public int RewardCash { get; set; }
public int RewardXP { get; set; }
public int? RatingChange { get; set; } // For ranked matches
public int? NewRating { get; set; }
}
// Race results (all players)
public class RaceResultsResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public List<ParticipantDto> Results { get; set; } = new();
}
// Competitive rating DTO
public class CompetitiveRatingDto
{
public int UserId { get; set; }
public string Nickname { get; set; } = string.Empty;
public int Rating { get; set; }
public int Wins { get; set; }
public int Losses { get; set; }
public int Draws { get; set; }
public string Division { get; set; } = string.Empty;
public int DivisionRank { get; set; }
}
// Rating response
public class RatingResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public CompetitiveRatingDto Rating { get; set; } = new();
}
// Leaderboard response
public class CompetitiveLeaderboardResponse
{
public int ResultCode { get; set; } = 0;
public string? Message { get; set; }
public List<CompetitiveRatingDto> Leaderboard { get; set; } = new();
}