using NeonSprawl.Server.Game.PositionState;

namespace NeonSprawl.Server.Game.Gigs;

/// <summary>Registers gig XP persistence: PostgreSQL when configured, otherwise in-memory fallback (NEO-44).</summary>
public static class GigProgressionServiceCollectionExtensions
{
    public static IServiceCollection AddGigProgressionStore(this IServiceCollection services, IConfiguration configuration)
    {
        var cs = configuration.GetConnectionString(PositionStateServiceCollectionExtensions.NeonSprawlConnectionStringName);
        if (!string.IsNullOrWhiteSpace(cs))
        {
            services.AddSingleton<IPlayerGigProgressionStore, PostgresPlayerGigProgressionStore>();
        }
        else
        {
            services.AddSingleton<IPlayerGigProgressionStore, InMemoryPlayerGigProgressionStore>();
        }

        return services;
    }
}
