Files
SVSimServer/SVSim.Database/Models/Viewer.cs
gamer147 ee808a60a2 feat(viewer): add MyPageBgSelectType + MyPageBgId scalars + MyPageBgRotation owned collection
Adds BGType persistence (0=Deck/1=CustomBG/2=RandomBG) to Viewer via two scalar
columns and an owned collection keyed (ViewerId, Slot). Two persistence tests
confirm round-trip and zero-defaults on fresh viewers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 16:26:48 -04:00

97 lines
3.5 KiB
C#

using System.ComponentModel.DataAnnotations.Schema;
using SVSim.Database.Common;
using Microsoft.EntityFrameworkCore;
namespace SVSim.Database.Models;
/// <summary>
/// A user within the game system.
/// </summary>
[Index(nameof(ShortUdid))]
[Index(nameof(Udid), IsUnique = true)]
public class Viewer : BaseEntity<long>
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; }
/// <summary>
/// This user's name displayed in game.
/// </summary>
public string DisplayName { get; set; } = String.Empty;
/// <summary>
/// This user's short identifier.
/// </summary>
public long ShortUdid { get; set; }
/// <summary>
/// The client's full UDID (AES key for the wire protocol). Set when the viewer is created
/// via <c>/tool/signup</c>; null for viewers created via the admin Steam-import path. Unique
/// when present — the partial filter is declared in the migration.
/// </summary>
public Guid? Udid { get; set; }
public DateTime LastLogin { get; set; }
/// <summary>BGType enum: 0=Deck, 1=CustomBG, 2=RandomBG. Default 0 = follow equipped deck's leader skin.</summary>
public int MyPageBgSelectType { get; set; }
/// <summary>The single chosen MyPageBG cosmetic id, used when SelectType=CustomBG. 0 = none.</summary>
public int MyPageBgId { get; set; }
#region Owned
public ViewerInfo Info { get; set; } = new ViewerInfo();
public ViewerMissionData MissionData { get; set; } = new ViewerMissionData();
public ViewerCurrency Currency { get; set; } = new ViewerCurrency();
public List<ViewerClassData> Classes { get; set; } = new List<ViewerClassData>();
#endregion
#region Collection
public List<ShadowverseDeckEntry> Decks { get; set; } = new List<ShadowverseDeckEntry>();
public List<OwnedCardEntry> Cards { get; set; } = new List<OwnedCardEntry>();
public List<LeaderSkinEntry> LeaderSkins { get; set; } = new List<LeaderSkinEntry>();
public List<DegreeEntry> Degrees { get; set; } = new List<DegreeEntry>();
public List<EmblemEntry> Emblems { get; set; } = new List<EmblemEntry>();
public List<OwnedItemEntry> Items { get; set; } = new List<OwnedItemEntry>();
public List<SleeveEntry> Sleeves { get; set; } = new List<SleeveEntry>();
public List<MyPageBackgroundEntry> MyPageBackgrounds { get; set; } = new List<MyPageBackgroundEntry>();
public List<ViewerPackOpenCount> PackOpenCounts { get; set; } = new List<ViewerPackOpenCount>();
public List<ViewerFreePackClaim> FreePackClaims { get; set; } = new List<ViewerFreePackClaim>();
public List<MyPageBgRotationEntry> MyPageBgRotation { get; set; } = new List<MyPageBgRotationEntry>();
public List<ViewerGachaPointBalance> GachaPointBalances { get; set; } = new List<ViewerGachaPointBalance>();
public List<ViewerGachaPointReceived> GachaPointReceived { get; set; } = new List<ViewerGachaPointReceived>();
public List<ViewerBuildDeckProductPurchase> BuildDeckPurchases { get; set; } = new List<ViewerBuildDeckProductPurchase>();
public List<ViewerMission> Missions { get; set; } = new List<ViewerMission>();
public List<ViewerAchievement> Achievements { get; set; } = new List<ViewerAchievement>();
public List<ViewerEventCounter> EventCounters { get; set; } = new List<ViewerEventCounter>();
#endregion
#region Navigation Properties
public List<SocialAccountConnection> SocialAccountConnections { get; set; } = new List<SocialAccountConnection>();
#endregion
}