repo(card): ICardInventoryRepository.CreateCards surface

This commit is contained in:
gamer147
2026-05-28 01:03:41 -04:00
parent a851e6aa20
commit dd80f5187a

View File

@@ -18,6 +18,14 @@ public interface ICardInventoryRepository
/// <see cref="DestructError"/> when validation fails. On error nothing is written.
/// </returns>
Task<DestructOutcome> DestructCards(long viewerId, IReadOnlyDictionary<long, int> destructCounts);
/// <summary>
/// Validate-then-mutate craft of cards from RedEther. Atomic in a transaction; on validation
/// failure nothing is written. Routes Card grants through <see cref="Services.RewardGrantService.ApplyAsync"/>
/// so the CardCosmeticReward cascade fires for first-time owners.
/// </summary>
/// <param name="createCounts">cardId → num_to_create. Empty dict is rejected by the caller.</param>
Task<CreateOutcome> CreateCards(long viewerId, IReadOnlyDictionary<long, int> createCounts);
}
/// <summary>
@@ -42,3 +50,28 @@ public enum DestructError
CardProtected,
InsufficientCards,
}
public sealed record CreateOutcome(CreateResult? Result, CreateError? Error)
{
public bool IsSuccess => Result is not null;
public static CreateOutcome Ok(CreateResult r) => new(r, null);
public static CreateOutcome Fail(CreateError e) => new(null, e);
}
/// <summary>
/// Outcome of a successful create. <see cref="Grants"/> is the flattened
/// <see cref="Services.GrantedReward"/> list returned by <see cref="Services.RewardGrantService.ApplyAsync"/>
/// — one Card entry per crafted cardId plus any cosmetic-cascade entries.
/// </summary>
public sealed record CreateResult(
ulong NewRedEtherTotal,
IReadOnlyList<Services.GrantedReward> Grants);
public enum CreateError
{
UnknownCard,
NotCraftable,
WouldExceedMaxCopies,
InsufficientVials,
}