Exemple #1
0
        public override void Verify(LegalityAnalysis data)
        {
            var pkm = data.pkm;
            var enc = data.EncounterMatch;

            if (!IsPlayerOriginalTrainer(enc))
            {
                return; // already verified
            }
            var ot = pkm.OT_Name;

            if (ot.Length == 0)
            {
                data.AddLine(GetInvalid(LOTShort));
            }

            if (IsOTNameSuspicious(ot))
            {
                data.AddLine(Get(LOTSuspicious, Severity.Fishy));
            }

            if (pkm.VC)
            {
                VerifyOTG1(data);
            }
            else if (ot.Length > Legal.GetMaxLengthOT(data.Info.Generation, (LanguageID)pkm.Language))
            {
                if (!IsEdgeCaseLength(pkm, data.EncounterOriginal, ot))
                {
                    data.AddLine(Get(LOTLong, Severity.Invalid));
                }
            }

            if (ParseSettings.CheckWordFilter)
            {
                if (WordFilter.IsFiltered(ot, out string bad))
                {
                    data.AddLine(GetInvalid($"Wordfilter: {bad}"));
                }
                if (ContainsTooManyNumbers(ot, data.Info.Generation))
                {
                    data.AddLine(GetInvalid("Wordfilter: Too many numbers."));
                }

                if (WordFilter.IsFiltered(pkm.HT_Name, out bad))
                {
                    data.AddLine(GetInvalid($"Wordfilter: {bad}"));
                }
            }
        }
        public static bool IsEdgeCaseLength(PKM pkm, IEncounterable e, string ot)
        {
            if (e.EggEncounter)
            {
                if (e is WC3 wc3 && pkm.IsEgg && wc3.OT_Name == ot)
                {
                    return(true); // Fixed OT Mystery Gift Egg
                }
                bool eggEdge = pkm.IsEgg ? pkm.IsTradedEgg || pkm.Format == 3 : pkm.WasTradedEgg;
                if (!eggEdge)
                {
                    return(false);
                }
                var len = Legal.GetMaxLengthOT(pkm.GenNumber, LanguageID.English); // max case
                return(ot.Length <= len);
            }

            if (e is MysteryGift mg && mg.OT_Name.Length == ot.Length)
            {
                return(true); // Mattle Ho-Oh
            }
            return(false);
        }
        public override void Verify(LegalityAnalysis data)
        {
            var pkm = data.pkm;

            switch (data.EncounterMatch)
            {
            case EncounterTrade _:
            case MysteryGift g when !g.IsEgg:
            case EncounterStatic5N _:
                return;     // already verified
            }

            var ot = pkm.OT_Name;

            if (ot.Length == 0)
            {
                data.AddLine(GetInvalid(LOTShort));
            }

            if (pkm.TID == 0 && pkm.SID == 0)
            {
                data.AddLine(Get(LOT_IDs0, Severity.Fishy));
            }
            else if (pkm.VC)
            {
                if (pkm.SID != 0)
                {
                    data.AddLine(GetInvalid(LOT_SID0Invalid));
                }
            }
            else if (pkm.TID == pkm.SID)
            {
                data.AddLine(Get(LOT_IDEqual, Severity.Fishy));
            }
            else if (pkm.TID == 0)
            {
                data.AddLine(Get(LOT_TID0, Severity.Fishy));
            }
            else if (pkm.SID == 0)
            {
                data.AddLine(Get(LOT_SID0, Severity.Fishy));
            }
            else if ((pkm.TID == 12345 && pkm.SID == 54321) || IsOTNameSuspicious(ot))
            {
                data.AddLine(Get(LOTSuspicious, Severity.Fishy));
            }

            if (pkm.VC)
            {
                VerifyOTG1(data);
            }
            else if (ot.Length > Legal.GetMaxLengthOT(data.Info.Generation, (LanguageID)pkm.Language))
            {
                if (!IsEdgeCaseLength(pkm, data.EncounterOriginal, ot))
                {
                    data.AddLine(Get(LOTLong, Severity.Invalid));
                }
            }

            if (ParseSettings.CheckWordFilter)
            {
                if (WordFilter.IsFiltered(ot, out string bad))
                {
                    data.AddLine(GetInvalid($"Wordfilter: {bad}"));
                }
                if (WordFilter.IsFiltered(pkm.HT_Name, out bad))
                {
                    data.AddLine(GetInvalid($"Wordfilter: {bad}"));
                }
                if (ContainsTooManyNumbers(ot, data.Info.Generation))
                {
                    data.AddLine(GetInvalid($"Wordfilter: Too many numbers."));
                }
            }
        }