feat(load): project currency/cards/cosmetics through entitlements (freeplay)
Route /load/index currency, owned-card list, and cosmetic id-lists through IViewerEntitlements so freeplay mode inflates all three without touching the viewer's DB state. Adds LoadControllerFreeplayTests (2 tests). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -50,12 +50,13 @@ public class LoadController : SVSimController
|
||||
private readonly IBattlePassService _battlePass;
|
||||
private readonly IViewerMissionStateService _missionState;
|
||||
private readonly SVSimDbContext _db;
|
||||
private readonly IViewerEntitlements _entitlements;
|
||||
|
||||
public LoadController(IViewerRepository viewerRepository, ICardRepository cardRepository,
|
||||
ICollectionRepository collectionRepository, IGlobalsRepository globalsRepository,
|
||||
ICardAcquisitionService acquisition, IGameConfigService config,
|
||||
IBattlePassService battlePass, IViewerMissionStateService missionState,
|
||||
SVSimDbContext db)
|
||||
SVSimDbContext db, IViewerEntitlements entitlements)
|
||||
{
|
||||
_viewerRepository = viewerRepository;
|
||||
_cardRepository = cardRepository;
|
||||
@@ -66,6 +67,7 @@ public class LoadController : SVSimController
|
||||
_battlePass = battlePass;
|
||||
_missionState = missionState;
|
||||
_db = db;
|
||||
_entitlements = entitlements;
|
||||
}
|
||||
|
||||
[HttpPost("index")]
|
||||
@@ -127,20 +129,11 @@ public class LoadController : SVSimController
|
||||
// * card_set_id=90000 (engine tokens, char_type=4): never collectible
|
||||
// Both naturally fall out of "ownership-only" since the viewer can't own them;
|
||||
// re-confirm the filter if we later move to Option B and start iterating card-sets.
|
||||
var defaultCards = await _cardRepository.GetDefaultCards();
|
||||
var defaultCardIds = defaultCards.Select(c => c.Id).ToHashSet();
|
||||
var ownedCollectibles = viewer.Cards
|
||||
.Where(c => c.Count > 0 && !defaultCardIds.Contains(c.Card.Id));
|
||||
var allCardsAsOwned = ownedCollectibles
|
||||
.Concat(defaultCards.Select(bc => new OwnedCardEntry
|
||||
{
|
||||
Card = bc,
|
||||
Count = 3,
|
||||
IsProtected = true
|
||||
}))
|
||||
.ToList();
|
||||
// Owned-card projection (incl. the freeplay "all cards" path) lives in the entitlements
|
||||
// service so both modes share one definition.
|
||||
var allCardsAsOwned = await _entitlements.EffectiveOwnedCardsAsync(viewer, ct);
|
||||
|
||||
List<LeaderSkinEntry> allLeaderSkins = await _collectionRepository.GetLeaderSkins();
|
||||
var cosmetics = await _entitlements.EffectiveCosmeticsAsync(viewer, ct);
|
||||
var classExpCurve = await _globalsRepository.GetClassExpCurve();
|
||||
|
||||
List<ClassExp> classExps = new();
|
||||
@@ -179,7 +172,13 @@ public class LoadController : SVSimController
|
||||
{
|
||||
UserTutorial = new UserTutorial { TutorialStep = viewer.MissionData.TutorialState },
|
||||
UserInfo = new UserInfo(deviceType, viewer),
|
||||
UserCurrency = new UserCurrency(viewer),
|
||||
UserCurrency = new UserCurrency(viewer)
|
||||
{
|
||||
Crystals = (ulong)_entitlements.EffectiveBalance(viewer, SpendCurrency.Crystal),
|
||||
TotalCrystals = (ulong)_entitlements.EffectiveBalance(viewer, SpendCurrency.Crystal),
|
||||
Rupees = (ulong)_entitlements.EffectiveBalance(viewer, SpendCurrency.Rupee),
|
||||
RedEther = (ulong)_entitlements.EffectiveBalance(viewer, SpendCurrency.RedEther),
|
||||
},
|
||||
UserItems = viewer.Items.Select(item => new UserItem(item)).ToList(),
|
||||
SpotPoint = checked((int)viewer.Currency.SpotPoints),
|
||||
UserRotationDecks = new UserFormatDeckInfo
|
||||
@@ -199,13 +198,13 @@ public class LoadController : SVSimController
|
||||
},
|
||||
UserCards = allCardsAsOwned.Select(card => new UserCard(card)).ToList(),
|
||||
UserClasses = viewer.Classes.Select(vc => new UserClass(vc)).ToList(),
|
||||
Sleeves = viewer.Sleeves.Select(s => new SleeveIdentifier { SleeveId = s.Id }).ToList(),
|
||||
UserEmblems = viewer.Emblems.Select(e => new EmblemIdentifier { EmblemId = e.Id }).ToList(),
|
||||
UserDegrees = viewer.Degrees.Select(d => new DegreeIdentifier { DegreeId = d.Id }).ToList(),
|
||||
LeaderSkins = allLeaderSkins
|
||||
.Select(skin => new UserLeaderSkin(skin, viewer.LeaderSkins.Any(vs => vs.Id == skin.Id)))
|
||||
Sleeves = cosmetics.SleeveIds.Select(id => new SleeveIdentifier { SleeveId = id }).ToList(),
|
||||
UserEmblems = cosmetics.EmblemIds.Select(id => new EmblemIdentifier { EmblemId = id }).ToList(),
|
||||
UserDegrees = cosmetics.DegreeIds.Select(id => new DegreeIdentifier { DegreeId = id }).ToList(),
|
||||
LeaderSkins = cosmetics.AllLeaderSkins
|
||||
.Select(skin => new UserLeaderSkin(skin, cosmetics.OwnedLeaderSkinIds.Contains(skin.Id)))
|
||||
.ToList(),
|
||||
MyPageBackgrounds = viewer.MyPageBackgrounds.Select(mpbg => mpbg.Id.ToString()).ToList(),
|
||||
MyPageBackgrounds = cosmetics.MyPageBackgroundIds.Select(id => id.ToString()).ToList(),
|
||||
LootBoxRegulations = new LootBoxRegulations(),
|
||||
GatheringInfo = new GatheringInfo(),
|
||||
IsBattlePassPeriod = rotation.IsBattlePassPeriod,
|
||||
|
||||
Reference in New Issue
Block a user