示例#1
0
 private static string GetShowdownName(string species, string form)
 {
     if (string.IsNullOrWhiteSpace(form) || ShowdownUtil.IsInvalidForm(form))
     {
         return(species);
     }
     return($"{species}-{form}");
 }
示例#2
0
        private static PKM GetBruteForcedLegalMon(this ITrainerInfo tr, ShowdownSet set, PKM template)
        {
            var resetForm = ShowdownUtil.IsInvalidForm(set.Form);
            var trainer   = TrainerSettings.GetSavedTrainerData(template, tr);
            var legal     = BruteForce.ApplyDetails(template, set, resetForm, trainer);

            legal.SetAllTrainerData(trainer);
            return(legal);
        }
示例#3
0
        /// <summary>
        /// Fix Formes that are illegal outside of battle
        /// </summary>
        /// <param name="set">Original Showdown Set</param>
        /// <param name="changedSet">Edited Showdown Set</param>
        /// <returns>boolen that checks if a form is fixed or not</returns>
        private static bool FixFormes(ShowdownSet set, out ShowdownSet changedSet)
        {
            changedSet = set;
            var badForm = ShowdownUtil.IsInvalidForm(set.Form);

            if (!badForm)
            {
                return(false);
            }

            changedSet = new ShowdownSet(set.Text.Replace($"-{set.Form}", string.Empty));
            return(true);
        }
示例#4
0
        private static string GetURL(string speciesName, string form, string baseURL)
        {
            if (string.IsNullOrWhiteSpace(form) || ShowdownUtil.IsInvalidForm(form))
            {
                var spec = ConvertSpeciesToURLSpecies(speciesName).ToLower();
                return($"{baseURL}/{spec}/");
            }

            var urlSpecies = ConvertSpeciesToURLSpecies(speciesName);
            {
                var spec = urlSpecies.ToLower();
                var f    = ConvertFormToURLForm(form, urlSpecies).ToLower();
                return($"{baseURL}/{spec}-{f}/");
            }
        }
示例#5
0
        /// <summary>
        /// Fix Formes that are illegal outside of battle
        /// </summary>
        /// <param name="set">Original Showdown Set</param>
        /// <param name="changedSet">Edited Showdown Set</param>
        /// <returns>boolen that checks if a form is fixed or not</returns>
        private static bool FixFormes(ShowdownSet set, out ShowdownSet changedSet)
        {
            changedSet = set;
            var badForm = ShowdownUtil.IsInvalidForm(set.Form);

            if (!badForm)
            {
                return(false);
            }

            changedSet = new ShowdownSet(set.Text.Replace($"-{set.Form}", string.Empty));

            // Changed set handling for forme changes that affect battle-only moves
            ReplaceBattleOnlyMoves(changedSet);
            return(true);
        }
示例#6
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 ShowdownSet(ShowdownSet.GetShowdownText(pk));
            var legal = tr.GetLegalFromTemplate(pk, set, out var satisfied);

            if (satisfied)
            {
                return(legal);
            }

            var dest      = new PokeTrainerDetails(pk.Clone());
            var resetForm = ShowdownUtil.IsInvalidForm(set.Form);

            legal = BruteForce.ApplyDetails(pk, set, resetForm, dest);
            legal.SetTrainerData(dest);
            return(legal);
        }
示例#7
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)
            {
                Ball      = (Ball)pk.Ball,
                ShinyType = pk.ShinyXor == 0 ? Shiny.AlwaysSquare : pk.IsShiny ? Shiny.AlwaysStar : Shiny.Never
            };
            var legal = tr.GetLegalFromTemplate(pk, set, out var satisfied);

            if (satisfied)
            {
                return(legal);
            }

            var dest      = new PokeTrainerDetails(pk.Clone());
            var resetForm = ShowdownUtil.IsInvalidForm(set.Form);

            legal = BruteForce.ApplyDetails(pk, set, resetForm, dest);
            legal.SetTrainerData(dest);
            return(legal);
        }