Пример #1
0
 public static void SanitizeForm(this RegenTemplate set)
 {
     if (!FormInfo.IsBattleOnlyForm(set.Species, set.Form, set.Format))
     {
         return;
     }
     set.Form = FormInfo.GetOutOfBattleForm(set.Species, set.Form, set.Format);
 }
Пример #2
0
        private static bool IgnoreForm(this PKM pk, ITrainerInfo tr, int form)
        {
            var generation = tr.Generation;
            var species    = pk.Species;

            switch ((Species)species)
            {
            case Species.Unown when generation == 2 && form >= 26:
                return(true);

            case Species.Scatterbug or Species.Spewpa when form > Vivillon3DS.MaxWildFormID:
                return(true);

            case Species.Floette when form == 5:
                return(true);

            case Species.Shaymin or Species.Furfrou or Species.Hoopa when form != 0 && generation <= 6:
                return(true);

            case Species.Arceus when generation == 4 && form == 9:     // ??? form
                return(true);
            }
            if (FormInfo.IsBattleOnlyForm(pk.Species, form, generation))
            {
                return(true);
            }
            if (form == 0)
            {
                return(false);
            }
            if (generation >= 7 && pk.Generation < 7 && pk.Generation != -1 && (species == 25 || SimpleEdits.AlolanOriginForms.Contains(species)))
            {
                return(true);
            }
            return(false);
        }
    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)));
                }
            }
        }
    }