Example #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);
        }
Example #2
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);
        }