1
1
mirror of https://github.com/CyberL1/MyMcRealms.git synced 2024-12-23 21:08:22 -05:00

feat: compatibility check

This commit is contained in:
CyberL1 2024-04-21 12:49:07 +02:00
parent fbf2e8b9bb
commit 95e4a37cb0
3 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ using MyMcRealms.MyMcAPI.Responses;
using MyMcRealms.Requests;
using MyMcRealms.Responses;
using Newtonsoft.Json;
using Semver;
namespace MyMcRealms.Controllers
{
@ -38,7 +39,10 @@ namespace MyMcRealms.Controllers
foreach (var world in AllServers.Servers)
{
Console.WriteLine(world.ServerName);
int versionsCompared = SemVersion.Parse(gameVerision, SemVersionStyles.Strict).ComparePrecedenceTo(SemVersion.Parse(world.GameVersion, SemVersionStyles.Strict));
string isCompatible = versionsCompared == 0 ? "COMPATIBLE" : versionsCompared > 0 ? "NEEDS_DOWNGRADE" : "NEEDS_UPGRADE";
WorldResponse response = new()
{
Id = AllServers.Servers.IndexOf(world),
@ -58,7 +62,8 @@ namespace MyMcRealms.Controllers
DaysLeft = 0,
Expired = false,
ExpiredTrial = false,
Compatibility = world.GameVersion == gameVerision ? "COMPATIBLE" : "INCOMPATIBLE"
Compatibility = isCompatible,
ActiveVersion = world.GameVersion
};
allWorlds.Add(response);

View File

@ -16,6 +16,7 @@
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="Semver" Version="2.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

View File

@ -7,5 +7,6 @@
public bool Expired { get; set; } = false;
public bool ExpiredTrial { get; set; } = false;
public string Compatibility { get; set; } = string.Empty;
public string ActiveVersion { get; set; } = string.Empty;
}
}