Lots of data and model setup

This commit is contained in:
gamer147
2025-05-18 02:27:17 -04:00
parent 79505e0c1a
commit b2024af852
77 changed files with 81988 additions and 433 deletions

View File

@@ -1,5 +1,9 @@
using Microsoft.AspNetCore.Mvc;
using SVSim.Database.Enums;
using SVSim.Database.Models;
using SVSim.Database.Repositories.Card;
using SVSim.Database.Repositories.Collectibles;
using SVSim.Database.Repositories.Globals;
using SVSim.Database.Repositories.Viewer;
using SVSim.EmulatedEntrypoint.Constants;
using SVSim.EmulatedEntrypoint.Models.Dtos;
@@ -11,16 +15,22 @@ namespace SVSim.EmulatedEntrypoint.Controllers;
public class LoadController : SVSimController
{
private readonly IViewerRepository _viewerRepository;
private readonly ICardRepository _cardRepository;
private readonly ICollectionRepository _collectionRepository;
private readonly IGlobalsRepository _globalsRepository;
public LoadController(IViewerRepository viewerRepository)
public LoadController(IViewerRepository viewerRepository, ICardRepository cardRepository, ICollectionRepository collectionRepository, IGlobalsRepository globalsRepository)
{
_viewerRepository = viewerRepository;
_cardRepository = cardRepository;
_collectionRepository = collectionRepository;
_globalsRepository = globalsRepository;
}
[HttpPost("index")]
public async Task<ActionResult<IndexResponse>> Index(IndexRequest request)
{
Viewer? viewer = await _viewerRepository.GetViewerByShortUdid(ulong.Parse(User.Claims
Viewer? viewer = await _viewerRepository.GetViewerByShortUdid(long.Parse(User.Claims
.FirstOrDefault(claim => claim.Type == ShadowverseClaimTypes.ShortUdidClaim).Value));
if (viewer == null)
@@ -28,15 +38,105 @@ public class LoadController : SVSimController
return NotFound();
}
List<ShadowverseCardEntry> allCollectibleCards = await _cardRepository.GetAll(true);
List<ShadowverseCardEntry> allBasicCards = await _cardRepository.GetAllBasic();
List<OwnedCardEntry> ownedCards = viewer.Cards;
List<OwnedCardEntry> allCardsAsOwned = allCollectibleCards.GroupJoin(ownedCards, card => card.Id,
ownedCard => ownedCard.Card.Id,
(card, foundOwnedCards) =>
{
OwnedCardEntry ownedCard = foundOwnedCards.DefaultIfEmpty().FirstOrDefault() ?? new OwnedCardEntry
{
Card = card,
Count = 0,
IsProtected = false
};
return ownedCard;
}).ToList();
allCardsAsOwned = allCardsAsOwned.Union(allBasicCards.Select(bc => new OwnedCardEntry
{
Card = bc,
Count = 3,
IsProtected = true
})).ToList();
List<LeaderSkinEntry> allLeaderSkins = await _collectionRepository.GetLeaderSkins();
Dictionary<string, ClassExp> classExp = new Dictionary<string, ClassExp>();
var classExpCurve = await _globalsRepository.GetClassExpCurve();
List<ClassExp> classExps = new List<ClassExp>();
int accumulateExp = 0;
int? prevNecessaryExp = null;
foreach (var entry in classExpCurve)
{
accumulateExp += entry.NecessaryExp;
classExps.Add(new ClassExp
{
Level = entry.Id, // You need to specify the level value based on your logic
NecessaryExp = entry.NecessaryExp,
DiffExp = prevNecessaryExp.HasValue ? entry.NecessaryExp - prevNecessaryExp.Value : entry.NecessaryExp,
AccumulateExp = accumulateExp
});
prevNecessaryExp = entry.NecessaryExp;
}
return new IndexResponse
{
UserTutorial = new UserTutorial()
UserTutorial = new UserTutorial
{
TutorialStep = viewer.MissionData.TutorialState
},
UserInfo = new UserInfo(int.Parse(Request.Headers["DEVICE"].FirstOrDefault()), viewer),
UserCurrency = new UserCurrency(),
UserCurrency = new UserCurrency(viewer),
UserItems = viewer.Items.Select(item => new UserItem(item)).ToList(),
UserRotationDecks = new UserFormatDeckInfo
{
UserDecks = viewer.Decks.Where(deck => deck.Format == Format.Rotation).Select(deck => new UserDeck(deck)).ToList()
},
UserUnlimitedDecks = new UserFormatDeckInfo
{
UserDecks = viewer.Decks.Where(deck => deck.Format == Format.Unlimited).Select(deck => new UserDeck(deck)).ToList()
},
UserMyRotationDecks = new UserFormatDeckInfo
{
UserDecks = viewer.Decks.Where(deck => deck.Format == Format.MyRotation).Select(deck => new UserDeck(deck)).ToList()
},
UserCards = allCardsAsOwned.Select(card => new UserCard(card)).ToList(),
UserClasses = viewer.Classes.Select(viewerClass => new UserClass(viewerClass)).ToList(),
Sleeves = viewer.Sleeves.ToDictionary(sleeve => sleeve.Id.ToString(), sleeve => new SleeveIdentifier { SleeveId = sleeve.Id }),
UserEmblems = viewer.Emblems.Select(emblem => new EmblemIdentifier { EmblemId = emblem.Id }).ToList(),
UserDegrees = viewer.Degrees.Select(degree => new DegreeIdentifier { DegreeId = degree.Id }).ToList(),
LeaderSkins = allLeaderSkins.ToDictionary(skin => skin.Id.ToString(), skin => new UserLeaderSkin(skin, viewer.LeaderSkins.Any(vs => vs.Id == skin.Id))),
MyPageBackgrounds = viewer.MyPageBackgrounds.Select(mpbg => mpbg.Id).ToList(),
LootBoxRegulations = new LootBoxRegulations(),
GatheringInfo = new GatheringInfo(),
IsBattlePassPeriod = false,
BattlePassLevelInfo = null,
SpecialCrystalInfos = new List<SpecialCrystalInfo>(),
AvatarRotationInfo = null,
MyRotationInfo = null,
FeatureMaintenances = new List<FeatureMaintenance>(),
PreReleaseInfo = null,
SpotCards = new Dictionary<string, int>(),
ReprintedCards = new Dictionary<string, long>(),
UnlimitedBanList = new Dictionary<string, int>(),
LoadingTipCardExclusions = new List<long>(),
MaintenanceCards = new List<CardIdentifier>(),
RedEtherOverrides = new List<RedEtherOverride>(),
DailyLoginBonus = new DailyLoginBonus(),
UserRankedMatches = new List<UserRankedMatches>(),
UserRankInfo = new Dictionary<string, UserRankInfo>(),
ArenaConfig = new ArenaConfig(),
ArenaInfos = new List<ArenaInfo>(),
RotationSets = (await _cardRepository.GetCardSets(true)).Select(set => new CardSetIdentifier { SetId = set.Id }).ToList(),
UserConfig = new UserConfig(),
OpenBattlefieldIds = (await _globalsRepository.GetBattlefields(true)).ToDictionary(bf => bf.Id.ToString(), bf => bf.Id),
DefaultSettings = new DefaultSettings(await _globalsRepository.GetGameConfiguration("default")),
ClassExp = classExps.ToDictionary(kv => kv.Level.ToString(), kv => kv),
RankInfo = (await _globalsRepository.GetRankInfo()).Select(ri => new RankInfo(ri)).ToDictionary(ri => ri.RankId.ToString(), ri => ri)
};
}
}