コード例 #1
0
        public bool SetRegenSettings(IEnumerable <string> lines)
        {
            var  split = RegenUtil.Split(lines);
            bool any   = false;

            foreach (var s in split)
            {
                var key   = s.Key;
                var value = s.Value;
                switch (key)
                {
                case nameof(Ball):
                    Ball = Aesthetics.GetBallFromString(value);
                    break;

                case nameof(Shiny):
                    ShinyType = Aesthetics.GetShinyType(value);
                    break;

                case nameof(Language):
                    Language = Aesthetics.GetLanguageId(value);
                    break;

                default:
                    continue;
                }
                any = true;
            }
            return(any);
        }
コード例 #2
0
ファイル: RegenSet.cs プロジェクト: jan2705/PKHeX-Plugins
 public RegenSet(ICollection <string> lines, int format, Shiny shiny = Shiny.Never)
 {
     Extra = new RegenSetting {
         ShinyType = shiny
     };
     HasExtraSettings   = Extra.SetRegenSettings(lines);
     HasTrainerSettings = RegenUtil.GetTrainerInfo(lines, format, out var tr);
     Trainer            = tr;
     Batch = new StringInstructionSet(lines);
 }
コード例 #3
0
ファイル: RegenSet.cs プロジェクト: jan2705/PKHeX-Plugins
        public string GetSummary()
        {
            var sb = new StringBuilder();

            if (HasExtraSettings)
            {
                sb.AppendLine(RegenUtil.GetSummary(Extra));
            }
            if (HasTrainerSettings && Trainer != null)
            {
                sb.AppendLine(RegenUtil.GetSummary(Trainer));
            }
            if (HasBatchSettings)
            {
                sb.AppendLine(RegenUtil.GetSummary(Batch));
            }
            return(sb.ToString());
        }
コード例 #4
0
        public RegenTemplate(ShowdownSet set, int gen = PKX.Generation) : this(set, gen, set.Text)
        {
            this.SanitizeForm();
            this.SanitizeBattleMoves();

            var shiny = Shiny ? Core.Shiny.Always : Core.Shiny.Never;

            if (set.InvalidLines.Count == 0)
            {
                Regen.Extra.ShinyType = shiny;
                return;
            }

            Regen = new RegenSet(set.InvalidLines, gen, shiny);
            Shiny = Regen.Extra.IsShiny;
            if (Ability == -1)
            {
                Ability = RegenUtil.GetRegenAbility(set.Species, gen, Regen.Extra.Ability);
            }
            set.InvalidLines.Clear();
        }
コード例 #5
0
        public bool SetRegenSettings(IEnumerable <string> lines)
        {
            var  split = RegenUtil.Split(lines);
            bool any   = false;

            foreach (var s in split)
            {
                var key   = s.Key;
                var value = s.Value;
                switch (key)
                {
                case nameof(Ball):
                    Ball = Aesthetics.GetBallFromString(value);
                    break;

                case nameof(Shiny):
                    ShinyType = Aesthetics.GetShinyType(value);
                    break;

                case nameof(Language):
                    Language = Aesthetics.GetLanguageId(value);
                    break;

                case nameof(Ability):
                    Ability = Enum.TryParse(value, out AbilityRequest ar) ? ar : AbilityRequest.Any;
                    break;

                case nameof(Alpha):
                    Alpha = value == "Yes";
                    break;

                default:
                    continue;
                }
                any = true;
            }
            return(any);
        }
コード例 #6
0
        /// <summary>
        /// Set Species and Level with nickname (Helps with PreEvos)
        /// </summary>
        /// <param name="pk">PKM to modify</param>
        /// <param name="set">Set to use as reference</param>
        /// <param name="Form">Form to apply</param>
        /// <param name="enc">Encounter detail</param>
        /// <param name="lang">Language to apply</param>
        public static void SetSpeciesLevel(this PKM pk, IBattleTemplate set, int Form, IEncounterable enc, LanguageID?lang = null)
        {
            pk.ApplySetGender(set);

            var evolutionRequired = pk.Species != set.Species;
            var formchange        = Form != pk.Form;

            if (evolutionRequired)
            {
                pk.Species = set.Species;
            }
            if (formchange)
            {
                pk.Form = Form;
            }

            if ((evolutionRequired || formchange) && pk is IScaledSizeValue sv)
            {
                sv.HeightAbsolute = sv.CalcHeightAbsolute;
                sv.WeightAbsolute = sv.CalcWeightAbsolute;
            }

            // Don't allow invalid tox nature, set random nature first and then statnature later
            if (pk.Species == (int)Species.Toxtricity)
            {
                while (true)
                {
                    var result = EvolutionMethod.GetAmpLowKeyResult(pk.Nature);
                    if (result == pk.Form)
                    {
                        break;
                    }
                    pk.Nature = Util.Rand.Next(25);
                }
            }

            pk.SetSuggestedFormArgument(enc.Species);
            if (evolutionRequired)
            {
                pk.RefreshAbility(pk.AbilityNumber >> 1);
            }

            pk.CurrentLevel = set.Level;
            if (pk.Met_Level > pk.CurrentLevel)
            {
                pk.Met_Level = pk.CurrentLevel;
            }
            if (set.Level != 100 && set.Level == enc.LevelMin && pk.Format is 3 or 4)
            {
                pk.EXP = Experience.GetEXP(enc.LevelMin + 1, PersonalTable.HGSS[enc.Species].EXPGrowth) - 1;
            }

            var currentlang = (LanguageID)pk.Language;
            var finallang   = lang ?? currentlang;

            if (finallang == LanguageID.Hacked)
            {
                finallang = LanguageID.English;
            }
            pk.Language = (int)finallang;

            // check if nickname even needs to be updated
            if (set.Nickname.Length == 0 && finallang == currentlang && !evolutionRequired)
            {
                return;
            }

            // don't bother checking encountertrade nicknames for length validity
            if (enc is EncounterTrade {
                HasNickname : true
            } et&& et.Nicknames.Contains(set.Nickname))
            {
                // Nickname matches the requested nickname already
                if (pk.Nickname == set.Nickname)
                {
                    return;
                }
                // This should be illegal except Meister Magikarp in BDSP, however trust the user and set corresponding OT
                var index = et.Nicknames.ToList().IndexOf(set.Nickname);
                pk.Nickname = set.Nickname;
                if (pk.Format >= 3)
                {
                    pk.OT_Name = et.TrainerNames[index];
                }
            }

            var gen      = enc.Generation;
            var maxlen   = Legal.GetMaxLengthNickname(gen, finallang);
            var newnick  = RegenUtil.MutateNickname(set.Nickname, finallang, (GameVersion)pk.Version);
            var nickname = newnick.Length > maxlen ? newnick[..maxlen] : newnick;