From f54bc7bf6fa665688c27e807544dabb3bf1f022a Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 8 Dec 2019 17:52:17 -0800 Subject: [PATCH] Batch editor updates .PID=$shiny0 will do squares anything else will do stars .RelearnMoves=$suggestAll will give ALL TR moves, not just the ones for its current movepool. .Ribbons=$suggest will give all valid ribbons .Ribbons=$suggestNone will remove all ribbons (except required ones like event ribbons) Closes #2568 --- PKHeX.Core/Editing/Bulk/BatchEditing.cs | 27 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/Editing/Bulk/BatchEditing.cs b/PKHeX.Core/Editing/Bulk/BatchEditing.cs index ed22008ea..41125d27a 100644 --- a/PKHeX.Core/Editing/Bulk/BatchEditing.cs +++ b/PKHeX.Core/Editing/Bulk/BatchEditing.cs @@ -23,7 +23,7 @@ public static class BatchEditing typeof (PK2), typeof (PK1), }; - public static readonly string[] CustomProperties = { PROP_LEGAL }; + public static readonly string[] CustomProperties = { PROP_LEGAL, PROP_RIBBONS }; public static readonly string[][] Properties = GetPropArray(); private static readonly Dictionary[] Props = Types.Select(z => ReflectUtil.GetAllPropertyInfoPublic(z) @@ -36,6 +36,7 @@ public static class BatchEditing private const string CONST_BYTES = "$[]"; private const string PROP_LEGAL = "Legal"; + private const string PROP_RIBBONS = "Ribbons"; private const string IdentifierContains = nameof(PKM.Identifier) + "Contains"; private static string[][] GetPropArray() @@ -247,8 +248,8 @@ private static ModifyResult SetPKMProperty(StringInstruction cmd, PKMInfo info, if (cmd.PropertyValue.StartsWith(CONST_BYTES)) return SetByteArrayProperty(pk, cmd); - if (cmd.PropertyValue == CONST_SUGGEST) - return SetSuggestedPKMProperty(cmd.PropertyName, info); + if (cmd.PropertyValue.StartsWith(CONST_SUGGEST)) + return SetSuggestedPKMProperty(cmd.PropertyName, info, cmd.PropertyValue); if (cmd.PropertyValue == CONST_RAND && cmd.PropertyName == nameof(PKM.Moves)) return SetMoves(pk, pk.GetMoveSet(info.Legality, true)); @@ -348,8 +349,11 @@ private static bool IsLegalFiltered(StringInstruction cmd, Func isLegal) /// /// Property to modify. /// Cached info storing Legal data. - private static ModifyResult SetSuggestedPKMProperty(string name, PKMInfo info) + /// Suggestion string which starts with + private static ModifyResult SetSuggestedPKMProperty(string name, PKMInfo info, string propValue) { + bool isAll() => propValue.EndsWith("All", true, CultureInfo.CurrentCulture); + bool isNone() => propValue.EndsWith("None", true, CultureInfo.CurrentCulture); var pk = info.Entity; switch (name) { @@ -380,10 +384,19 @@ private static ModifyResult SetSuggestedPKMProperty(string name, PKMInfo info) if (pk.Format >= 8) { pk.ClearRecordFlags(); - pk.SetRecordFlags(pk.Moves); + if (isAll()) + pk.SetRecordFlags(); // all + else if (!isNone()) + pk.SetRecordFlags(pk.Moves); // whatever fit the current moves } pk.SetRelearnMoves(info.SuggestedRelearn); return ModifyResult.Modified; + case PROP_RIBBONS: + if (isNone()) + RibbonApplicator.RemoveAllValidRibbons(pk); + else // All + RibbonApplicator.SetAllValidRibbons(pk); + return ModifyResult.Modified; case nameof(PKM.Met_Location): var encounter = info.SuggestedEncounter; if (encounter == null) @@ -465,8 +478,8 @@ private static bool SetComplexProperty(PKM pk, StringInstruction cmd) pk.SetPIDGender(pk.Gender); else if (cmd.PropertyName == nameof(PKM.EncryptionConstant) && cmd.PropertyValue == nameof(PKM.PID)) pk.EncryptionConstant = pk.PID; - else if (cmd.PropertyName == nameof(PKM.PID) && cmd.PropertyValue == CONST_SHINY) - pk.SetShiny(); + else if (cmd.PropertyName == nameof(PKM.PID) && cmd.PropertyValue.StartsWith(CONST_SHINY)) + CommonEdits.SetShiny(pk, cmd.PropertyValue.EndsWith("0")); else if (cmd.PropertyName == nameof(PKM.Species) && cmd.PropertyValue == "0") Array.Clear(pk.Data, 0, pk.Data.Length); else if (cmd.PropertyName.StartsWith("IV") && cmd.PropertyValue == CONST_RAND)