mirror of
https://github.com/CyberL1/MyMcRealms.git
synced 2024-11-21 13:38:21 -05:00
feat: compatibility check
This commit is contained in:
parent
fbf2e8b9bb
commit
95e4a37cb0
@ -8,6 +8,7 @@ using MyMcRealms.MyMcAPI.Responses;
|
|||||||
using MyMcRealms.Requests;
|
using MyMcRealms.Requests;
|
||||||
using MyMcRealms.Responses;
|
using MyMcRealms.Responses;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Semver;
|
||||||
|
|
||||||
namespace MyMcRealms.Controllers
|
namespace MyMcRealms.Controllers
|
||||||
{
|
{
|
||||||
@ -38,7 +39,10 @@ namespace MyMcRealms.Controllers
|
|||||||
|
|
||||||
foreach (var world in AllServers.Servers)
|
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()
|
WorldResponse response = new()
|
||||||
{
|
{
|
||||||
Id = AllServers.Servers.IndexOf(world),
|
Id = AllServers.Servers.IndexOf(world),
|
||||||
@ -58,7 +62,8 @@ namespace MyMcRealms.Controllers
|
|||||||
DaysLeft = 0,
|
DaysLeft = 0,
|
||||||
Expired = false,
|
Expired = false,
|
||||||
ExpiredTrial = false,
|
ExpiredTrial = false,
|
||||||
Compatibility = world.GameVersion == gameVerision ? "COMPATIBLE" : "INCOMPATIBLE"
|
Compatibility = isCompatible,
|
||||||
|
ActiveVersion = world.GameVersion
|
||||||
};
|
};
|
||||||
|
|
||||||
allWorlds.Add(response);
|
allWorlds.Add(response);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
|
||||||
|
<PackageReference Include="Semver" Version="2.3.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
public bool Expired { get; set; } = false;
|
public bool Expired { get; set; } = false;
|
||||||
public bool ExpiredTrial { get; set; } = false;
|
public bool ExpiredTrial { get; set; } = false;
|
||||||
public string Compatibility { get; set; } = string.Empty;
|
public string Compatibility { get; set; } = string.Empty;
|
||||||
|
public string ActiveVersion { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user