37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
namespace NeonSprawl.Server.Game.Encounters;
|
|
|
|
/// <summary>Id normalization for encounter progress/completion stores (NEO-104).</summary>
|
|
public static class EncounterProgressIds
|
|
{
|
|
/// <summary>Trim + lowercase; empty when input is null/whitespace.</summary>
|
|
public static string NormalizePlayerId(string? playerId)
|
|
{
|
|
var trimmed = playerId?.Trim();
|
|
if (string.IsNullOrEmpty(trimmed))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
return trimmed.ToLowerInvariant();
|
|
}
|
|
|
|
/// <summary>Trim + lowercase; empty when input is null/whitespace.</summary>
|
|
public static string NormalizeEncounterId(string? encounterId) => NormalizePlayerId(encounterId);
|
|
|
|
/// <summary>Trim + lowercase; empty when input is null/whitespace.</summary>
|
|
public static string NormalizeNpcInstanceId(string? npcInstanceId) => NormalizePlayerId(npcInstanceId);
|
|
|
|
/// <summary>Composite store key for <paramref name="playerId"/> + <paramref name="encounterId"/>.</summary>
|
|
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}";
|
|
}
|
|
}
|