Exemplo n.º 1
0
        private void StartRandomizing(int pokeNumber)
        {
            _teamSize = pokeNumber;

            var levelValidatorResult = LevelValidator.IsLevelValid(tbLevel.Text);

            if (levelValidatorResult == LevelValidatorResult.OK)
            {
                _pokemonList.Clear();
                _enemyPokemonList.Clear();

                int level = Convert.ToInt32(tbLevel.Text);

                for (int i = 0; i < pokeNumber; i++)
                {
                    _pokemonList.Add(PokemonFactory.CreatePokemon(level));
                    _enemyPokemonList.Add(PokemonFactory.CreatePokemon(level));
                }

                PrepareImages();
            }
            else if (levelValidatorResult == LevelValidatorResult.InvalidFormat)
            {
                MessageBox.Show("Incorrect level format (Only numbers)");
            }
            else if (levelValidatorResult == LevelValidatorResult.NotInRange)
            {
                MessageBox.Show("Level must be higher than 0 or 100 and less");
            }
        }
Exemplo n.º 2
0
        public static void FillPokemonList()
        {
            DataRowCollection pokemonDataRows = StaticSQL.GetPokemons().Rows;

            foreach (DataRow pokemonRow in pokemonDataRows)
            {
                var      values  = pokemonRow.ItemArray;
                IPokemon pokemon = PokemonFactory.CreatePokemon();

                pokemon.ID   = (int)values[0];
                pokemon.Name = (string)values[1];

                pokemon.Stats.Health         = (int)values[2];
                pokemon.Stats.Attack         = (int)values[3];
                pokemon.Stats.Defence        = (int)values[4];
                pokemon.Stats.SpecialAttack  = (int)values[5];
                pokemon.Stats.SpecialDefence = (int)values[6];
                pokemon.Stats.Speed          = (int)values[7];

                pokemon.PrimaryTypeID   = (int)values[8];
                pokemon.SecondaryTypeID = values[9] != DBNull.Value ? (int?)values[9] : null;
                pokemon.MinimalLevel    = (int)values[10];

                Pokemons.Add(pokemon.ID, pokemon);
            }
            AddAttacksToPokemons();
        }
Exemplo n.º 3
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog()
                {
                    Filter           = "Text Files (*.txt)|*.txt",
                    DefaultExt       = "txt",
                    AddExtension     = true,
                    RestoreDirectory = true,
                    InitialDirectory = $"{Environment.CurrentDirectory}\\ExportedObjects\\"
                };

                if (openFileDialog.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                PokemonImport pokemonImport = new PokemonImport(openFileDialog.FileName);

                var importedPokemons = pokemonImport.Import();
                if (importedPokemons.Any())
                {
                    _pokemonList.Clear();
                    _enemyPokemonList.Clear();
                    foreach (var importedPokemon in importedPokemons)
                    {
                        _pokemonList.Add(importedPokemon.ToDomainObject());
                        _enemyPokemonList.Add(PokemonFactory.CreatePokemon(importedPokemon.Level));
                    }

                    PrepareImages();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }