namespace NeonSprawl.Server.Game.AbilityInput;

/// <summary>Registers hotbar loadout persistence: PostgreSQL when configured, otherwise in-memory fallback (NEO-29).</summary>
public static class HotbarLoadoutServiceCollectionExtensions
{
    public static IServiceCollection AddHotbarLoadoutStore(this IServiceCollection services, IConfiguration configuration)
    {
        var cs = configuration.GetConnectionString(PositionState.PositionStateServiceCollectionExtensions.NeonSprawlConnectionStringName);
        if (!string.IsNullOrWhiteSpace(cs))
        {
            services.AddSingleton<IPlayerHotbarLoadoutStore, PostgresPlayerHotbarLoadoutStore>();
        }
        else
        {
            services.AddSingleton<IPlayerHotbarLoadoutStore, InMemoryPlayerHotbarLoadoutStore>();
        }

        return services;
    }
}
