Skip to content

Commit

Permalink
Utilities: WowheadDB_Extractor: Set Central package management - Upda…
Browse files Browse the repository at this point in the history
…te NugetPackages
  • Loading branch information
Xian55 committed Sep 9, 2024
1 parent 2f15377 commit 4d27958
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
10 changes: 10 additions & 0 deletions Utilities/WowheadDB_Extractor/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.8" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Utilities/WowheadDB_Extractor/PerZoneGatherable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task<int[]> Run()
Console.WriteLine($" - {nameof(PerZoneGatherable)}\n {e}");
}

return Array.Empty<int>();
return [];
}


Expand Down
9 changes: 4 additions & 5 deletions Utilities/WowheadDB_Extractor/WowheadDB_Extractor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.Drawing.Common" />
</ItemGroup>

<ItemGroup>
<Reference Include="WowheadDB">
<HintPath>..\..\WowheadDB\bin\Release\net8.0\WowheadDB.dll</HintPath>
<HintPath>..\..\WowheadDB\bin\Release\net9.0\WowheadDB.dll</HintPath>
</Reference>
<Reference Include="SharedLib">
<HintPath>..\..\SharedLib\bin\Release\net8.0\SharedLib.dll</HintPath>
<HintPath>..\..\SharedLib\bin\Release\net9.0\SharedLib.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
45 changes: 21 additions & 24 deletions Utilities/WowheadDB_Extractor/ZoneExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Linq;
using SharedLib;

using static System.Diagnostics.Stopwatch;

namespace WowheadDB_Extractor
{
public class ZoneExtractor
Expand All @@ -20,20 +22,14 @@ public class ZoneExtractor

public static string BaseUrl()
{
switch (EXP)
return EXP switch
{
case "som":
return "https://classic.wowhead.com";
case "tbc":
return "https://tbc.wowhead.com";
case "wrath":
return "https://www.wowhead.com/wotlk";
case "cata":
return "https://www.wowhead.com/cata";
default:
case "retail":
return RetailUrl;
}
"som" => "https://classic.wowhead.com",
"tbc" => "https://tbc.wowhead.com",
"wrath" => "https://www.wowhead.com/wotlk",
"cata" => "https://www.wowhead.com/cata",
_ => RetailUrl,
};
}

private const string parentPath = $"../../../../../Json";
Expand Down Expand Up @@ -94,13 +90,13 @@ static async Task ExtractZones()

try
{
//var p = GetPayloadFromWebpage(await LoadPage(entry.Value));
//string baseUrl = BaseUrl();
string p;
string baseUrl;
var p = GetPayloadFromWebpage(await LoadPage(entry.Value));
string baseUrl = BaseUrl();
//string p;
//string baseUrl;

// empty then fall back to retail
//if (p == "[]")
if (p == "[]")
{
var url = GetRetailZoneUrl() + entry.Value;

Expand All @@ -127,6 +123,8 @@ static async Task ExtractZones()
z.salvegable = await salv.Run();

SaveZone(z, entry.Value.ToString());

// TSP generation
//SaveZoneNode(entry, z.herb, nameof(z.herb), false, true);
//SaveZoneNode(entry, z.vein, nameof(z.vein), false, true);

Expand Down Expand Up @@ -181,21 +179,20 @@ static void SaveZoneNode(KeyValuePair<string, int> zonekvp, Dictionary<string, L
if (nodes == null)
return;

List<Vector2> points = new();
List<Vector2> points = [];
foreach (var kvp in nodes)
{
points.AddRange(Array.ConvertAll(kvp.Value[0].MapCoords.ToArray(), (Vector3 v3) => new Vector2(v3.X, v3.Y)));
points.AddRange(Array.ConvertAll([.. kvp.Value[0].MapCoords], (Vector3 v3) => new Vector2(v3.X, v3.Y)));
}

GeneticTSPSolver solver = new(points);
Stopwatch sw = new();
sw.Start();
long startTime = GetTimestamp();
while (solver.UnchangedGens < solver.Length)
{
solver.Evolve();
}
sw.Stop();
Console.WriteLine($" - TSP Solver {points.Count} {type} nodes {sw.ElapsedMilliseconds} ms");
var elapsed = GetElapsedTime(startTime);
Console.WriteLine($" - TSP Solver {points.Count} {type} nodes {elapsed.TotalMilliseconds} ms");

string prefix = $"{zonekvp.Value}_{zonekvp.Key}_{type}";

Expand Down

0 comments on commit 4d27958

Please sign in to comment.