Fix EV yield bit ordering

oopsies

https://github.com/kwsch/PKHeX/issues/4252

also includes a minor clean for TextVariableCode
This commit is contained in:
Kurt 2024-04-22 13:19:03 -05:00
parent 95d0937fd8
commit dcf6b0043b
3 changed files with 4 additions and 15 deletions

View File

@ -6,5 +6,5 @@ namespace pkNX.Structures.FlatBuffers.SV;
public partial class PersonalInfoStats
{
public ushort U16() => (ushort)((HP & 0b11) | ((ATK & 0b11) << 2) | ((DEF & 0b11) << 4) | ((SPA & 0b11) << 6) | ((SPD & 0b11) << 8) | ((SPE & 0b11) << 10));
public ushort U16() => (ushort)((HP & 0b11) | ((ATK & 0b11) << 2) | ((DEF & 0b11) << 4) | ((SPE & 0b11) << 6) | ((SPA & 0b11) << 8) | ((SPD & 0b11) << 10));
}

View File

@ -17,7 +17,7 @@ public class TextConfig(GameVersion game)
public IEnumerable<string> GetVariableList() => Variables.Select(z => $"{z.Code:X4}={z.Name}");
private TextVariableCode? GetCode(string name) => Array.Find(Variables, v => v.Name == name);
private TextVariableCode? GetName(int value) => Array.Find(Variables, v => v.Code == value);
private TextVariableCode? GetName(ushort value) => Array.Find(Variables, v => v.Code == value);
/// <summary>
/// Gets the machine-friendly variable instruction code to be written to the data.
@ -27,7 +27,7 @@ public ushort GetVariableNumber(string variable)
{
var v = GetCode(variable);
if (v != null)
return (ushort)v.Code;
return v.Code;
if (ushort.TryParse(variable.TrimStart(_trim_hex), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result))
return result;
throw new ArgumentException($"Variable parse error: {variable}. Expected a hexadecimal value or standard variable code.");

View File

@ -1,18 +1,7 @@
using System;
namespace pkNX.Structures;
public sealed class TextVariableCode
public sealed record TextVariableCode(ushort Code, string Name)
{
public readonly string Name;
public readonly int Code;
private TextVariableCode(int code, string name)
{
Code = code;
Name = name;
}
public static TextVariableCode[] GetVariables(GameVersion game)
{
if (game == GameVersion.Any)