namespace NeonSprawl.Server.Game.Items;

/// <summary>Persisted per-player inventory slot state (NEO-54).</summary>
public interface IPlayerInventoryStore
{
    /// <summary>Returns the current snapshot for a known player bucket; false when the player is not in the store.</summary>
    bool TryGetSnapshot(string playerId, out PlayerInventorySnapshot snapshot);

    /// <summary>Atomically replaces the full snapshot for a known player; false when the player is not in the store.</summary>
    bool TryReplaceSnapshot(string playerId, PlayerInventorySnapshot snapshot);

    /// <summary>
    /// Atomically reads the current snapshot and optionally persists a replacement under per-player lock (in-memory)
    /// or within one database transaction (Postgres).
    /// </summary>
    bool TryMutateSnapshot(
        string playerId,
        Func<PlayerInventorySnapshot, PlayerInventoryMutationWrite> mutator,
        out PlayerInventorySnapshot result);
}
