namespace NeonSprawl.Server.Game.Encounters;
/// Id normalization for encounter progress/completion stores (NEO-104).
public static class EncounterProgressIds
{
/// Trim + lowercase; empty when input is null/whitespace.
public static string NormalizePlayerId(string? playerId)
{
var trimmed = playerId?.Trim();
if (string.IsNullOrEmpty(trimmed))
{
return string.Empty;
}
return trimmed.ToLowerInvariant();
}
/// Trim + lowercase; empty when input is null/whitespace.
public static string NormalizeEncounterId(string? encounterId) => NormalizePlayerId(encounterId);
/// Trim + lowercase; empty when input is null/whitespace.
public static string NormalizeNpcInstanceId(string? npcInstanceId) => NormalizePlayerId(npcInstanceId);
/// Composite store key for + .
public static string MakeProgressKey(string? playerId, string? encounterId)
{
var p = NormalizePlayerId(playerId);
var e = NormalizeEncounterId(encounterId);
if (p.Length == 0 || e.Length == 0)
{
return string.Empty;
}
return $"{p}\0{e}";
}
}