예제 #1
0
        /// <summary>
        /// Sets all ribbon flags according to a legality report.
        /// </summary>
        /// <param name="pk">Pokémon to modify</param>
        /// <param name="allValid">Set all valid ribbons only</param>
        public static void SetSuggestedRibbons(this PKM pk, IEncounterable enc, bool allValid = true)
        {
            if (allValid)
            {
                RibbonApplicator.SetAllValidRibbons(pk);
                if (pk is PK8 pk8 && pk8.Species != (int)Species.Shedinja && pk8.GetRandomValidMark(enc, out var mark))
                {
                    pk8.SetRibbonIndex(mark);
                }
            }
            string report = new LegalityAnalysis(pk).Report();

            if (report.Contains(string.Format(LegalityCheckStrings.LRibbonFMissing_0, "")))
            {
                var val            = string.Format(LegalityCheckStrings.LRibbonFMissing_0, "");
                var ribbonList     = GetRequiredRibbons(report, val);
                var missingRibbons = GetRibbonsRequired(pk, ribbonList);
                SetRibbonValues(pk, missingRibbons, 0, true);
            }
            if (report.Contains(string.Format(LegalityCheckStrings.LRibbonFInvalid_0, "")))
            {
                var      val            = string.Format(LegalityCheckStrings.LRibbonFInvalid_0, "");
                string[] ribbonList     = GetRequiredRibbons(report, val);
                var      invalidRibbons = GetRibbonsRequired(pk, ribbonList);
                SetRibbonValues(pk, invalidRibbons, 0, false);
            }
        }
예제 #2
0
        /// <summary>
        /// Fix invalid and missing ribbons. (V600 and V601)
        /// </summary>
        /// <param name="pk">PKM whose ribbons need to be fixed</param>
        public static void FixRibbons(PKM pk)
        {
            string Report = new LegalityAnalysis(pk).Report();

            if (Report.Contains(String.Format(V600, "")))
            {
                string[]      ribbonList     = Report.Split(new string[] { String.Format(V600, "") }, StringSplitOptions.None)[1].Split(new string[] { "\r\n" }, StringSplitOptions.None)[0].Split(new string[] { ", " }, StringSplitOptions.None);
                var           RibbonNames    = ReflectUtil.GetPropertiesStartWithPrefix(pk.GetType(), "Ribbon").Distinct();
                List <string> missingRibbons = new List <string>();
                foreach (var RibbonName in RibbonNames)
                {
                    string v = RibbonStrings.GetName(RibbonName).Replace("Ribbon", "");
                    if (ribbonList.Contains(v))
                    {
                        missingRibbons.Add(RibbonName);
                    }
                }
                foreach (string missing in missingRibbons)
                {
                    if (missing == "RibbonCountMemoryBattle" || missing == "RibbonCountMemoryContest")
                    {
                        ReflectUtil.SetValue(pk, missing, 0);
                    }
                    else
                    {
                        ReflectUtil.SetValue(pk, missing, -1);
                    }
                }
            }
            if (Report.Contains(String.Format(V601, "")))
            {
                string[]      ribbonList     = Report.Split(new string[] { String.Format(V601, "") }, StringSplitOptions.None)[1].Split(new string[] { "\r\n" }, StringSplitOptions.None)[0].Split(new string[] { ", " }, StringSplitOptions.None);
                var           RibbonNames    = ReflectUtil.GetPropertiesStartWithPrefix(pk.GetType(), "Ribbon").Distinct();
                List <string> invalidRibbons = new List <string>();
                foreach (var RibbonName in RibbonNames)
                {
                    string v = RibbonStrings.GetName(RibbonName).Replace("Ribbon", "");
                    if (ribbonList.Contains(v))
                    {
                        invalidRibbons.Add(RibbonName);
                    }
                }
                foreach (string invalid in invalidRibbons)
                {
                    if (invalid == "RibbonCountMemoryBattle" || invalid == "RibbonCountMemoryContest")
                    {
                        ReflectUtil.SetValue(pk, invalid, 0);
                    }
                    else
                    {
                        ReflectUtil.SetValue(pk, invalid, false);
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Sets all ribbon flags according to a legality report.
        /// </summary>
        /// <param name="pk">Pokémon to modify</param>
        public static void SetSuggestedRibbons(this PKM pk)
        {
            string report = new LegalityAnalysis(pk).Report();

            if (report.Contains(string.Format(LegalityCheckStrings.LRibbonFMissing_0, "")))
            {
                var val            = string.Format(LegalityCheckStrings.LRibbonFMissing_0, "");
                var ribbonList     = GetRequiredRibbons(report, val);
                var missingRibbons = GetRibbonsRequired(pk, ribbonList);
                SetRibbonValues(pk, missingRibbons, 0, true);
            }
            if (report.Contains(string.Format(LegalityCheckStrings.LRibbonFInvalid_0, "")))
            {
                var      val            = string.Format(LegalityCheckStrings.LRibbonFInvalid_0, "");
                string[] ribbonList     = GetRequiredRibbons(report, val);
                var      invalidRibbons = GetRibbonsRequired(pk, ribbonList);
                SetRibbonValues(pk, invalidRibbons, 0, false);
            }
        }
예제 #4
0
        public static bool ValidBall(this PKM pk)
        {
            var rep = new LegalityAnalysis(pk).Report(true);

            return(rep.Contains(LegalityCheckStrings.LBallEnc) || rep.Contains(LegalityCheckStrings.LBallSpeciesPass));
        }