Esempio n. 1
0
        /// <summary>
        /// API Legality
        /// </summary>
        /// <param name="tr">trainer data</param>
        /// <param name="set">showdown set to legalize from</param>
        /// <param name="template">pkm file to legalize</param>
        /// <param name="pkm">legalized pkm file</param>
        /// <returns>bool if the pokemon was legalized</returns>
        public static LegalizationResult TryAPIConvert(this ITrainerInfo tr, IBattleTemplate set, PKM template, out PKM pkm)
        {
            pkm = tr.GetLegalFromTemplateTimeout(template, set, out LegalizationResult satisfied);
            if (satisfied != LegalizationResult.Regenerated)
            {
                return(satisfied);
            }

            var trainer = TrainerSettings.GetSavedTrainerData(pkm, tr);

            pkm.SetAllTrainerData(trainer);
            return(LegalizationResult.Regenerated);
        }
Esempio n. 2
0
        /// <summary>
        /// Tries to regenerate the <see cref="pk"/> into a valid pkm.
        /// </summary>
        /// <param name="tr">Source/Destination trainer</param>
        /// <param name="pk">Currently invalid pkm data</param>
        /// <returns>Legalized PKM (hopefully legal)</returns>
        public static PKM Legalize(this ITrainerInfo tr, PKM pk)
        {
            var set = new RegenTemplate(pk, tr.Generation);

            return(tr.GetLegalFromTemplateTimeout(pk, set, out _));
        }