using Newtonsoft.Json; using StardewModdingAPI.Toolkit.Framework.Clients.Wiki; namespace StardewModdingAPI.Web.ViewModels { /// Metadata about a mod's compatibility with the latest versions of SMAPI and Stardew Valley. public class ModCompatibilityModel { /********* ** Accessors *********/ /// The compatibility status, as a string like "Broken". public string Status { get; } /// The human-readable summary, as an HTML block. public string? Summary { get; } /// The game or SMAPI version which broke this mod (if applicable). public string? BrokeIn { get; } /// A link to the unofficial version which fixes compatibility, if any. public ModLinkModel? UnofficialVersion { get; } /********* ** Public methods *********/ /// Construct an instance. /// The compatibility status, as a string like "Broken". /// The human-readable summary, as an HTML block. /// The game or SMAPI version which broke this mod (if applicable). /// A link to the unofficial version which fixes compatibility, if any. [JsonConstructor] public ModCompatibilityModel(string status, string? summary, string? brokeIn, ModLinkModel? unofficialVersion) { this.Status = status; this.Summary = summary; this.BrokeIn = brokeIn; this.UnofficialVersion = unofficialVersion; } /// Construct an instance. /// The mod metadata. public ModCompatibilityModel(WikiCompatibilityInfo info) { this.Status = info.Status.ToString(); this.Status = this.Status.Substring(0, 1).ToLower() + this.Status.Substring(1); this.Summary = info.Summary; this.BrokeIn = info.BrokeIn; if (info.UnofficialVersion != null) this.UnofficialVersion = new ModLinkModel(info.UnofficialUrl!, info.UnofficialVersion.ToString()); } } }