namespace Млаумчерб.Клиент.классы; public class GameVersionProps : IComparable, IEquatable { public string Name { get; } public IOPath LocalDescriptorPath { get; } public string? RemoteDescriptorUrl { get; } private bool _isDownloaded; public bool IsDownloaded { get => _isDownloaded; set { bool downloadCompleted = value && !_isDownloaded; _isDownloaded = value; if(downloadCompleted) OnDownloadCompleted?.Invoke(); } } public event Action? OnDownloadCompleted; public GameVersionProps(string name, string? url, IOPath descriptorPath) { Name = name; LocalDescriptorPath = descriptorPath; RemoteDescriptorUrl = url; IsDownloaded = File.Exists(Пути.GetVersionJarFilePath(name)); } public GameVersionProps(string name, string? url) : this(name, url, Пути.GetVersionDescriptorPath(name)) { } public override string ToString() => Name; public override int GetHashCode() => Name.GetHashCode(); public int CompareTo(GameVersionProps? other) { if (ReferenceEquals(this, other)) return 0; if (other is null) return 1; if (Version.TryParse(Name, out var version1) && Version.TryParse(other.Name, out var version2)) { return version1.CompareTo(version2); } return String.Compare(Name, other.Name, StringComparison.InvariantCulture); } public bool Equals(GameVersionProps? other) { if (other is null) return false; if (ReferenceEquals(this, other)) return true; return Name == other.Name; } public override bool Equals(object? obj) { if (obj is GameVersionProps other) return Equals(other); if (ReferenceEquals(this, obj)) return true; return false; } }