refactor(gacha-point): route TryExchangeAsync through IInventoryTransaction
Change signature from (Viewer, packId, cardId) to (IInventoryTransaction, packId, cardId). Drop RewardGrantService from GachaPointService ctor. PackController.ExchangeGachaPoint opens tx with GachaPointBalances/Received extra includes, passes tx, commits on success. Update GachaPointServiceTests to use inv.BeginAsync + tx pattern. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using SVSim.Database.Models;
|
||||
using SVSim.Database.Services.Inventory;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Services;
|
||||
@@ -23,11 +24,14 @@ public interface IGachaPointService
|
||||
void Accrue(Viewer viewer, PackConfigEntry pack, PackChildGachaEntry child, int packNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Validate + execute an exchange. Returns the grant outcome on success (reward_list
|
||||
/// entries the controller will return in <see cref="Dtos.Responses.Pack.ExchangeGachaPointResponse"/>),
|
||||
/// or a failure result describing why. Mutates the in-memory graph; caller saves.
|
||||
/// Validate + execute an exchange using the provided inventory transaction (which must
|
||||
/// have <c>GachaPointBalances</c> and <c>GachaPointReceived</c> loaded on <c>tx.Viewer</c>
|
||||
/// via <see cref="IInventoryService.BeginAsync"/> extra includes). Grants the card via
|
||||
/// the tx. Returns the grant outcome on success (reward_list entries already converted to
|
||||
/// <see cref="RewardListEntry"/>), or a failure result describing why. Caller commits
|
||||
/// the tx on success.
|
||||
/// </summary>
|
||||
Task<ExchangeOutcome> TryExchangeAsync(Viewer viewer, int packId, long cardId);
|
||||
Task<ExchangeOutcome> TryExchangeAsync(IInventoryTransaction tx, int packId, long cardId);
|
||||
}
|
||||
|
||||
public sealed record ExchangeOutcome(bool Success, string? Error, IReadOnlyList<RewardListEntry> RewardList)
|
||||
|
||||
Reference in New Issue
Block a user