Exemplo n.º 1
0
 internal static IEnumerable <EncounterStatic> DreamRadarClone(this EncounterStatic s)
 {
     for (int i = 0; i < 8; i++)
     {
         yield return(s.DreamRadarClone((5 * i) + 5));  // Level from 5->40 depends on the number of badges
     }
 }
Exemplo n.º 2
0
        internal static EncounterStatic Clone(this EncounterStatic s, int location)
        {
            var result = s.Clone();

            result.Location = location;
            return(result);
        }
Exemplo n.º 3
0
 private void VerifyIVsStatic(LegalityAnalysis data, EncounterStatic s)
 {
     if (s.FlawlessIVCount != 0)
     {
         VerifyIVsFlawless(data, s.FlawlessIVCount);
     }
 }
Exemplo n.º 4
0
        private static bool IsValidCatchRatePK1(EncounterStatic e, PK1 pk1)
        {
            var catch_rate = pk1.Catch_Rate;

            // Pure gen 1, trades can be filter by catch rate
            if (pk1.Species == 25 || pk1.Species == 26)
            {
                if (catch_rate == 190) // Red Blue Pikachu, is not a static encounter
                {
                    return(false);
                }
                if (catch_rate == 163 && e.Level == 5) // Light Ball (Yellow) starter
                {
                    return(true);
                }
            }

            if (e.Version == GameVersion.Stadium)
            {
                // Amnesia Psyduck has different catch rates depending on language
                if (e.Species == 054)
                {
                    return(catch_rate == (pk1.Japanese ? 167 : 168));
                }
                return(Stadium_CatchRate.Contains(catch_rate));
            }

            // Encounters can have different Catch Rates (RBG vs Y)
            var table = e.Version == GameVersion.Y ? PersonalTable.Y : PersonalTable.RB;
            var rate  = table[e.Species].CatchRate;

            return(catch_rate == rate);
        }
Exemplo n.º 5
0
        private static bool IsUnobtainable(this EncounterStatic enc, PKM pk)
        {
            switch (enc.Generation)
            {
            case 4 when enc is EncounterStaticTyped t && enc.Location == 193:
                if (t.TypeEncounter == EncounterType.Surfing_Fishing) // Johto Route 45 surfing encounter. Unreachable Water tiles.
                {
                    return(true);                                     // only hits for Roamer Raikou
                }
                break;

            case 4:
                switch (pk.Species)
                {
                case 491 when enc.Location == 079 && !pk.Pt:         // DP Darkrai
                    return(true);

                case 492 when enc.Location == 063 && !pk.Pt:         // DP Shaymin
                    return(true);

                case 493 when enc.Location == 086:         // Azure Flute Arceus
                    return(true);
                }
                break;
            }

            return(false);
        }
 private CheckResult VerifyBallStatic(LegalityAnalysis data, EncounterStatic s)
 {
     if (s.Location == 75 && s.Generation == 5) // Entree Forest (Dream World)
     {
         return(VerifyBallEquals(data, Legal.DreamWorldBalls));
     }
     return(VerifyBallEquals(data, Legal.GetWildBalls(data.pkm)));
 }
Exemplo n.º 7
0
 internal static EncounterStatic[] Clone(this EncounterStatic s, int[] locations)
 {
     EncounterStatic[] Encounters = new EncounterStatic[locations.Length];
     for (int i = 0; i < locations.Length; i++)
     {
         Encounters[i] = s.Clone(locations[i]);
     }
     return(Encounters);
 }
Exemplo n.º 8
0
 public EncounterStatic[] Clone(int[] locations)
 {
     EncounterStatic[] Encounters = new EncounterStatic[locations.Length];
     for (int i = 0; i < locations.Length; i++)
     {
         Encounters[i] = Clone(locations[i]);
     }
     return(Encounters);
 }
Exemplo n.º 9
0
        private void VerifyIVsStatic(LegalityAnalysis data, EncounterStatic s)
        {
            var pkm = data.pkm;

            if (s.FlawlessIVCount != 0 && pkm.IVs.Count(iv => iv == 31) < s.FlawlessIVCount)
            {
                data.AddLine(GetInvalid(string.Format(V28, s.FlawlessIVCount)));
            }
        }
Exemplo n.º 10
0
        private static EncounterStatic DreamRadarClone(this EncounterStatic s, int level)
        {
            var result = s.Clone(level);

            result.Level    = level;
            result.Location = 30015; // Pokemon Dream Radar
            result.Gift     = true;  // Only
            result.Ball     = 25;    // Dream Ball
            return(result);
        }
Exemplo n.º 11
0
 private static GBEncounterPriority GetGBEncounterPriority(PKM pkm, IEncounterable Encounter)
 {
     return(Encounter switch
     {
         EncounterTrade1 t1 when t1.IsMatchDeferred(pkm) => GBEncounterPriority.Least,
         EncounterTrade1 _ => GBEncounterPriority.TradeEncounterG1,
         EncounterTrade2 _ => GBEncounterPriority.TradeEncounterG2,
         EncounterStatic _ => GBEncounterPriority.StaticEncounter,
         EncounterSlot _ => GBEncounterPriority.WildEncounter,
         _ => GBEncounterPriority.EggEncounter
     });
Exemplo n.º 12
0
 private static CheckResult VerifyEncounter(PKM pkm, LegalInfo info)
 {
     return(info.EncounterMatch switch
     {
         EncounterEgg _ => VerifyEncounterEgg(pkm),
         EncounterTrade t => VerifyEncounterTrade(pkm, t),
         EncounterSlot w => VerifyEncounterWild(pkm, w),
         EncounterStatic s => VerifyEncounterStatic(pkm, s),
         MysteryGift g => VerifyEncounterEvent(pkm, g),
         _ => new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter)
     });
Exemplo n.º 13
0
        private static EncounterStatic GetSuggestedEncounterStatic(EncounterStatic s, int loc = -1)
        {
            if (loc == -1)
            {
                loc = s.Location;
            }

            // don't leak out the original EncounterStatic object
            var encounter = s.Clone(loc);

            return(encounter);
        }
Exemplo n.º 14
0
 private static bool GetIsMatchDeferred(PKM pkm, EncounterStatic e)
 {
     if (pkm.FatefulEncounter != e.Fateful)
     {
         return(true);
     }
     if (e.Ability == 4 && pkm.AbilityNumber != 4) // BW/2 Jellicent collision with wild surf slot, resolved by duplicating the encounter with any abil
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 15
0
        private static CheckResult VerifyEncounterStatic(PKM pkm, EncounterStatic s)
        {
            // Check for Unreleased Encounters / Collisions
            switch (pkm.GenNumber)
            {
            case 3:
                if (s is EncounterStaticShadow w && w.EReader && pkm.Language != 1)     // Non-JP E-reader Pokemon
                {
                    return(new CheckResult(Severity.Invalid, V406, CheckIdentifier.Encounter));
                }
                if (pkm.Species == 151 && s.Location == 201 && pkm.Language != 1)     // Non-JP Mew (Old Sea Map)
                {
                    return(new CheckResult(Severity.Invalid, V353, CheckIdentifier.Encounter));
                }
                break;

            case 4:
                if (pkm.Species == 493 && s.Location == 086)     // Azure Flute Arceus
                {
                    return(new CheckResult(Severity.Invalid, V352, CheckIdentifier.Encounter));
                }
                if (pkm.Species == 491 && s.Location == 079 && !pkm.Pt)     // DP Darkrai
                {
                    return(new CheckResult(Severity.Invalid, V383, CheckIdentifier.Encounter));
                }
                if (pkm.Species == 492 && s.Location == 063 && !pkm.Pt)     // DP Shaymin
                {
                    return(new CheckResult(Severity.Invalid, V354, CheckIdentifier.Encounter));
                }
                if (s.Location == 193 && (s as EncounterStaticTyped)?.TypeEncounter == EncounterType.Surfing_Fishing)     // Roaming pokemon surfin in Johto Route 45
                {
                    return(new CheckResult(Severity.Invalid, V384, CheckIdentifier.Encounter));
                }
                break;

            case 7:
                if (s.EggLocation == 60002 && pkm.RelearnMoves.Any(m => m != 0))
                {
                    return(new CheckResult(Severity.Invalid, V74, CheckIdentifier.RelearnMove));    // not gift egg
                }
                break;
            }
            if (s.EggEncounter && !pkm.IsEgg) // hatched
            {
                var hatchCheck = VerifyEncounterEgg(pkm, null);
                if (!hatchCheck.Valid)
                {
                    return(hatchCheck);
                }
            }

            return(new CheckResult(Severity.Valid, V75, CheckIdentifier.Encounter));
        }
Exemplo n.º 16
0
        private static CheckResult VerifyEncounterStatic(PKM pkm, EncounterStatic s)
        {
            // Check for Unreleased Encounters / Collisions
            switch (pkm.GenNumber)
            {
            case 3:
                if (s is EncounterStaticShadow w && w.EReader && pkm.Language != (int)LanguageID.Japanese)     // Non-JP E-reader Pokemon
                {
                    return(new CheckResult(Severity.Invalid, LG3EReader, CheckIdentifier.Encounter));
                }
                if (pkm.Species == (int)Species.Mew && s.Location == 201 && pkm.Language != (int)LanguageID.Japanese)     // Non-JP Mew (Old Sea Map)
                {
                    return(new CheckResult(Severity.Invalid, LEncUnreleasedEMewJP, CheckIdentifier.Encounter));
                }
                break;

            case 4:
                switch (pkm.Species)
                {
                case (int)Species.Darkrai when s.Location == 079 && !pkm.Pt:         // DP Darkrai
                    return(new CheckResult(Severity.Invalid, LEncUnreleasedPtDarkrai, CheckIdentifier.Encounter));

                case (int)Species.Shaymin when s.Location == 063 && !pkm.Pt:        // DP Shaymin
                    return(new CheckResult(Severity.Invalid, LEncUnreleasedPtShaymin, CheckIdentifier.Encounter));

                case (int)Species.Arceus when s.Location == 086:         // Azure Flute Arceus
                    return(new CheckResult(Severity.Invalid, LEncUnreleasedHoOArceus, CheckIdentifier.Encounter));
                }
                if (s.Location == 193 && s is EncounterStaticTyped t && t.TypeEncounter == EncounterType.Surfing_Fishing)     // Roaming pokemon surfing in Johto Route 45
                {
                    return(new CheckResult(Severity.Invalid, LG4InvalidTileR45Surf, CheckIdentifier.Encounter));
                }
                break;

            case 7:
                if (s.EggLocation == Locations.Daycare5 && pkm.RelearnMoves.Any(m => m != 0))                  // eevee gift egg
                {
                    return(new CheckResult(Severity.Invalid, LEncStaticRelearn, CheckIdentifier.RelearnMove)); // not gift egg
                }
                break;
            }
            if (s.EggEncounter && !pkm.IsEgg) // hatched
            {
                var hatchCheck = VerifyEncounterEgg(pkm);
                if (!hatchCheck.Valid)
                {
                    return(hatchCheck);
                }
            }

            return(new CheckResult(Severity.Valid, LEncStaticMatch, CheckIdentifier.Encounter));
        }
Exemplo n.º 17
0
        private CheckResult VerifyBall(LegalityAnalysis data)
        {
            var Info = data.Info;
            var enc  = Info.EncounterMatch;

            // Fixed ball cases -- can be only one ball ever
            switch (enc)
            {
            case MysteryGift g:
                return(VerifyBallMysteryGift(data, g));

            case EncounterTrade t:
                return(VerifyBallEquals(data, t.Ball));

            case EncounterStatic {
                    Gift: true
            } s:
                return(VerifyBallEquals(data, s.Ball));

            case EncounterSlot8GO:     // Already a strict match
                return(GetResult(true));
            }

            // Capture / Inherit cases -- can be one of many balls
            var pkm = data.pkm;

            if (pkm.Species == (int)Species.Shedinja && enc.Species != (int)Species.Shedinja) // Shedinja. For gen3, copy the ball from Nincada
            {
                // Only Gen3 origin Shedinja can copy the wild ball.
                // Evolution chains will indicate if it could have existed as Shedinja in Gen3.
                // The special move verifier has a similar check!
                if (Info.Generation != 3 || Info.EvoChainsAllGens[3].Count != 2)
                {
                    return(VerifyBallEquals(data, (int)Poke)); // Pokeball Only
                }
            }

            if (pkm.Ball == (int)Heavy && BallBreedLegality.AlolanCaptureNoHeavyBall.Contains(enc.Species) && !enc.EggEncounter && pkm.SM)
            {
                return(GetInvalid(LBallHeavy)); // Heavy Ball, can inherit if from egg (USUM fixed catch rate calc)
            }
            return(enc switch
            {
                EncounterStatic e => VerifyBallStatic(data, e),
                EncounterSlot w => VerifyBallWild(data, w),
                EncounterEgg => VerifyBallEgg(data),
                EncounterInvalid => VerifyBallEquals(data, pkm.Ball), // ignore ball, pass whatever
                _ => VerifyBallEquals(data, (int)Poke),
            });
Exemplo n.º 18
0
        private void UpdateVCTransferInfo()
        {
            EncounterOriginalGB = EncounterMatch;
            Info.EncounterMatch = EncounterGenerator.GetVCStaticTransferEncounter(pkm);
            EncounterStatic s = Info.EncounterMatch as EncounterStatic;

            if (s == null || !EncounterGenerator.IsVCStaticTransferEncounterValid(pkm, s))
            {
                AddLine(Severity.Invalid, V80, CheckIdentifier.Encounter); return;
            }

            foreach (var z in VerifyVCEncounter(pkm, EncounterOriginalGB.Species, EncounterOriginalGB as GBEncounterData, s))
            {
                AddLine(z);
            }
        }
Exemplo n.º 19
0
        private static IEnumerable <EncounterStatic> PermuteCosplayPikachu()
        {
            var CosplayPikachu = new EncounterStatic
            {
                Species = 25, Level = 20, Gender = 1, Ability = 4, IV3 = true,
                Contest = new[] { 70, 70, 70, 70, 70, 0 }, Gift = true, Shiny = Shiny.Never
            };

            foreach (int loc in new[] { 178, 180, 186, 194 })
            {
                for (int f = 1; f <= 6; f++)
                {
                    var pk = CosplayPikachu.Clone(loc); pk.Form = f; yield return(pk);
                }
            }
        }
Exemplo n.º 20
0
        private static EncounterStatic GetSuggestedEncounterWild(EncounterArea area, int loc)
        {
            var slots     = area.Slots.OrderBy(s => s.LevelMin);
            var first     = slots.First();
            var encounter = new EncounterStatic
            {
                Location = area.Location,
                Species  = first.Species,
                Level    = first.LevelMin,
            };

            if (loc != -1) // forced location
            {
                encounter.Location = loc;
            }
            return(encounter);
        }
Exemplo n.º 21
0
        private static EncounterStatic GetGSStaticTransfer(int species, int pkmMetLevel)
        {
            var enc = new EncounterStatic
            {
                Species     = species,
                Gift        = true,                                                      // Forces Poké Ball
                Ability     = TransferSpeciesDefaultAbility_2.Contains(species) ? 1 : 4, // Hidden by default, else first
                Shiny       = species == 151 ? Shiny.Never : Shiny.Random,
                Fateful     = species == 151 || species == 251,
                Location    = Transfer2,
                EggLocation = 0,
                Level       = pkmMetLevel,
                Version     = GameVersion.GSC
            };

            enc.FlawlessIVCount = enc.Fateful ? 5 : 3;
            return(enc);
        }
        private static bool GetIsMatchStatic(PKM pkm, EncounterStatic e, int lvl)
        {
            if (!e.IsMatch(pkm, lvl))
            {
                return(false);
            }

            if (pkm is PK1 pk1 && pk1.Gen1_NotTradeback && !IsValidCatchRatePK1(e, pk1))
            {
                return(false);
            }

            if (!ParseSettings.AllowGBCartEra && GameVersion.GBCartEraOnly.Contains(e.Version))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 23
0
        private CheckResult VerifyBall(LegalityAnalysis data)
        {
            var EncounterMatch = data.EncounterMatch;
            var Info = data.Info;

            // Fixed ball cases -- can be only one ball ever
            switch (EncounterMatch)
            {
                case MysteryGift g:
                    return VerifyBallMysteryGift(data, g);
                case EncounterTrade t:
                    return VerifyBallEquals(data, t.Ball);
                case EncounterStatic s when s.Gift:
                    return VerifyBallEquals(data, s.Ball);
            }

            // Capture / Inherit cases -- can be one of many balls
            var pkm = data.pkm;
            if (pkm.Species == (int)Species.Shedinja && data.EncounterMatch.Species != (int)Species.Shedinja) // Shedinja. For gen3, copy the ball from Nincada
            {
                // Only Gen3 origin Shedinja can copy the wild ball.
                // Evolution chains will indicate if it could have existed as Shedinja in Gen3.
                // The special move verifier has a similar check!
                if (Info.Generation != 3 || Info.EvoChainsAllGens[3].Count != 2)
                    return VerifyBallEquals(data, (int)Poke); // Pokeball Only
            }

            if (pkm.Ball == (int)Heavy && Legal.AlolanCaptureNoHeavyBall.Contains(EncounterMatch.Species) && !EncounterMatch.EggEncounter && pkm.SM)
                return GetInvalid(LBallHeavy); // Heavy Ball, can inherit if from egg (USUM fixed catch rate calc)

            return EncounterMatch switch
            {
                EncounterStatic e => VerifyBallStatic(data, e),
                EncounterSlot w => VerifyBallWild(data, w),
                EncounterEgg _ => VerifyBallEgg(data),
                EncounterInvalid _ => VerifyBallEquals(data, pkm.Ball), // ignore ball, pass whatever
                _ => VerifyBallEquals(data, (int)Poke)
            };
        }
Exemplo n.º 24
0
        private CheckResult VerifyBall(LegalityAnalysis data)
        {
            var EncounterMatch = data.EncounterMatch;
            var Info           = data.Info;

            // Fixed ball cases -- can be only one ball ever
            switch (EncounterMatch)
            {
            case MysteryGift g:
                return(VerifyBallMysteryGift(data, g));

            case EncounterTrade t:
                return(VerifyBallEquals(data, t.Ball));

            case EncounterStatic s when s.Gift:
                return(VerifyBallEquals(data, s.Ball));
            }

            // Capture / Inherit cases -- can be one of many balls
            var pkm = data.pkm;

            if (pkm.Species == (int)Species.Shedinja && Info.Generation != 3 && data.EncounterMatch.Species != (int)Species.Shedinja) // Shedinja. For gen3, copy the ball from Nincada
            {
                return(VerifyBallEquals(data, (int)Poke));                                                                            // Pokeball Only
            }
            if (pkm.Ball == (int)Heavy && Legal.AlolanCaptureNoHeavyBall.Contains(EncounterMatch.Species) && !EncounterMatch.EggEncounter && pkm.SM)
            {
                return(GetInvalid(LBallHeavy)); // Heavy Ball, can inherit if from egg (USUM fixed catch rate calc)
            }
            return(EncounterMatch switch
            {
                EncounterStatic e => VerifyBallStatic(data, e),
                EncounterSlot w => VerifyBallWild(data, w),
                EncounterEgg _ => VerifyBallEgg(data),
                EncounterInvalid _ => VerifyBallEquals(data, pkm.Ball), // ignore ball, pass whatever
                _ => VerifyBallEquals(data, (int)Poke)
            });
Exemplo n.º 25
0
        private static EncounterSuggestionData GetSuggestedEncounterStatic(PKM pkm, EncounterStatic s, int loc = -1)
        {
            var met = loc != -1 ? loc : s.Location;

            return(new EncounterSuggestionData(pkm, s, met));
        }
 internal static bool IsVCStaticTransferEncounterValid(PKM pkm, EncounterStatic e)
 {
     return(pkm.Met_Location == e.Location && pkm.Egg_Location == e.EggLocation);
 }
Exemplo n.º 27
0
        private static bool GetIsMatchStatic(PKM pkm, EncounterStatic e, int lvl)
        {
            if (e.Nature != Nature.Random && pkm.Nature != (int)e.Nature)
            {
                return(false);
            }
            if (pkm.WasEgg != e.EggEncounter && pkm.Egg_Location == 0 && pkm.Format > 3 && pkm.GenNumber > 3 && !pkm.IsEgg)
            {
                return(false);
            }
            if (e is EncounterStaticPID p && p.PID != pkm.PID)
            {
                return(false);
            }

            if (pkm.Gen3 && e.EggLocation != 0) // Gen3 Egg
            {
                if (pkm.Format == 3 && pkm.IsEgg && e.EggLocation != pkm.Met_Location)
                {
                    return(false);
                }
            }
            else if (pkm.VC || pkm.GenNumber <= 2 && e.EggLocation != 0) // Gen2 Egg
            {
                if (pkm.Format <= 2)
                {
                    if (pkm.IsEgg)
                    {
                        if (pkm.Met_Location != 0 && pkm.Met_Level != 0)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        switch (pkm.Met_Level)
                        {
                        case 0 when pkm.Met_Location != 0:
                            return(false);

                        case 1 when pkm.Met_Location == 0:
                            return(false);

                        default:
                            if (pkm.Met_Location == 0 && pkm.Met_Level != 0)
                            {
                                return(false);
                            }
                            break;
                        }
                    }
                    if (pkm.Met_Level == 1)
                    {
                        lvl = 5; // met @ 1, hatch @ 5.
                    }
                }
            }
            else if (e.EggLocation != pkm.Egg_Location)
            {
                if (pkm.IsEgg) // unhatched
                {
                    if (e.EggLocation != pkm.Met_Location)
                    {
                        return(false);
                    }
                    if (pkm.Egg_Location != 0)
                    {
                        return(false);
                    }
                }
                else if (pkm.Gen4)
                {
                    if (pkm.Egg_Location != 2002) // Link Trade
                    {
                        // check Pt/HGSS data
                        if (pkm.Format <= 4)
                        {
                            return(false);                                  // must match
                        }
                        if (e.EggLocation >= 3000 || e.EggLocation <= 2010) // non-Pt/HGSS egg gift
                        {
                            return(false);
                        }

                        // transferring 4->5 clears pt/hgss location value and keeps Faraway Place
                        if (pkm.Egg_Location != 3002) // Faraway Place
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    if (pkm.Egg_Location != 30002) // Link Trade
                    {
                        return(false);
                    }
                }
            }
            else if (e.EggLocation != 0 && pkm.Gen4)
            {
                // Check the inverse scenario for 4->5 eggs
                if (e.EggLocation < 3000 && e.EggLocation > 2010) // Pt/HGSS egg gift
                {
                    if (pkm.Format > 4)
                    {
                        return(false); // locations match when it shouldn't
                    }
                }
            }

            if (pkm.HasOriginalMetLocation)
            {
                if (!e.EggEncounter && e.Location != 0 && e.Location != pkm.Met_Location)
                {
                    return(false);
                }
                if (e.Level != lvl)
                {
                    if (!(pkm.Format == 3 && e.EggEncounter && lvl == 0))
                    {
                        return(false);
                    }
                }
            }
            else if (e.Level > lvl)
            {
                return(false);
            }

            if (e.Gender != -1 && e.Gender != pkm.Gender)
            {
                return(false);
            }
            if (e.Form != pkm.AltForm && !e.SkipFormCheck && !IsFormChangeable(pkm, e.Species))
            {
                return(false);
            }
            if (e.EggLocation == 60002 && e.Relearn[0] == 0 && pkm.RelearnMoves.Any(z => z != 0)) // gen7 eevee edge case
            {
                return(false);
            }

            if (e.IVs != null && (e.Generation > 2 || pkm.Format <= 2)) // 1,2->7 regenerates IVs, only check if original IVs still exist
            {
                for (int i = 0; i < 6; i++)
                {
                    if (e.IVs[i] != -1 && e.IVs[i] != pkm.IVs[i])
                    {
                        return(false);
                    }
                }
            }

            if (pkm.IsContestBelow(e))
            {
                return(false);
            }

            // 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;

            if (pkm is PK1 pk1 && pk1.Gen1_NotTradeback && !IsValidCatchRatePK1(e, pk1))
            {
                return(false);
            }

            if (!AllowGBCartEra && GameVersion.GBCartEraOnly.Contains(e.Version))
            {
                return(false);
            }
            return(true);
        }