Beispiel #1
0
 public void Update(string[] data)
 {
     Ability       = new PokemonAbility(Convert.ToInt32(data[0]));
     Ailment       = data[1];
     Level         = Convert.ToInt32(data[2]);
     IsElite       = data[3].ToLowerInvariant() == "true";
     IsRare        = IsElite;
     Id            = Convert.ToInt32(data[5]);
     IsShiny       = (data[6].ToLowerInvariant() == "true");
     Form          = data[7];
     MaxHealth     = Convert.ToInt32(data[8]);
     CurrentHealth = Convert.ToInt32(data[9]);
 }
Beispiel #2
0
        internal Pokemon(string[] data)
        {
            if (data[0] != "")
            {
                UniqueId = Convert.ToInt32(data[0]);
            }
            if (data[32] != "")
            {
                Id = Convert.ToInt32(data[32]);
            }
            if (data[7] != "")
            {
                MaxHealth = Convert.ToInt32(data[7]);
            }
            if (data[27] != "")
            {
                CurrentHealth = Convert.ToInt32(data[27]);
            }
            if (data[31] != "" && data[29] != "" && data[28] != "")
            {
                Experience = new PokemonExperience(Convert.ToInt32(data[31]), Convert.ToInt32(data[29]), Convert.ToInt32(data[28]));
            }
            IsShiny = (data[30].ToLowerInvariant() == "true");
            Status  = data[36];

            Moves = new PokemonMove[4];
            if (data[21] != "")
            {
                Moves[0] = new PokemonMove(1, Convert.ToInt32(data[21]), 999, 999); //Infinite PP lol
            }
            if (data[22] != "")
            {
                Moves[1] = new PokemonMove(2, Convert.ToInt32(data[22]), 999, 999);
            }
            if (data[23] != "")
            {
                Moves[2] = new PokemonMove(3, Convert.ToInt32(data[23]), 999, 999);
            }
            if (data[24] != "")
            {
                Moves[3] = new PokemonMove(4, Convert.ToInt32(data[24]), 999, 999);
            }

            OriginalTrainer = data[38];
            Form            = data[39];

            _nature = data[20];
            if (data[35] != "")
            {
                AbilityNo = Convert.ToInt32(data[35]);
                Ability   = new PokemonAbility(AbilityNo);
            }
            if (data[37] != "")
            {
                AbilityLength = Convert.ToInt32(data[37]);
            }
            if (data[1] != "")
            {
                Happiness = Convert.ToInt32(data[1]);
            }
            ItemHeld = data[34];
            if (data[2] != "")
            {
                Stats = new PokemonStats(data, 2, MaxHealth);
            }
            Ailment = data[36];
            if (data[14] != "")
            {
                IV = new PokemonStats(data, 14);
            }
            if (data[8] != "")
            {
                EV = new PokemonStats(data, 8);
            }

            Type1 = TypesManager.Instance.Type1[Id];
            Type2 = TypesManager.Instance.Type2[Id];
        }
Beispiel #3
0
        public Pokemon(XmlNodeList node)
        {
            if (node is null)
            {
                return;
            }
            int damnR = int.MinValue;

            EV    = new PokemonStats();
            IV    = new PokemonStats();
            Stats = new PokemonStats();
            Moves = new PokemonMove[4];
            foreach (XmlNode no in node)
            {
                if (!int.TryParse(no.Attributes[0].Value, out damnR))
                {
                    if (no.Attributes[0].Value.ToLowerInvariant() == "moves")
                    {
                        foreach (XmlElement el in no)
                        {
                            switch (el.GetAttribute("n"))
                            {
                            case "3":
                                Moves[3] = new PokemonMove(4, Convert.ToInt32(el.InnerText), 999);     //Infinite PP lol
                                break;

                            case "2":
                                Moves[2] = new PokemonMove(3, Convert.ToInt32(el.InnerText), 999);     //Infinite PP lol
                                break;

                            case "1":
                                Moves[1] = new PokemonMove(2, Convert.ToInt32(el.InnerText), 999);     //Infinite PP lol
                                break;

                            case "0":
                                Moves[0] = new PokemonMove(1, Convert.ToInt32(el.InnerText), 999);     //Infinite PP lol
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (no.Attributes[0].Value)
                        {
                        //normal
                        case "id":
                            Id = Convert.ToInt32(no.InnerText);
                            break;

                        case "heldItem":
                            _itemHeld = no.InnerText;
                            break;

                        case "currentHp":
                            CurrentHealth = Convert.ToInt32(no.InnerText);
                            break;

                        case "hp":
                            MaxHealth    = Convert.ToInt32(no.InnerText);
                            Stats.Health = Convert.ToInt32(no.InnerText);
                            break;

                        case "uniqueId":
                            UniqueId = Convert.ToInt32(no.InnerText);
                            break;

                        case "nature":
                            _nature = no.InnerText;
                            break;

                        case "ability":
                            AbilityNo = Convert.ToInt32(no.InnerText);
                            Ability   = new PokemonAbility(AbilityNo);
                            break;

                        case "ailment":
                            Ailment = no.InnerText;
                            break;

                        case "ailmentLength":
                            AbilityLength = Convert.ToInt32(no.InnerText);
                            break;

                        case "exp":
                            exp = Convert.ToInt32(no.InnerText);
                            break;

                        case "level":
                            level = Convert.ToInt32(no.InnerText);
                            break;

                        case "totalExp":
                            totalExp = Convert.ToInt32(no.InnerText);
                            break;

                        case "originalCatcher":
                            OriginalTrainer = no.InnerText;
                            break;

                        case "happiness":
                            Happiness = Convert.ToInt32(no.InnerText);
                            break;

                        case "form":
                            Form = no.InnerText;
                            break;

                        case "status":
                            Status = no.InnerText;
                            break;

                        case "shiny":
                            IsShiny = no.InnerText != "0";
                            break;

                        //stat
                        case "attack":
                            Stats.Attack = Convert.ToInt32(no.InnerText);
                            break;

                        case "speed":
                            Stats.Speed = Convert.ToInt32(no.InnerText);
                            break;

                        case "defense":
                            Stats.Defence = Convert.ToInt32(no.InnerText);
                            break;

                        case "specialAttack":
                            Stats.SpAttack = Convert.ToInt32(no.InnerText);
                            break;

                        case "specialDefense":
                            Stats.SpDefence = Convert.ToInt32(no.InnerText);
                            break;

                        //iv
                        case "attackIV":
                            IV.Attack = Convert.ToInt32(no.InnerText);
                            break;

                        case "speedIV":
                            IV.Speed = Convert.ToInt32(no.InnerText);
                            break;

                        case "defenseIV":
                            IV.Defence = Convert.ToInt32(no.InnerText);
                            break;

                        case "specialAttackIV":
                            IV.SpAttack = Convert.ToInt32(no.InnerText);
                            break;

                        case "specialDefenseIV":
                            IV.SpDefence = Convert.ToInt32(no.InnerText);
                            break;

                        case "hpIV":
                            IV.Health = Convert.ToInt32(no.InnerText);
                            break;

                        //ev
                        case "attackEV":
                            EV.Attack = Convert.ToInt32(no.InnerText);
                            break;

                        case "speedEV":
                            EV.Speed = Convert.ToInt32(no.InnerText);
                            break;

                        case "defenseEV":
                            EV.Defence = Convert.ToInt32(no.InnerText);
                            break;

                        case "specialAttackEV":
                            EV.SpAttack = Convert.ToInt32(no.InnerText);
                            break;

                        case "specialDefenseEv":
                            EV.SpDefence = Convert.ToInt32(no.InnerText);
                            break;

                        case "hpEV":
                            EV.Health = Convert.ToInt32(no.InnerText);
                            break;
                        }
#if DEBUG
                        Console.WriteLine($"Name: {no.Attributes[0].Value} - Value:{no.InnerText}");
#endif
                    }
                }
            }
            Experience = new PokemonExperience(level, exp, totalExp);
            Type1      = TypesManager.Instance.Type1[Id];
            Type2      = TypesManager.Instance.Type2[Id];
        }