Exemplo n.º 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, tr.Generation);
            }

            msg = tr.TryAPIConvert(set, template, out PKM pk);
            if (msg == LegalizationResult.Regenerated)
            {
                return(pk);
            }

            if (EnableEasterEggs)
            {
                return(tr.GetEasterEggFromSet(set, template));
            }
            return(template);
        }