示例#1
0
        private string ParseLineMove(string line)
        {
            string moveString = line.Substring(line[1] == ' ' ? 2 : 1);

            if (!moveString.Contains(moves[237])) // Hidden Power
            {
                return(moveString);
            }

            // Defined Hidden Power
            if (moveString.Length > 13)
            {
                string type = moveString.Remove(0, 13);
                type = ReplaceAll(type, string.Empty, "[", "]", "(", ")"); // Trim out excess data
                int hpVal = Array.IndexOf(hptypes, type);                  // Get HP Type

                if (IVs.Any(z => z != 31))
                {
                    if (!HiddenPower.SetIVsForType(hpVal, IVs))
                    {
                        InvalidLines.Add($"Invalid IVs for Hidden Power Type: {type}");
                    }
                }
                else if (hpVal >= 0)
                {
                    IVs = PKX.SetHPIVs(hpVal, IVs); // Get IVs
                }
                else
                {
                    InvalidLines.Add($"Invalid Hidden Power Type: {type}");
                }
            }
            return(moves[237]);
        }
示例#2
0
        /// <summary>
        /// Sets the <see cref="PKM.IVs"/> to match a provided <see cref="hiddenPowerType"/>.
        /// </summary>
        /// <param name="pk">Pokémon to modify.</param>
        /// <param name="hiddenPowerType">Desired Hidden Power typing.</param>
        public static void SetHiddenPower(this PKM pk, int hiddenPowerType)
        {
            Span <int> IVs = stackalloc int[6];

            pk.GetIVs(IVs);
            HiddenPower.SetIVsForType(hiddenPowerType, IVs, pk.Format);
            pk.SetIVs(IVs);
        }
示例#3
0
 private IEnumerable <string> GetStringMoves()
 {
     foreach (int move in Moves.Where(move => move != 0 && move < Strings.Move.Count))
     {
         var str = $"- {Strings.Move[move]}";
         if (move == 237) // Hidden Power
         {
             str += $" [{Strings.Types[1+HiddenPower.GetType(IVs, Format)]}]";
         }
         yield return(str);
     }
 }
示例#4
0
 private IEnumerable <string> GetStringMoves()
 {
     foreach (int move in Moves.Where(move => move != 0 && move < moves.Length))
     {
         var str = $"- {moves[move]}";
         if (move == 237) // Hidden Power
         {
             str += $" [{hptypes[HiddenPower.GetType(IVs)]}]";
         }
         yield return(str);
     }
 }
示例#5
0
        /// <summary>
        /// Converts the <see cref="PKM"/> data into an importable set format for Pokémon Showdown.
        /// </summary>
        /// <param name="pkm">PKM to convert to string</param>
        /// <returns>New ShowdownSet object representing the input <see cref="pkm"/></returns>
        public ShowdownSet(PKM pkm)
        {
            if (pkm.Species <= 0)
            {
                return;
            }

            Format = pkm.Format;

            Nickname   = pkm.Nickname;
            Species    = pkm.Species;
            HeldItem   = pkm.HeldItem;
            Ability    = pkm.Ability;
            EVs        = pkm.EVs;
            IVs        = pkm.IVs;
            Moves      = pkm.Moves;
            Nature     = pkm.StatNature;
            Gender     = genders[pkm.Gender < 2 ? pkm.Gender : 2];
            Friendship = pkm.CurrentFriendship;
            Level      = Experience.GetLevel(pkm.EXP, pkm.PersonalInfo.EXPGrowth);
            Shiny      = pkm.IsShiny;
            Ball       = pkm.Ball;

            if (pkm is IGigantamax g)
            {
                CanGigantamax = g.CanGigantamax;
            }

            HiddenPowerType = HiddenPower.GetType(IVs, Format);
            if (pkm is IHyperTrain h)
            {
                for (int i = 0; i < 6; i++)
                {
                    if (h.GetHT(i))
                    {
                        IVs[i] = pkm.MaxIV;
                    }
                }
            }

            SetFormString(pkm.AltForm);
        }
示例#6
0
        private string ParseLineMove(string line)
        {
            const int hiddenPower = 237;
            string    moveString  = line.Substring(line[1] == ' ' ? 2 : 1).Split('/')[0].Trim();

            if (!moveString.StartsWith(Strings.Move[hiddenPower])) // Hidden Power
            {
                return(moveString);                                // regular move
            }
            if (moveString.Length <= 13)
            {
                return(Strings.Move[hiddenPower]);
            }

            // Defined Hidden Power
            string type = moveString.Substring(13);

            type = RemoveAll(type, ParenJunk);                                   // Trim out excess data
            int hpVal = StringUtil.FindIndexIgnoreCase(Strings.types, type) - 1; // Get HP Type

            HiddenPowerType = hpVal;
            if (IVs.Any(z => z != 31))
            {
                if (!HiddenPower.SetIVsForType(hpVal, IVs, Format))
                {
                    InvalidLines.Add($"Invalid IVs for Hidden Power Type: {type}");
                }
            }
            else if (hpVal >= 0)
            {
                IVs = HiddenPower.SetIVs(hpVal, IVs, Format); // Get IVs
            }
            else
            {
                InvalidLines.Add($"Invalid Hidden Power Type: {type}");
            }
            return(Strings.Move[hiddenPower]);
        }