38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
namespace NeonSprawl.Server.Game.Quests;
|
|
|
|
/// <summary>Id normalization for player quest progress stores (NEO-116).</summary>
|
|
public static class QuestProgressIds
|
|
{
|
|
/// <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 NormalizeQuestId(string? questId) => NormalizePlayerId(questId);
|
|
|
|
/// <summary>Trim + lowercase; empty when input is null/whitespace.</summary>
|
|
public static string NormalizeObjectiveId(string? objectiveId) => NormalizePlayerId(objectiveId);
|
|
|
|
/// <summary>Composite store key for <paramref name="playerId"/> + <paramref name="questId"/>.</summary>
|
|
public static string MakeProgressKey(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}";
|
|
}
|
|
|
|
}
|