Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add opcode.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 27, 2024
1 parent 3bafba6 commit 3016cef
Show file tree
Hide file tree
Showing 8 changed files with 569 additions and 19 deletions.
4 changes: 3 additions & 1 deletion RotationSolver.Basic/Rotations/Duties/BozjaRotation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace RotationSolver.Basic.Rotations.Duties;
using ECommons.DalamudServices;

namespace RotationSolver.Basic.Rotations.Duties;

/// <summary>
/// The bozja action.
Expand Down
26 changes: 26 additions & 0 deletions RotationSolver.GameData/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Lumina;
using Lumina.Data;
using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json.Linq;
using RotationSolver.GameData;
using RotationSolver.GameData.Getters;
using RotationSolver.GameData.Getters.Actions;
using System.Net;
using System.Resources.NetStandard;

var gameData = new GameData("C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack", new LuminaOptions
Expand Down Expand Up @@ -89,6 +91,30 @@ namespace RotationSolver.Basic.Rotations.Basic;
.Select(job => new RotationGetter(gameData, job).GetCode());
res.AddResource("Rotation", header + string.Join("\n\n", rotations));

using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
using var result = await client.GetAsync("https://raw.githubusercontent.com/karashiiro/FFXIVOpcodes/master/opcodes.json");

if (result.StatusCode != HttpStatusCode.OK) return;
var responseStream = await result.Content.ReadAsStringAsync();


var strs = JToken.Parse(responseStream)[0]!["lists"]!.Children()
.SelectMany(i => i.Children()).SelectMany(i => i.Children()).Cast<JObject>()
.Select(i =>
{
var name = ((JValue)i["name"]!).Value as string;
var description = name!.Space();

return $$"""
/// <summary>
///{{description}}
/// </summary>
[Description("{{description}}")]
{{name}} = {{((JValue)i["opcode"]!).Value}},
""";
});
res.AddResource("OpCode", string.Join("\n", strs));

res.Generate();

Console.WriteLine("Finished!");
3 changes: 2 additions & 1 deletion RotationSolver.GameData/RotationSolver.GameData.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -9,6 +9,7 @@

<ItemGroup>
<PackageReference Include="Lumina.Excel" Version="6.5.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="ResXResourceReader.NetStandard" Version="1.2.0" />
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions RotationSolver.GameData/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ public static bool IsSingleJobForCombat(this ClassJobCategory jobCategory)

public static string Table(this string str) => " " + str.Replace("\n", "\n ");

public static string Space(this string str)
{
string result = string.Empty;

bool lower = false;
foreach (var c in str)
{
var isLower = char.IsLower(c);
if (lower && !isLower)
{
result += ' ';
}
lower = isLower;
result += c;
}

return result;
}

public static string OnlyAscii(this string input) => new(input.Where(char.IsAscii).ToArray());

public static string ToPascalCase(this string input)
Expand Down
68 changes: 53 additions & 15 deletions RotationSolver.SourceGenerators/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3016cef

Please sign in to comment.