namespace NeonSprawl.Server.Game.Rewards;
/// Id normalization and composite keys for reward delivery stores (NEO-126).
public static class RewardDeliveryIds
{
/// 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 NormalizeQuestId(string? questId) => NormalizePlayerId(questId);
/// Stable idempotency key for quest completion delivery.
public static string MakeIdempotencyKey(string? playerId, string? questId)
{
var p = NormalizePlayerId(playerId);
var q = NormalizeQuestId(questId);
if (p.Length == 0 || q.Length == 0)
{
return string.Empty;
}
return $"{p}:quest_complete:{q}";
}
/// Composite store key for + .
public static string MakeStoreKey(string? playerId, string? questId)
{
var p = NormalizePlayerId(playerId);
var q = NormalizeQuestId(questId);
if (p.Length == 0 || q.Length == 0)
{
return string.Empty;
}
return $"{p}\0{q}";
}
}