示例#1
0
    public static int[] GetEggMoves(PersonalInfo pi, int species, int form, GameVersion version, int generation)
    {
        if (species > GetMaxSpeciesOrigin(generation, version))
        {
            return(Array.Empty <int>());
        }

        if (pi.Genderless && !FixedGenderFromBiGender.Contains(species))
        {
            return(Array.Empty <int>());
        }

        if (!Breeding.CanGameGenerateEggs(version))
        {
            return(Array.Empty <int>());
        }

        return(GetEggMoves(generation, species, form, version));
    }
    public static IEnumerable <EncounterEgg> GenerateEggs(PKM pk, EvoCriteria[] chain, int generation, bool all = false)
    {
        System.Diagnostics.Debug.Assert(generation >= 3); // if generating Gen2 eggs, use the other generator.
        int currentSpecies = pk.Species;

        if (!Breeding.CanHatchAsEgg(currentSpecies))
        {
            yield break;
        }

        var currentForm = pk.Form;

        if (!Breeding.CanHatchAsEgg(currentSpecies, currentForm, generation))
        {
            yield break; // can't originate from eggs
        }
        // version is a true indicator for all generation 3-5 origins
        var ver = (GameVersion)pk.Version;

        if (!Breeding.CanGameGenerateEggs(ver))
        {
            yield break;
        }

        var lvl = EggStateLegality.GetEggLevel(generation);
        int max = GetMaxSpeciesOrigin(generation);

        var(species, form) = GetBaseSpecies(chain, 0);
        if ((uint)species <= max)
        {
            // NOTE: THE SPLIT-BREED SECTION OF CODE SHOULD BE EXACTLY THE SAME AS THE BELOW SECTION
            if (FormInfo.IsBattleOnlyForm(species, form, generation))
            {
                form = FormInfo.GetOutOfBattleForm(species, form, generation);
            }
            if (Breeding.CanHatchAsEgg(species, form, ver))
            {
                yield return(new EncounterEgg(species, form, lvl, generation, ver));

                if (generation > 5 && (pk.WasTradedEgg || all) && HasOtherGamePair(ver))
                {
                    yield return(new EncounterEgg(species, form, lvl, generation, GetOtherTradePair(ver)));
                }
            }
        }

        if (!Breeding.GetSplitBreedGeneration(generation).Contains(currentSpecies))
        {
            yield break; // no other possible species
        }
        var otherSplit = species;

        (species, form) = GetBaseSpecies(chain, 1);
        if ((uint)species == otherSplit)
        {
            yield break;
        }

        if (species <= max)
        {
            // NOTE: THIS SECTION OF CODE SHOULD BE EXACTLY THE SAME AS THE ABOVE SECTION
            if (FormInfo.IsBattleOnlyForm(species, form, generation))
            {
                form = FormInfo.GetOutOfBattleForm(species, form, generation);
            }
            if (Breeding.CanHatchAsEgg(species, form, ver))
            {
                yield return(new EncounterEgg(species, form, lvl, generation, ver));

                if (generation > 5 && (pk.WasTradedEgg || all) && HasOtherGamePair(ver))
                {
                    yield return(new EncounterEgg(species, form, lvl, generation, GetOtherTradePair(ver)));
                }
            }
        }
    }