Files
rr3-server/RR3CommunityServer/Models/ApiModels.cs
Daniel Elliott e839064b35 Add Phase 1 critical endpoints: Config & Save/Load system
- Added ConfigController with 4 endpoints:
  - getGameConfig: Server config, feature flags, URLs
  - getServerTime: UTC timestamps
  - getFeatureFlags: Feature toggles
  - getServerStatus: Health check

- Added save/load system to ProgressionController:
  - POST /save/{synergyId}: Save JSON blob
  - GET /save/{synergyId}/load: Load JSON blob
  - Version tracking and timestamps

- Added PlayerSave entity to database:
  - Stores arbitrary JSON game state
  - Version tracking (increments on save)
  - LastModified timestamps

- Updated appsettings.json:
  - ServerSettings section (version, URLs, MOTD)
  - FeatureFlags section (7 feature toggles)

- Created migration: AddPlayerSavesAndConfig
- Updated ApiModels with new DTOs
- All endpoints tested and working

Phase 1 objectives complete:
 Synergy ID generation (already existed)
 Configuration endpoints (new)
 Save/load system (new)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-21 23:53:43 -08:00

205 lines
6.2 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; }
}
// 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; }
}