コード例 #1
0
ファイル: Core.cs プロジェクト: LLNet/PKHeX
 internal static bool IsFormChangeable(PKM pkm, int species)
 {
     if (FormChange.Contains(species))
     {
         return(true);
     }
     if (IsEvolvedFormChange(pkm))
     {
         return(true);
     }
     if (species == 718 && pkm.InhabitedGeneration(7) && pkm.AltForm > 1)
     {
         return(true);
     }
     return(false);
 }
コード例 #2
0
        internal static EncounterStatic getValidStaticEncounter(PKM pkm)
        {
            // Get possible encounters
            IEnumerable <EncounterStatic> poss = getStaticEncounters(pkm);

            // Back Check against pkm
            foreach (EncounterStatic e in poss)
            {
                if (e.Nature != Nature.Random && pkm.Nature != (int)e.Nature)
                {
                    continue;
                }
                if (e.EggLocation != pkm.Egg_Location)
                {
                    continue;
                }
                if (e.Location != 0 && e.Location != pkm.Met_Location)
                {
                    continue;
                }
                if (e.Gender != -1 && e.Gender != pkm.Gender)
                {
                    continue;
                }
                if (e.Level != pkm.Met_Level)
                {
                    continue;
                }
                if (e.Form != pkm.AltForm && !FormChange.Contains(pkm.Species) && !e.SkipFormCheck)
                {
                    continue;
                }

                // Defer to EC/PID check
                // if (e.Shiny != null && e.Shiny != pkm.IsShiny)
                // continue;

                // Defer ball check to later
                // if (e.Gift && pkm.Ball != 4) // PokéBall
                // continue;

                // Passes all checks, valid encounter
                return(e);
            }
            return(null);
        }
コード例 #3
0
        private static IEnumerable <MysteryGift> getMatchingWC7(PKM pkm, IEnumerable <MysteryGift> DB)
        {
            List <MysteryGift> validWC7 = new List <MysteryGift>();

            if (DB == null)
            {
                return(validWC7);
            }
            var vs = getValidPreEvolutions(pkm).ToArray();

            foreach (WC7 wc in DB.OfType <WC7>().Where(wc => vs.Any(dl => dl.Species == wc.Species)))
            {
                if (pkm.Egg_Location == 0) // Not Egg
                {
                    if (wc.OTGender != 3)
                    {
                        if (wc.SID != pkm.SID)
                        {
                            continue;
                        }
                        if (wc.TID != pkm.TID)
                        {
                            continue;
                        }
                        if (wc.OTGender != pkm.OT_Gender)
                        {
                            continue;
                        }
                    }
                    if (!string.IsNullOrEmpty(wc.OT) && wc.OT != pkm.OT_Name)
                    {
                        continue;
                    }
                    if (wc.OriginGame != 0 && wc.OriginGame != pkm.Version)
                    {
                        continue;
                    }
                    if (wc.EncryptionConstant != 0 && wc.EncryptionConstant != pkm.EncryptionConstant)
                    {
                        continue;
                    }
                    if (wc.Language != 0 && wc.Language != pkm.Language)
                    {
                        continue;
                    }
                }
                if (wc.Form != pkm.AltForm && vs.All(dl => !FormChange.Contains(dl.Species)))
                {
                    continue;
                }
                if (wc.MetLocation != pkm.Met_Location)
                {
                    continue;
                }
                if (wc.EggLocation != pkm.Egg_Location)
                {
                    continue;
                }
                if (wc.MetLevel != pkm.Met_Level)
                {
                    continue;
                }
                if (wc.Ball != pkm.Ball)
                {
                    continue;
                }
                if (wc.OTGender < 3 && wc.OTGender != pkm.OT_Gender)
                {
                    continue;
                }
                if (wc.Nature != 0xFF && wc.Nature != pkm.Nature)
                {
                    continue;
                }
                if (wc.Gender != 3 && wc.Gender != pkm.Gender)
                {
                    continue;
                }

                if (wc.CNT_Cool > pkm.CNT_Cool)
                {
                    continue;
                }
                if (wc.CNT_Beauty > pkm.CNT_Beauty)
                {
                    continue;
                }
                if (wc.CNT_Cute > pkm.CNT_Cute)
                {
                    continue;
                }
                if (wc.CNT_Smart > pkm.CNT_Smart)
                {
                    continue;
                }
                if (wc.CNT_Tough > pkm.CNT_Tough)
                {
                    continue;
                }
                if (wc.CNT_Sheen > pkm.CNT_Sheen)
                {
                    continue;
                }

                if (wc.PIDType == 2 && !pkm.IsShiny)
                {
                    continue;
                }
                if (wc.PIDType == 3 && pkm.IsShiny)
                {
                    continue;
                }

                if ((pkm.SID << 16 | pkm.TID) == 0x79F57B49) // Greninja WC has variant PID and can arrive @ 36 or 37
                {
                    if (!pkm.IsShiny)
                    {
                        validWC7.Add(wc);
                    }
                    continue;
                }
                if (wc.PIDType == 0 && pkm.PID != wc.PID)
                {
                    continue;
                }

                // Some checks are best performed separately as they are caused by users screwing up valid data.
                // if (!wc.RelearnMoves.SequenceEqual(pkm.RelearnMoves)) continue; // Defer to relearn legality
                // if (wc.OT.Length > 0 && pkm.CurrentHandler != 1) continue; // Defer to ownership legality
                // if (wc.OT.Length > 0 && pkm.OT_Friendship != PKX.getBaseFriendship(pkm.Species)) continue; // Friendship
                // if (wc.Level > pkm.CurrentLevel) continue; // Defer to level legality
                // RIBBONS: Defer to ribbon legality

                validWC7.Add(wc);
            }
            return(validWC7);
        }
コード例 #4
0
        internal static IEnumerable <WC6> getValidWC6s(PK6 pk6)
        {
            var        vs       = getValidPreEvolutions(pk6).ToArray();
            List <WC6> validWC6 = new List <WC6>();

            foreach (WC6 wc in WC6DB.Where(wc => vs.Any(dl => dl.Species == wc.Species)))
            {
                if (pk6.Egg_Location == 0) // Not Egg
                {
                    if (wc.CardID != pk6.SID)
                    {
                        continue;
                    }
                    if (wc.TID != pk6.TID)
                    {
                        continue;
                    }
                    if (wc.OT != pk6.OT_Name)
                    {
                        continue;
                    }
                    if (wc.OTGender != pk6.OT_Gender)
                    {
                        continue;
                    }
                    if (wc.PIDType == 0 && pk6.PID != wc.PID)
                    {
                        continue;
                    }
                    if (wc.PIDType == 2 && !pk6.IsShiny)
                    {
                        continue;
                    }
                    if (wc.PIDType == 3 && pk6.IsShiny)
                    {
                        continue;
                    }
                    if (wc.OriginGame != 0 && wc.OriginGame != pk6.Version)
                    {
                        continue;
                    }
                    if (wc.EncryptionConstant != 0 && wc.EncryptionConstant != pk6.EncryptionConstant)
                    {
                        continue;
                    }
                    if (wc.Language != 0 && wc.Language != pk6.Language)
                    {
                        continue;
                    }
                }
                if (wc.Form != pk6.AltForm && vs.All(dl => !FormChange.Contains(dl.Species)))
                {
                    continue;
                }
                if (wc.MetLocation != pk6.Met_Location)
                {
                    continue;
                }
                if (wc.EggLocation != pk6.Egg_Location)
                {
                    continue;
                }
                if (wc.Level != pk6.Met_Level)
                {
                    continue;
                }
                if (wc.Pokéball != pk6.Ball)
                {
                    continue;
                }
                if (wc.OTGender < 3 && wc.OTGender != pk6.OT_Gender)
                {
                    continue;
                }
                if (wc.Nature != 0xFF && wc.Nature != pk6.Nature)
                {
                    continue;
                }
                if (wc.Gender != 3 && wc.Gender != pk6.Gender)
                {
                    continue;
                }

                if (wc.CNT_Cool > pk6.CNT_Cool)
                {
                    continue;
                }
                if (wc.CNT_Beauty > pk6.CNT_Beauty)
                {
                    continue;
                }
                if (wc.CNT_Cute > pk6.CNT_Cute)
                {
                    continue;
                }
                if (wc.CNT_Smart > pk6.CNT_Smart)
                {
                    continue;
                }
                if (wc.CNT_Tough > pk6.CNT_Tough)
                {
                    continue;
                }
                if (wc.CNT_Sheen > pk6.CNT_Sheen)
                {
                    continue;
                }

                // Some checks are best performed separately as they are caused by users screwing up valid data.
                // if (!wc.RelearnMoves.SequenceEqual(pk6.RelearnMoves)) continue; // Defer to relearn legality
                // if (wc.OT.Length > 0 && pk6.CurrentHandler != 1) continue; // Defer to ownership legality
                // if (wc.OT.Length > 0 && pk6.OT_Friendship != PKX.getBaseFriendship(pk6.Species)) continue; // Friendship
                // if (wc.Level > pk6.CurrentLevel) continue; // Defer to level legality
                // RIBBONS: Defer to ribbon legality

                validWC6.Add(wc);
            }
            return(validWC6);
        }