mlaumcherb/Mlaumcherb.Client.Avalonia/классы/Буржуазия/GameVersionCatalog.cs

55 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace Mlaumcherb.Client.Avalonia.классы;
public record VersionSearchParams
{
public bool ReleaseTypeAllowed;
public bool SnapshotTypeAllowed;
public bool OldTypeAllowed;
public bool OtherTypeAllowed;
}
public class GameVersionCatalog
{
[JsonRequired] public List<RemoteVersionDescriptorProps> versions { get; set; } = new();
/// <returns>empty list if couldn't find any remote versions</returns>
public List<RemoteVersionDescriptorProps> GetDownloadableVersions(VersionSearchParams p)
{
var _versionPropsList = new List<RemoteVersionDescriptorProps>();
foreach (var r in versions)
{
bool match = r.type switch
{
"release" => p.ReleaseTypeAllowed,
"snapshot" => p.SnapshotTypeAllowed,
"old_alpha" or "old_beta" => p.OldTypeAllowed,
_ => p.OtherTypeAllowed
};
if(match)
_versionPropsList.Add(r);
}
return _versionPropsList;
}
}
public class AssetProperties
{
[JsonRequired] public string hash { get; set; } = "";
[JsonRequired] public int size { get; set; }
}
public class AssetIndex
{
[JsonRequired] public Dictionary<string, AssetProperties> objects { get; set; } = new();
}
public class RemoteVersionDescriptorProps
{
[JsonRequired] public string id { get; set; } = "";
[JsonRequired] public string url { get; set; } = "";
[JsonRequired] public string type { get; set; } = "";
public string sha1 { get; set; } = "";
public DateTime time { get; set; }
public DateTime releaseTime { get; set; }
}