Files
SVSimServer/SVSim.Database/Services/Inventory/GrantSource.cs
gamer147 645c32e11c docs(inventory): annotate GrantSource gap + For() exception
Add comment above AdminGrant = 99 explaining the intentional 16–98 gap,
and add <exception> XML doc on GrantSourceMessages.For() so IDE tooling
surfaces the ArgumentOutOfRangeException.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 14:11:45 -04:00

64 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace SVSim.Database.Services.Inventory;
/// <summary>
/// Logical source of a grant routed through <see cref="IInventoryTransaction.GrantAsync"/>.
/// Stored verbatim in <c>viewer_acquire_history.AcquireType</c> and surfaced on the
/// <c>/item_acquire_history/info</c> wire as <c>acquire_type</c>.
/// </summary>
/// <remarks>
/// Values are persisted to the database — renumbering after ship requires a migration.
/// Values 1 and 2 mirror the prod capture in
/// <c>data_dumps/captures/traffic_prod_misc_clicking.ndjson</c>; the rest are our own.
/// </remarks>
public enum GrantSource
{
Unknown = 0,
DailyBonus = 1,
PackOpen = 2,
PuzzleReward = 3,
StoryFinish = 4,
BattlePassClaim = 5,
MissionReward = 6,
ArenaTwoPickFinish = 7,
ItemPurchase = 8,
BuildDeckBuy = 9,
SleeveBuy = 10,
LeaderSkinBuy = 11,
GachaPointExchange = 12,
AchievementReward = 13,
SerialCodeRedeem = 14,
CardCosmeticCascade = 15,
// Reserved high to stay visually distinct from gameplay sources; 1698 are intentionally unused.
AdminGrant = 99,
}
/// <summary>
/// Pre-localized text written into the <c>message</c> field of an item-acquire-history row.
/// The client renders this string verbatim, so all entries are user-facing English.
/// </summary>
public static class GrantSourceMessages
{
/// <exception cref="ArgumentOutOfRangeException">An unmapped <see cref="GrantSource"/> value was passed.</exception>
public static string For(GrantSource source) => source switch
{
GrantSource.Unknown => "Unknown",
GrantSource.DailyBonus => "Daily Bonus",
GrantSource.PackOpen => "From buying card packs",
GrantSource.PuzzleReward => "From puzzle reward",
GrantSource.StoryFinish => "From story reward",
GrantSource.BattlePassClaim => "From battle pass reward",
GrantSource.MissionReward => "From mission reward",
GrantSource.ArenaTwoPickFinish => "From 2Pick reward",
GrantSource.ItemPurchase => "From shop purchase",
GrantSource.BuildDeckBuy => "From starter set purchase",
GrantSource.SleeveBuy => "From sleeve purchase",
GrantSource.LeaderSkinBuy => "From leader skin purchase",
GrantSource.GachaPointExchange => "From point exchange",
GrantSource.AchievementReward => "From achievement reward",
GrantSource.SerialCodeRedeem => "From serial code",
GrantSource.CardCosmeticCascade => "Card cosmetic",
GrantSource.AdminGrant => "From admin grant",
_ => throw new ArgumentOutOfRangeException(nameof(source), source, "Unhandled GrantSource"),
};
}