示例#1
0
        /// <summary>
        /// Regenerates the set by searching for an encounter that can generate the template.
        /// </summary>
        /// <param name="tr">Trainer Data that was passed in</param>
        /// <param name="set">Showdown set being used</param>
        /// <param name="template">template PKM to legalize</param>
        /// <param name="msg">Legalization result</param>
        /// <returns>Legalized pkm</returns>
        private static PKM GetLegalFromSet(this ITrainerInfo tr, IBattleTemplate set, PKM template, out LegalizationResult msg)
        {
            if (set is ShowdownSet s)
            {
                set = new RegenTemplate(s);
            }

            bool success = tr.TryAPIConvert(set, template, out PKM pk);

            if (success)
            {
                msg = LegalizationResult.Regenerated;
                return(pk);
            }

            msg = LegalizationResult.Failed;
            if (EnableEasterEggs)
            {
                var gen     = EasterEggs.GetGeneration(template.Species);
                var species = (int)EasterEggs.GetMemeSpecies(gen);
                template.Species = species;
                var legalencs = tr.GetRandomEncounter(species, out var legal);
                if (legalencs && legal != null)
                {
                    template = legal;
                }
                template.SetNickname(EasterEggs.GetMemeNickname(gen));
            }
            return(template);
        }
示例#2
0
 private static void AddPKM(SaveFile sav, ITrainerInfo tr, List <PKM> pklist, int species, int?form, bool shiny, ref int attempt)
 {
     if (tr.GetRandomEncounter(species, form, shiny, ref attempt, out var pk) && pk != null)
     {
         pk.Heal();
         pklist.Add(pk);
     }
     else if (sav is SAV2 && GetRandomEncounter(new SAV1(GameVersion.Y)
     {
         Language = tr.Language, OT = tr.OT, TID = tr.TID
     }, species, 0, shiny, ref attempt, out var pkm) && pkm is PK1 pk1)
     {
         pklist.Add(pk1.ConvertToPK2());
     }
 }
示例#3
0
        private static PKM GetEasterEggFromSet(this ITrainerInfo tr, IBattleTemplate set, PKM template)
        {
            var gen     = EasterEggs.GetGeneration(template.Species);
            var species = (int)EasterEggs.GetMemeSpecies(gen, template);

            template.Species = species;
            var attempt   = 0;
            var legalencs = tr.GetRandomEncounter(species, null, set.Shiny, false, ref attempt, out var legal);

            if (legalencs && legal != null)
            {
                template = legal;
            }
            template.SetNickname(EasterEggs.GetMemeNickname(gen, template));
            return(template);
        }