diff --git a/SysBot.Pokemon/Helpers/AutoLegalityWrapper.cs b/SysBot.Pokemon/Helpers/AutoLegalityWrapper.cs index ca089591..7d03afd2 100644 --- a/SysBot.Pokemon/Helpers/AutoLegalityWrapper.cs +++ b/SysBot.Pokemon/Helpers/AutoLegalityWrapper.cs @@ -3,6 +3,7 @@ using System; using System.IO; using System.Linq; +using System.Runtime.ConstrainedExecution; using System.Threading; namespace SysBot.Pokemon; @@ -40,7 +41,13 @@ private static void InitializeSettings(LegalitySettings cfg) APILegality.AllowTrainerOverride = cfg.AllowTrainerDataOverride; APILegality.AllowBatchCommands = cfg.AllowBatchCommands; APILegality.PrioritizeGame = cfg.PrioritizeGame; - APILegality.PrioritizeGameVersion = cfg.PrioritizeGameVersion; + GameVersion[] validVersions = [.. Enum.GetValues().Where(ver => ver <= (GameVersion)51 && ver > GameVersion.Any)]; + foreach (var ver in validVersions) + { + if (!cfg.PriorityOrder.Contains(ver)) + cfg.PriorityOrder.Add(ver); + } + APILegality.PriorityOrder = cfg.PriorityOrder; APILegality.SetBattleVersion = cfg.SetBattleVersion; APILegality.Timeout = cfg.Timeout; var settings = ParseSettings.Settings; @@ -78,6 +85,7 @@ private static void InitializeTrainerDatabase(LegalitySettings cfg) RegisterIfNoneExist(fallback, 7, GameVersion.GP); RegisterIfNoneExist(fallback, 7, GameVersion.GE); } + private static SimpleTrainerInfo GetDefaultTrainer(LegalitySettings cfg) { var OT = cfg.GenerateOT; @@ -93,6 +101,7 @@ private static SimpleTrainerInfo GetDefaultTrainer(LegalitySettings cfg) }; return fallback; } + private static void RegisterIfNoneExist(SimpleTrainerInfo fallback, byte generation, GameVersion version) { fallback = new SimpleTrainerInfo(version) @@ -107,6 +116,7 @@ private static void RegisterIfNoneExist(SimpleTrainerInfo fallback, byte generat if (exist is SimpleTrainerInfo) // not anything from files; this assumes ALM returns SimpleTrainerInfo for non-user-provided fake templates. TrainerSettings.Register(fallback); } + private static void InitializeCoreStrings() { var lang = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName[..2]; @@ -162,9 +172,9 @@ public static PKM GetLegal(this ITrainerInfo sav, IBattleTemplate set, out strin var result = sav.GetLegalFromSet(set); res = result.Status switch { - LegalizationResult.Regenerated => "Regenerated", - LegalizationResult.Failed => "Failed", - LegalizationResult.Timeout => "Timeout", + LegalizationResult.Regenerated => "Regenerated", + LegalizationResult.Failed => "Failed", + LegalizationResult.Timeout => "Timeout", LegalizationResult.VersionMismatch => "VersionMismatch", _ => "", }; @@ -172,6 +182,8 @@ public static PKM GetLegal(this ITrainerInfo sav, IBattleTemplate set, out strin } public static string GetLegalizationHint(IBattleTemplate set, ITrainerInfo sav, PKM pk) => set.SetAnalysis(sav, pk); + public static PKM LegalizePokemon(this PKM pk) => pk.Legalize(); + public static IBattleTemplate GetTemplate(ShowdownSet set) => new RegenTemplate(set); } diff --git a/SysBot.Pokemon/Settings/LegalitySettings.cs b/SysBot.Pokemon/Settings/LegalitySettings.cs index f96f4b0b..f648bd24 100644 --- a/SysBot.Pokemon/Settings/LegalitySettings.cs +++ b/SysBot.Pokemon/Settings/LegalitySettings.cs @@ -1,6 +1,8 @@ using PKHeX.Core; +using System; using System.Collections.Generic; using System.ComponentModel; +using System.Linq; namespace SysBot.Pokemon; @@ -9,6 +11,7 @@ public class LegalitySettings private string DefaultTrainerName = "SysBot"; private const string Generate = nameof(Generate); private const string Misc = nameof(Misc); + public override string ToString() => "Legality Generating Settings"; // Generate @@ -42,10 +45,10 @@ public string GenerateOT public byte GenerateGenderOT { get; set; } = 0; [Category(Generate), Description("If PrioritizeGame is set to \"True\", uses PrioritizeGameVersion to start looking for encounters. If \"False\", uses newest game as the version. It is recommended to leave this as \"True\".")] - public bool PrioritizeGame { get; set; } = true; + public bool PrioritizeGame { get; set; } = false; - [Category(Generate), Description("Specifies the first game to use to generate encounters, or current game if this field is set to \"Any\". Set PrioritizeGame to \"true\" to enable. It is recommended to leave this as \"Any\".")] - public GameVersion PrioritizeGameVersion { get; set; } = GameVersion.Any; + [Category(Generate), Description("The order of GameVersions ALM will attempt to legalize from.")] + public List PriorityOrder { get; set; } = [.. Enum.GetValues().Where(ver => ver > GameVersion.Any && ver <= (GameVersion)51)]; [Category(Generate), Description("Set all possible legal ribbons for any generated Pokémon.")] public bool SetAllLegalRibbons { get; set; } @@ -64,7 +67,7 @@ public string GenerateOT [Category(Generate), Description("Prevents trading Pokémon that require a HOME Tracker, even if the file has one already."), DisplayName("Disallow Non-Native Pokémon")] public bool DisallowNonNatives { get; set; } = false; - + [Category(Generate), Description("Prevents trading Pokémon that already have a HOME Tracker."), DisplayName("Disallow Home Tracked Pokémon")] public bool DisallowTracked { get; set; } = false; diff --git a/SysBot.Pokemon/deps/PKHeX.Core.AutoMod.dll b/SysBot.Pokemon/deps/PKHeX.Core.AutoMod.dll index ac3b2972..e3c6c2db 100644 Binary files a/SysBot.Pokemon/deps/PKHeX.Core.AutoMod.dll and b/SysBot.Pokemon/deps/PKHeX.Core.AutoMod.dll differ diff --git a/SysBot.Pokemon/deps/PKHeX.Core.dll b/SysBot.Pokemon/deps/PKHeX.Core.dll index 076b7aca..22c56fc9 100644 Binary files a/SysBot.Pokemon/deps/PKHeX.Core.dll and b/SysBot.Pokemon/deps/PKHeX.Core.dll differ