Game version management

This commit is contained in:
2024-12-27 21:11:12 +05:00
parent 1f663902e2
commit cb85b132c3
17 changed files with 339 additions and 159 deletions

View File

@@ -1,8 +1,35 @@
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; } = null!;
/// <returns>empty list if couldn't find any remote versions</returns>
public List<GameVersionProps> GetDownloadableVersions(VersionSearchParams p)
{
var _versionPropsList = new List<GameVersionProps>();
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(new GameVersionProps(r.id, r.url));
}
return _versionPropsList;
}
}
public class AssetProperties
@@ -19,9 +46,9 @@ public class AssetIndex
public class RemoteVersionDescriptorProps
{
[JsonRequired] public string id { get; set; } = "";
[JsonRequired] public string type { get; set; } = "";
[JsonRequired] public string url { get; set; } = "";
[JsonRequired] public string sha1 { get; set; } = "";
[JsonRequired] public DateTime time { get; set; }
[JsonRequired] public DateTime releaseTime { get; set; }
[JsonRequired] public string type { get; set; } = "";
public string sha1 { get; set; } = "";
public DateTime time { get; set; }
public DateTime releaseTime { get; set; }
}

View File

@@ -10,10 +10,10 @@ public class GameVersionDescriptor
[JsonRequired] public DateTime releaseTime { get; set; }
[JsonRequired] public string type { get; set; } = "";
[JsonRequired] public string mainClass { get; set; } = "";
[JsonRequired] public Downloads downloads { get; set; } = null!;
[JsonRequired] public List<Library> libraries { get; set; } = null!;
[JsonRequired] public AssetIndexProperties assetIndex { get; set; } = null!;
[JsonRequired] public string assets { get; set; } = "";
public Downloads? downloads { get; set; } = null;
public JavaVersion javaVersion { get; set; } = new() { component = "jre-legacy", majorVersion = 8 };
public string? minecraftArguments { get; set; }
public ArgumentsNew? arguments { get; set; }