public PokemonData(int number, int form)
 {
     _moves = new ObservableCollection <LearnedMove>();
     _ev    = new Observable6D();
     Form   = RomData.GetPokemon(number, form);
 }
Exemplo n.º 2
0
        public PokemonData(int seed, string suiji)  //随机生成pm
        {
            _moves = new ObservableCollection <LearnedMove>();
            _ev    = new Observable6D();

            Random random = new Random(seed);
            bool   item_  = true;

            number = random.Next(1, 803);
            Form   = RomData.GetPokemon(number, form);

            int ff;

            ff = random.Next(RomData.Pokemons.ElementAtOrDefault(number - 1).Forms.Count());
            if (MegaPokemon.Contains(number) && (ff > 0))
            {
                item_ = SuitMegaStone(ff);
                ff    = 0;
            }
            if (number == 670 && ff <= 4)
            {
                ff = 0;
            }
            if (number == 025 || number == 351 || number == 384 || number == 421 || number == 493 || number == 555 || number == 647 || number == 648 || number == 649 || number == 658 || number == 666 || number == 669 || number == 671 || number == 676 || number == 678 || number == 681 || number == 710 || number == 711 || number == 718 && form == 4 || number == 773 || number == 774 || number == 778)
            {
                ff = 0;
            }
            if (number == 382 && form == 1)
            {
                _item = 9044;
                item_ = false;
            }
            if (number == 383 && form == 1)
            {
                _item = 9045;
                item_ = false;
            }
            if (number == 487 && ff == 1)
            {
                _item = 1003;
                item_ = false;
            }
            if (number == 718 && ff == 4)
            {
                ff = 2;
            }
            Form = RomData.GetPokemon(number, ff);

            Random genderrandom = new Random(random.Next());

            Gender = Form.Species.Genders.ElementAtOrDefault(genderrandom.Next(0, Form.Species.Genders.Count()));

            Nature = (PokemonNature)random.Next(0, 25);

            //for (int i = 0; i != 0; i = Form.Data.Abilities[random.Next(0, Form.Data.Abilities.Count())])
            //Ability = i;
            _abilityIndex = (Byte)random.Next(0, Form.Data.Abilities.Count());

            _Iv = new Observable6D(random.Next(0, 32), random.Next(0, 32), random.Next(0, 32), random.Next(0, 32), random.Next(0, 32), random.Next(0, 32));

            int[] ev    = new int[] { 0, 0, 0, 0, 0, 0 };
            int   index = 0;

            for (int i = 0; i < 127; i++)
            {
                while (true)
                {
                    index = random.Next(0, 6);
                    if (ev[index] <= 251)
                    {
                        ev[index] += 4;
                        break;
                    }
                }
            }
            _ev = new Observable6D(ev[0], ev[1], ev[2], ev[3], ev[4], ev[5]);

            GetLearnset();
            while (moveIds.Count() < 4 && moveIds.Count() < learnset.Count())
            {
                int x = learnset[random.Next(0, learnset.Count())];
                if (x != -1)
                {
                    AddMove(RomData.GetMove(x));
                }
            }
            if (number == 647 && HasMove(Ms.SECRET_SWORD))
            {
                Form = RomData.GetPokemon(number, 1);
            }

            Happiness = random.Next(0, 256);

            if (item_)
            {
ItemLoop:
                Item = RomData.Items.ElementAtOrDefault(random.Next(0, RomData.Items.Count()));
                if (UselessItem.Contains(Item) || (9000 <= Item && Item < 10004) || (11000 <= Item && Item < 12000 && number != 773) || (1300 <= Item && Item < 1400 && number != 649))
                {
                    goto ItemLoop;
                }
            }
        }