namespace SOR.Game; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using SOR.Database; using SOR.Game.Handlers; using SOR.Networking.Abstractions.Messaging; /// /// Registers all game service components into the DI container. /// Called from SOR.Host/Program.cs when ENABLED_SERVICES includes "game". /// public static class ServiceRegistration { public static IServiceCollection AddGameService( this IServiceCollection services, IConfiguration configuration) { services.AddGameDatabase(configuration); services.AddIdentityDatabase(configuration); services.AddCollectionDatabase(configuration); services.AddCatalogDatabase(configuration); // Abandons any Initializing sessions left over from a previous process (redeploy/crash). services.AddHostedService(); // Monitors active sessions for player inactivity. services.AddHostedService(); // Manages per-session turn timers; registered as singleton so handlers can inject it, // and as a hosted service so it receives app-lifetime Start/Stop callbacks. services.AddSingleton(); services.AddHostedService(sp => sp.GetRequiredService()); // Tracks spectators per session (in-memory; spectators only, players are not registered here). services.AddSingleton(); // Tracks clients subscribed to game activity events for the live-star skybox. services.AddSingleton(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); // Custom lobby handlers services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); // Ready-up handlers services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); // Spectator handlers services.AddTransient(); services.AddTransient(); // Skybox activity feed handlers services.AddTransient(); services.AddTransient(); // Preset vote service (in-memory, one active vote per lobby at a time). services.AddSingleton(); // Preset handlers services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); // Rule suggestion service (in-memory, one pending suggestion per lobby at a time). services.AddSingleton(); // Rule suggestion handlers (guest proposes → host accepts or rejects) services.AddTransient(); services.AddTransient(); services.AddTransient(); // Team assignment handler (host reassigns seats to teams) services.AddTransient(); // Triggered ability target response (player submits picks for a paused trigger) services.AddTransient(); return services; } }