Example #1
0
    public static Jugador ActualizarJugador(string nombre, string tipo, int edad, int id)
    {
        JugadorBLL.Update(nombre, tipo, edad, id);
        Jugador objJugador = JugadorBLL.SelectById(id);

        return(objJugador);
    }
        // Funcion que toma los datos para eliminar un jugador
        public static void deleteJugador(Usuario u)
        {
            JugadorBLL  servicioJugador  = new JugadorBLL();
            BitacoraBBL servicioBitacora = new BitacoraBBL();

            Console.WriteLine("Que jugador te gustaria eliminar? (ingresa solo el id)");
            listJugadores(u, false, false, true);
            Console.WriteLine("ID:");
            string idJugadorToDelete = Console.ReadLine();

            try
            {
                string rtaServer = servicioJugador.DeleteJugador(u.Codigo.ToString(), idJugadorToDelete);
                if (rtaServer == "\"OK\"")
                {
                    servicioBitacora.enviarPost(new Bitacora(u.Codigo, "Se elimino un jugador", TipoConsultaEnum.Eliminar_jugador));
                    Console.WriteLine("Jugador eliminado con exito!");
                    checkIfContinue(u);
                }
                else
                {
                    Console.WriteLine("Ups! Hubo un error del server:" + rtaServer);
                    deleteJugador(u);
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Hubo un error en el server:" + e.ToString());
                checkIfContinue(u);
            }
        }
Example #3
0
 public static int EliminarJugador(int idJugador)
 {
     try
     {
         JugadorBLL.Delete(idJugador);
         return(idJugador);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Example #4
0
 public void Iniciar()
 {
     for (int i = 0; i < 20; i++)
     {
         Jugadores j = new Jugadores();
         j.JugadorId = i + 1;
         j.Jugador   = "Jugador " + (i + 1);
         ListaJugadores.Add(j);
     }
     JugadorEnTurno = JugadorBLL.Buscar(1);
     JugadorLb.Text = JugadorEnTurno.Jugador;
 }
        public static void listBienes(string id, Boolean justShowing, Usuario u, Boolean justListingBienes)
        {
            BienBBL    servicioBienes  = new BienBBL();
            JugadorBLL servicioJugador = new JugadorBLL();
            // Aca voy a buscar ese jugador
            List <Bien> lst = servicioBienes.getAllBienes(Int32.Parse(id));

            if (lst.Capacity > 0)
            {
                Console.WriteLine("Los bienes del jugador " + id + " son:");
            }
            if (lst.Capacity > 0 && !justShowing)
            {
                foreach (var item in lst)
                {
                    Console.WriteLine("- " + item.Id + " - " + item.Nombre + " - $" + item.Precio.ToString());
                }
                Console.WriteLine("\n");
                if (!justListingBienes)
                {
                    userMethods.checkIfContinue(u);
                }
                // Console.WriteLine("Esos fueron los Bienes del jugador con que seguimos?");
                // userMethods.listOpciones(false);
                // userMethods.returnOpciones(userMethods.listOpciones(false), u);
            }
            else if (lst.Capacity > 0 && justShowing)
            {
                foreach (var item in lst)
                {
                    Console.WriteLine("- " + item.Id + " - " + item.Nombre + " - $" + item.Precio.ToString());
                }
                if (!justListingBienes)
                {
                    userMethods.checkIfContinue(u);
                }
            }
            else
            {
                Console.WriteLine("\n");
                Console.WriteLine("MM parece que el jugador no tiene bienes ¯|_(ツ)_|¯ ");
                userMethods.checkIfContinue(u);
            }
        }
        private void Movimiento_Tick(object sender, EventArgs e)
        {
            JugadorLb.Text = JugadorEnTurno.Jugador;
            DiaNUD.Value   = DiaSimulacion;
            LanzamientosTotalesNUD.Value = TotalLanzamientos;

            MovPX -= 5;

            if (MovPX - 47 <= 180)
            {
                MovPX = 700;
                TotalLanzamientos++;
                TipoLanzamiento();
                JugadorBatea();
                TipoBateoJugador();
                ContadorLanzamientos++;
            }
            else
            {
                AntesPB.Visible   = false;
                DespuesPB.Visible = true;
            }

            if (MovPX - 47 <= 500)
            {
                DespuesPB.Visible = false;
                AntesPB.Visible   = true;
            }

            PelotaPB.SetBounds(MovPX - 47, 92, 49, 38);

            if (ContadorLanzamientos == 5)
            {
                ContadorDias++; PadecimientoJugador(); ContadorLanzamientos = 0; DiaSimulacion++;
            }

            if (ContadorDias == 5)
            {
                ContadorDias      = 0;
                TotalLanzamientos = 0;
                JugadorEnTurno    = JugadorBLL.Buscar(JugadorEnTurno.JugadorId + 1);
                Actualizar();
            }
        }
        // Funcion que lista a los jugadores
        public static void listJugadores(Usuario u, Boolean justShowing, Boolean forBienes, Boolean deletingPlayers)
        {
            JugadorBLL     servicioJugador = new JugadorBLL();
            List <Jugador> lst             = servicioJugador.GetJugador(u.Codigo);

            foreach (var jugador in lst)
            {
                if (justShowing)
                {
                    Console.WriteLine(jugador.ToString());
                }
                else if (!justShowing)
                {
                    jugador.ToStringWithId();
                }
            }
            if (!forBienes && !deletingPlayers)
            {
                checkIfContinue(u);
            }
        }
        // Funcion que crea a los jugadores
        public static void createJugador(Usuario u)
        {
            JugadorBLL  servicioJugador  = new JugadorBLL();
            BitacoraBBL servicioBitacora = new BitacoraBBL();

            Console.WriteLine("Completa los campos para crear un jugador: \n");
            Console.WriteLine("Nombre:");
            string nombreJugador = Console.ReadLine();

            Console.WriteLine("Apellido:");
            string apellidoJugador = Console.ReadLine();

            Console.WriteLine("Fuerza (entre 1 y 10):");
            string fuerzaJugador = Console.ReadLine();

            Console.WriteLine("Angulo (entre 0 y 90):");
            string anguloJugador = Console.ReadLine();

            try
            {
                Jugador jugadorNuevo = new Jugador(1, u.Codigo, nombreJugador, apellidoJugador, Int32.Parse(fuerzaJugador), Int32.Parse(anguloJugador));
                string  rtaServer    = servicioJugador.SendJugador(jugadorNuevo);
                if (rtaServer == "\"OK\"")
                {
                    servicioBitacora.enviarPost(new Bitacora(u.Codigo, "Se creo un jugador", TipoConsultaEnum.Crear_jugador));
                    Console.WriteLine("Jugador creado con exito! Con que seguimos?");
                    checkIfContinue(u);
                }
                else
                {
                    Console.WriteLine("Ups! Hubo un error del server:" + rtaServer);
                    createJugador(u);
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Hubo un error en el server:" + e.ToString());
            }
        }
Example #9
0
    public static Jugador TraerJugador(int idJugador)
    {
        Jugador objJugador = JugadorBLL.SelectById(idJugador);

        return(objJugador);
    }
Example #10
0
    public static Jugador InsertarJugador(string nombre, string tipo, int edad)
    {
        Jugador objJugador = JugadorBLL.InsertWithReturn(nombre, tipo, edad);

        return(objJugador);
    }