mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-02 08:49:18 +00:00
88830e0d00
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now. Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes. Adds functionality for Batch Editor commands to `>`, `<` and <=/>= TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants. Main window has a new layout to account for DPI scaling (8 point grid) Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724) Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720) Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714) Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691) Added: Properties for ribbon/mark count (closes #3659) Fixed: Traded SV eggs are now checked correctly (closes #3692)
68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
using System;
|
|
using static PKHeX.Core.RibbonParseFlags;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Stores info about if a ribbon is valid or not.
|
|
/// </summary>
|
|
public readonly record struct RibbonResult
|
|
{
|
|
// TWO BYTES USED
|
|
private readonly byte Value;
|
|
private readonly RibbonParseFlags Flags;
|
|
|
|
/// <summary>
|
|
/// True: ribbon is missing -- should have the ribbon.
|
|
/// False: ribbon is invalid -- should not have the ribbon.
|
|
/// </summary>
|
|
public bool IsMissing => (Flags & Missing) != 0;
|
|
|
|
private RibbonParseFlags Type => Flags & ~Missing;
|
|
|
|
public RibbonResult(RibbonIndex index, bool missing = false) { Value = (byte)index; Flags = missing ? MissingM : Mainline; }
|
|
public RibbonResult(RibbonIndex3 index, bool missing = false) { Value = (byte)index; Flags = missing ? Missing3 : Index3; }
|
|
public RibbonResult(RibbonIndex4 index, bool missing = false) { Value = (byte)index; Flags = missing ? Missing4 : Index4; }
|
|
public bool Equals(RibbonIndex index) => Type == Mainline && Value == (byte)index;
|
|
public bool Equals(RibbonIndex3 index) => Type == Index3 && Value == (byte)index;
|
|
public bool Equals(RibbonIndex4 index) => Type == Index4 && Value == (byte)index;
|
|
|
|
/// <summary>
|
|
/// Property Name that the ribbon can be get/set with, or looked up for localization.
|
|
/// </summary>
|
|
public string PropertyName => Type switch
|
|
{
|
|
Mainline => ((RibbonIndex)Value).GetPropertyName(),
|
|
Index3 => ((RibbonIndex3)Value).GetPropertyName(),
|
|
Index4 => ((RibbonIndex4)Value).GetPropertyName(),
|
|
_ => throw new ArgumentException($"Invalid type: {Type}"),
|
|
};
|
|
|
|
/// <summary>
|
|
/// Updates the ribbon state depending on the <see cref="args"/> and <see cref="IsMissing"/> state.
|
|
/// </summary>
|
|
public void Fix(RibbonVerifierArguments args)
|
|
{
|
|
switch (Type)
|
|
{
|
|
case Mainline: ((RibbonIndex)Value).Fix(args, IsMissing); break;
|
|
case Index3: ((RibbonIndex3)Value).Fix(args, IsMissing); break;
|
|
case Index4: ((RibbonIndex4)Value).Fix(args, IsMissing); break;
|
|
default: throw new ArgumentException($"Invalid type: {Type}");
|
|
}
|
|
}
|
|
}
|
|
|
|
[Flags]
|
|
public enum RibbonParseFlags : byte
|
|
{
|
|
None = 0,
|
|
Mainline,
|
|
Index3,
|
|
Index4,
|
|
|
|
Missing = 0x80,
|
|
MissingM = Missing | Mainline,
|
|
Missing3 = Missing | Index3,
|
|
Missing4 = Missing | Index4,
|
|
}
|