Esempio n. 1
0
 private bool VerifyUnNicknamedEncounter(LegalityAnalysis data, PKM pkm, string nickname)
 {
     if (pkm.IsNicknamed)
     {
         for (int i = 0; i < PKX.SpeciesLang.Length; i++)
         {
             if (!PKX.SpeciesDict[i].TryGetValue(nickname, out int index))
             {
                 continue;
             }
             var msg = index == pkm.Species && i != pkm.Language ? LNickMatchNoOthersFail : LNickMatchLanguageFlag;
             data.AddLine(Get(msg, Severity.Fishy));
             return(true);
         }
         if (StringConverter.HasEastAsianScriptCharacters(nickname)) // East Asian Scripts
         {
             data.AddLine(GetInvalid(LNickInvalidChar));
             return(true);
         }
         if (nickname.Length > Legal.GetNicknameOTMaxLength(data.Info.Generation, (LanguageID)pkm.Language))
         {
             data.AddLine(Get(LNickLengthLong, data.EncounterOriginal.EggEncounter ? Severity.Fishy : Severity.Invalid));
             return(true);
         }
         data.AddLine(GetValid(LNickMatchNoOthers));
     }
     else if (pkm.Format < 3)
     {
         // pk1/pk2 IsNicknamed getter checks for match, logic should only reach here if matches.
         data.AddLine(GetValid(LNickMatchLanguage));
     }
     else
     {
         var  EncounterMatch = data.EncounterOriginal;
         bool valid          = IsNicknameValid(pkm, EncounterMatch, nickname);
         var  result         = valid ? GetValid(LNickMatchLanguage) : GetInvalid(LNickMatchLanguageFail);
         data.AddLine(result);
     }
     return(false);
 }
Esempio n. 2
0
        public override void Verify(LegalityAnalysis data)
        {
            var pkm = data.pkm;

            switch (data.EncounterMatch)
            {
            case EncounterTrade _:
            case MysteryGift g when !g.IsEgg:
            case EncounterStaticPID s when s.NSparkle:
                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.GetNicknameOTMaxLength(data.Info.Generation, (LanguageID)pkm.Language))
            {
                if (!pkm.IsEgg) // ignore eggs, on trade, OT is not updated if language is
                {
                    data.AddLine(Get(LOTLong, data.EncounterOriginal.EggEncounter ? Severity.Fishy : Severity.Invalid));
                }
            }

            if (Legal.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}"));
                }
            }
        }