feat(pack): gacha-point accrual with per-child override
This commit is contained in:
@@ -123,7 +123,31 @@ public sealed class GachaPointService : IGachaPointService
|
||||
private static bool IsLeaderCard(CardCosmeticReward? skin) => skin is not null;
|
||||
|
||||
public void Accrue(Viewer viewer, PackConfigEntry pack, PackChildGachaEntry child, int packNumber)
|
||||
=> throw new NotImplementedException();
|
||||
{
|
||||
if (pack.GachaPointConfig is null) return;
|
||||
if (packNumber <= 0) return;
|
||||
|
||||
// Per-child override wins when set (>0); fall back to the pack's default.
|
||||
int perPack = child.OverrideIncreaseGachaPoint > 0
|
||||
? child.OverrideIncreaseGachaPoint
|
||||
: pack.GachaPointConfig.IncreaseGachaPoint;
|
||||
if (perPack <= 0) return;
|
||||
|
||||
int delta = perPack * packNumber;
|
||||
|
||||
var existing = viewer.GachaPointBalances.FirstOrDefault(b => b.PackId == pack.Id);
|
||||
if (existing is null)
|
||||
{
|
||||
viewer.GachaPointBalances.Add(new ViewerGachaPointBalance
|
||||
{
|
||||
PackId = pack.Id, Points = delta,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
existing.Points += delta;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<ExchangeOutcome> TryExchangeAsync(Viewer viewer, int packId, long cardId)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
Reference in New Issue
Block a user