using System; using System.Linq; using Lumafly.Services; namespace Lumafly.Models; /// /// A record to represent a pack of mods /// [Serializable] public record Pack(string Name, string Description, string Authors, InstalledMods InstalledMods) { /// /// A list of the names of the mods in the profile. /// public InstalledMods InstalledMods { get; set; } = InstalledMods; /// /// The name of the pack /// public string Name { get; set; } = Name; /// /// The description of the pack /// public string Description { get; set; } = Description; /// /// The description of the pack /// public string Authors { get; set; } = Authors; public string? SharingCode { get; set; } public bool HasSharingCode => !string.IsNullOrEmpty(SharingCode); public string ModList => InstalledMods.Mods.Keys .Concat(InstalledMods.NotInModlinksMods.Keys.Select(x => $"{x} ({Resources.MVVM_NotInModlinks_Disclaimer})")) .Aggregate("", (x, y) => x + y + "\n"); public Pack DeepCopy() => new(Name, Description, Authors, InstalledMods.DeepCopy()); public void Copy(Pack pack) { Name = pack.Name; Description = pack.Description; Authors = pack.Authors; SharingCode = pack.SharingCode; InstalledMods = pack.InstalledMods; } public bool IsSame(Pack pack) { return Name == pack.Name && Description == pack.Description && Authors == pack.Authors && ( InstalledMods.Mods.All(x => pack.InstalledMods.Mods.ContainsKey(x.Key) && pack.InstalledMods.Mods[x.Key] == x.Value) && InstalledMods.NotInModlinksMods.All(x => pack.InstalledMods.NotInModlinksMods.ContainsKey(x.Key) && pack.InstalledMods.NotInModlinksMods[x.Key] == x.Value) ); } }