/// <summary> /// Le pide al usuario que ingrese los datos del pokemon a cargar y valida la informacion /// </summary> /// <returns>El pokemon cargado</returns> static Pokemon CargaDatosPokemon() { #region Se deben validar los datos y por ultimo instanciar un nuevo Pokemon con los campos ingresados //Cargamos el nroDex short nroDex = Validaciones.ValidarNroDex(); //Cargamos el nombre string nombre = Validaciones.ValidarCadena("Ingrese el nombre del pokemon"); //Cargamos el nivel byte nivel = Validaciones.ValidarNivel(); //Cargamos el tipo Tipo tipo = Validaciones.ValidarTipo(); //Cargamos la pokebola Pokebola pokebola = Validaciones.ValidarPokebola(); //Cargamos el genero Genero genero = Validaciones.ValidarGenero(); //Cargamos los ataques string[] ataques = Validaciones.ValidarAtaques(); //Cargamos el trainer Entrenador entrenador = Validaciones.ValidarEntrenador(); //Cargamos el item bool item = Validaciones.ValidarItem(); #endregion return(new Pokemon(nroDex, nombre, nivel, tipo, genero, entrenador, pokebola, ataques, item)); }
public Pokemon(short nroDex, string nombre, byte nivel, Tipo tipo, Genero sexo, Entrenador entrenador, Pokebola pokebola, string[] ataquesParametro, bool tieneItem) { _nroDex = nroDex; _tipo = tipo; _pokebola = pokebola; _entrenador = entrenador; _nivel = nivel; _genero = sexo; this.Ataques = new string[Pokemon.LimiteAtaques]; #region Adaptando el array que llega como parametro if (ataquesParametro.Length <= Pokemon.LimiteAtaques) { for (int i = 0, j = 0; i < ataquesParametro.Length; i++) { if (ataquesParametro[i] != null) { //Lo guarda en la primera posicion de mi array de ataques this.Ataques[j++] = ataquesParametro[i]; } } } #endregion this.TieneItem = tieneItem; this.Nombre = nombre; }
public Pokemon[] ObtenerPorPokebola(Pokebola pokebola) { Pokemon[] todos = this.ObtenerTodosLosCapturados(); #region Obtengo la cantidad de pokemones capturados con esa pokebola int cantPokemon = 0; foreach (Pokemon pokemon in todos) { if (pokemon.AtrapadoCon == pokebola) { cantPokemon++; } } #endregion #region Guardo los pokemones capturados con esa pokebola en el nuevo array Pokemon[] pokemonesPorPokebola = new Pokemon[cantPokemon]; for (int i = 0, j = 0; i < todos.Length; i++) { if (todos[i].AtrapadoCon == pokebola) { pokemonesPorPokebola[j++] = todos[i]; } } #endregion return(pokemonesPorPokebola); }
public static int CantPokemonesPorPokebola(Pokebola pokebola) { int pokemonesPorPokebola = 0; foreach (Box box in PC.Boxes) { LogicaBox boxBL = new LogicaBox(box); pokemonesPorPokebola += boxBL.ObtenerPorPokebola(pokebola).Length; } return(pokemonesPorPokebola); }
static void MostrarPorPokebola(Pokebola pokebola) { LogicaBox box = new LogicaBox(LogicaPC.BoxSeleccionada); Pokemon[] pokemonPorPokebola = box.ObtenerPorPokebola(pokebola); if (!MenuMostrarPokemon.Mostrar(pokemonPorPokebola)) { Menu.CambiarColor(ConsoleColor.Red); Console.WriteLine($"No hay pokemones capturados con la '{pokebola.ToString().ToLower()}' en esta box."); } Menu.EspereUnaTecla(); }