Esempio n. 1
0
        internal static IModInfo ToModInfo(this BeatModsEntry entry, JsonSerializerOptions jsonOptions = null)
        {
            var info = new ModInfo {
                GameId      = "beatsaber",
                FileVersion = entry.Version,
                // SourceUrl = new Uri($"https://beatmods.com/api/v1/mod/{entry.DocumentId}"),
                SourceUrl       = new Uri($"https://beatmods.com{entry.Downloads.First().Url}"),
                Source          = "beatmods",
                FileName        = System.IO.Path.GetFileName(entry.Downloads.First().Url),
                LogicalFileName = entry.Name,
                Expires         = DateTime.UtcNow.AddHours(24).Ticks,
                Details         = new ModDetails {
                    Author      = entry.Author.UserName,
                    Category    = entry.Category,
                    Description = entry.Description,
                    FileId      = entry.DocumentId,
                    HomePage    = entry.Link.ToString(),
                }
            };

            if (entry.Dependencies.Any(e => e.TryGetProperty("name", out _)))
            {
                info.Rules = entry.Dependencies.Select(e => JsonSerializer.Deserialize <BeatModsEntry>(e.GetRawText(), jsonOptions ?? GetJsonOptions())).Select(d => {
                    return(new BasicRule {
                        Reference = new BeatModsModReference(d.Name, d.Version), Type = RuleType.Requires
                    });
                }).Cast <IRule>().ToList();
            }
            return(info);
        }
Esempio n. 2
0
 internal static bool MatchesVersion(this BeatModsEntry m, VersionMatch version)
 {
     return(((Range)version).IsSatisfied(m.Version));
 }
Esempio n. 3
0
 public BeatModsLookupResult(BeatModsEntry e)
 {
     ResultId = e.DocumentId;
     ModInfo  = e.ToModInfo();
 }