Esempio n. 1
0
        private static PKM GetLegalFromSet(this ITrainerInfo tr, ShowdownSet set, PKM template, out LegalizationResult msg)
        {
            if (AllowAPI)
            {
                bool success = tr.TryAPIConvert(set, template, out PKM pk);
                if (success)
                {
                    msg = LegalizationResult.Regenerated;
                    return(pk);
                }
                if (!AllowBruteForce)
                {
                    msg = LegalizationResult.Failed;
                    return(pk);
                }
            }

            if (AllowBruteForce)
            {
                msg = LegalizationResult.BruteForce;
                return(tr.GetBruteForcedLegalMon(set, template));
            }

            msg = LegalizationResult.Failed;
            return(template);
        }
Esempio n. 2
0
 private static PKM GetLegalFromSet(this ITrainerInfo tr, ShowdownSet set, PKM template, out LegalizationResult msg, bool allowAPI = true)
 {
     if (allowAPI && tr.TryAPIConvert(set, template, out PKM pk))
     {
         msg = LegalizationResult.Regenerated;
         return(pk);
     }
     msg = LegalizationResult.BruteForce;
     return(tr.GetBruteForcedLegalMon(set, template));
 }
Esempio n. 3
0
        /// <summary>
        /// Main method that calls both API legality and Bruteforce
        /// </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 (API, Bruteforce, Failure)</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);
            }

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

            if (AllowBruteForce)
            {
                msg = LegalizationResult.BruteForce;
                return(tr.GetBruteForcedLegalMon(set, template));
            }

            msg = LegalizationResult.Failed;
            if (EnableEasterEggs)
            {
                var gen = EasterEggs.GetGeneration(template.Species);
                template.Species = (int)EasterEggs.IllegalPKMMemeSpecies(gen);
                var legalencs = ModLogic.GetRandomEncounter(tr, (int)EasterEggs.IllegalPKMMemeSpecies(gen), out var legal);
                if (legalencs && legal != null)
                {
                    template = legal;
                }
                template.SetNickname(EasterEggs.IllegalPKMMemeNickname(gen));
            }
            return(template);
        }