Seeding reorg

This commit is contained in:
gamer147
2026-05-24 21:13:15 -04:00
parent 34bcc579a5
commit c14408ba06
73 changed files with 4611 additions and 369716 deletions

View File

@@ -1,20 +1,22 @@
using Microsoft.EntityFrameworkCore;
using SVSim.Database.Enums;
using SVSim.Database.Models;
using SVSim.Database.Repositories.Card;
using SVSim.Database.Repositories.Globals;
using SVSim.Database.Models.Config;
using SVSim.Database.Services;
namespace SVSim.Database.Repositories.Viewer;
public class ViewerRepository : IViewerRepository
{
protected readonly SVSimDbContext _dbContext;
private readonly IGameConfigService _config;
private const int MaxFriends = 20;
public ViewerRepository(SVSimDbContext dbContext)
public ViewerRepository(SVSimDbContext dbContext, IGameConfigService config)
{
_dbContext = dbContext;
_config = config;
}
public async Task<Models.Viewer?> GetViewerBySocialConnection(SocialAccountType accountType, ulong socialId)
@@ -73,7 +75,9 @@ public class ViewerRepository : IViewerRepository
{
DisplayName = displayName
};
GameConfiguration gameConfig = await new GlobalsRepository(_dbContext).GetGameConfiguration("default");
var player = _config.Get<PlayerConfig>();
var grants = _config.Get<DefaultGrantsConfig>();
var loadout = _config.Get<DefaultLoadoutConfig>();
viewer.SocialAccountConnections.Add(new SocialAccountConnection
{
@@ -81,13 +85,12 @@ public class ViewerRepository : IViewerRepository
AccountType = socialType
});
// TODO: fixed in Task 7 — reads via Config tree after RefactorGameConfigurationToJsonb
viewer.Info.MaxFriends = gameConfig.Config.Player.MaxFriends;
viewer.Info.MaxFriends = player.MaxFriends;
viewer.Info.CountryCode = "KOR";
viewer.Info.BirthDate = DateTime.UtcNow;
viewer.Currency.Crystals = gameConfig.Config.DefaultGrants.Crystals;
viewer.Currency.Rupees = gameConfig.Config.DefaultGrants.Rupees;
viewer.Currency.RedEther = gameConfig.Config.DefaultGrants.Ether;
viewer.Currency.Crystals = grants.Crystals;
viewer.Currency.Rupees = grants.Rupees;
viewer.Currency.RedEther = grants.Ether;
viewer.MissionData.TutorialState = 100; // finishes tutorial for now
// Load classes WITH their LeaderSkins — DefaultLeaderSkin iterates the nav collection
@@ -108,11 +111,10 @@ public class ViewerRepository : IViewerRepository
};
}).ToList();
// TODO: fixed in Task 7 — load cosmetics by ID from Config.DefaultLoadout after RefactorGameConfigurationToJsonb
var defaultSleeveId = gameConfig.Config.DefaultLoadout.SleeveId;
var defaultDegreeId = gameConfig.Config.DefaultLoadout.DegreeId;
var defaultEmblemId = gameConfig.Config.DefaultLoadout.EmblemId;
var defaultBgId = gameConfig.Config.DefaultLoadout.MyPageBackgroundId;
var defaultSleeveId = loadout.SleeveId;
var defaultDegreeId = loadout.DegreeId;
var defaultEmblemId = loadout.EmblemId;
var defaultBgId = loadout.MyPageBackgroundId;
var defaultSleeve = await _dbContext.Set<SleeveEntry>().FindAsync(defaultSleeveId);
var defaultDegree = await _dbContext.Set<DegreeEntry>().FindAsync(defaultDegreeId);
var defaultEmblem = await _dbContext.Set<EmblemEntry>().FindAsync(defaultEmblemId);