Esempio n. 1
0
        /// <summary>
        /// lista de todas las victorias
        /// </summary>
        /// <returns>lista de todas las victorias</returns>
        public List <Victoria> CargarTop5Victoria()
        {
            List <Victoria> livi = new List <Victoria>();

            try
            {
                using (NpgsqlConnection con = new NpgsqlConnection(Configuracion.CadenaConexion))
                {
                    con.Open();
                    string sql = @"SELECT  id_jugador,tiempo FROM public.jugador_victoria;";

                    NpgsqlCommand    cmd    = new NpgsqlCommand(sql, con);
                    NpgsqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        Victoria vi = new Victoria()
                        {
                            id_jugador     = reader.GetInt32(0),
                            SegundoTotales = reader.GetInt32(1)
                        };

                        livi.Add(vi);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            return(livi);
        }
Esempio n. 2
0
 public VictoriaJugadores()
 {
     ListVic = new List <Victoria>();
     VicBO   = new VictoriaBO();
     vic     = new Victoria();
     juBO    = new JugadorBO();
     InitializeComponent();
 }
Esempio n. 3
0
        /// <summary>
        /// boton que trae los datos de la victoria del cada participante y los muestra en un datagrid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            Victoria victoria = new Victoria();
            int      cont     = 0;
            int      suma     = 0;
            int      id       = 0;

            try
            {
                List <Victoria> lisVic = new List <Victoria>();
                id = Convert.ToInt32(DataGrJugadores.CurrentRow.Cells["Id"].Value);
                if (id != 0)
                {
                    lisVic = VicBO.CargarVictoria_Jugador(id);
                    // for que trae el tiempo de la victoria
                    for (int i = 0; i < lisVic.Count; i++)
                    {
                        vic   = lisVic[i];
                        suma += vic.SegundoTotales;
                        cont += 1;
                    }
                    resulSegundos = suma / cont;

                    string num = VicBO.ConvertirTiempo(resulSegundos);

                    DTGDatosJug.Rows[0].Cells[0].Value = cont;

                    DTGDatosJug.Rows[0].Cells[1].Value = num;
                }
                else
                {
                    MessageBox.Show("Debes seleccionar un Jugador");
                }
            }
            catch (Exception q)
            {
                MessageBox.Show(q.Message);
                DTGDatosJug.Rows[0].Cells[0].Value = 0;

                DTGDatosJug.Rows[0].Cells[1].Value = 0;
            }
        }
Esempio n. 4
0
 // Cup of Tea: Switches Elizabeth or Victoria to her calm state. If already calm instead + 15 Stamina
 public override int Skill3()
 {
     if (Target[0].Name == "Elizabeth")
     {
         if (Target[0].allegiance == this.allegiance)   //is Elizabeth on our team?
         {
             Elizabeth elizabeth = (Elizabeth)Target[0];
             if (elizabeth.Transform)
             {
                 // transform is a unique boolean to the Schola Grandis girls
                 elizabeth.Transform = false;
             }
             else
             {
                 elizabeth.gainStamina(15);
             }
         }
     }
     else if (Target[0].Name == "Victoria")
     {
         if (Target[0].allegiance == this.allegiance)   //is Victoria on our team?
         {
             Victoria victoria = (Victoria)Target[0];
             if (victoria.Transform)
             {
                 // transform is a unique boolean to the Schola Grandis girls
                 victoria.Transform = false;
             }
             else
             {
                 victoria.gainStamina(15);
             }
         }
     }
     // This statement only runs if the target is neither Elizabeth or Victoria
     else
     {
         Target [0].gainStamina(15);
     }
     return(0);
 }
Esempio n. 5
0
        /// <summary>
        /// guarda una victoria en la base de datos
        /// </summary>
        /// <param name="resul">tiempo en segundos</param>
        /// <param name="id_jugador">id del jugador</param>
        public void GuardarVictoria(int resul, int id_jugador)
        {
            // bool Verifica = false;
            Victoria Vict = new Victoria();

            try
            {
                using (NpgsqlConnection con = new NpgsqlConnection(Configuracion.CadenaConexion))
                {
                    con.Open();
                    string        sql = @"INSERT INTO public.jugador_victoria(id_jugador, tiempo)  VALUES ( :id_jugador, :tiempo ) RETURNING id; ";
                    NpgsqlCommand cmd = new NpgsqlCommand(sql, con);
                    cmd.Parameters.AddWithValue(":id_jugador", id_jugador);
                    cmd.Parameters.AddWithValue(":tiempo", resul);
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// metodo encargado de extraer los 5 mejores partidas que pudieron resolver en el menor tiempo posible.
        /// </summary>
        public void Top5()
        {
            Victoria[] vecV     = new Victoria[5];
            int        segundos = 0;
            string     tiempoT  = "";

            // llsta con todas lass victorias de los jugadores
            ListVic = VicBO.CargarTop5Victorias();
            // vector que almacena los 5 mejores jugadores
            vecV = VicBO.Top5(ListVic);
            try
            {
                for (int i = 0; i < vecV.Length; i++)
                {
                    if (i == 0)
                    {
                        Jugador ju = new Jugador();
                        ju.Id         = vecV[i].id_jugador;
                        segundos      = vecV[i].SegundoTotales;
                        tiempoT       = VicBO.ConvertirTiempo(segundos);
                        ju            = juBO.CargarJugador(ju.Id);
                        Top5Compartir = "Nombre" + "        " + "Tiempo:  " + "\n" + ju.Nombre + "              " + tiempoT + "\n";
                        DTGRTop5.Rows[0].Cells[0].Value = ju.Nombre;
                        seriesArray[i] = "1: " + ju.Nombre.ToString();
                        DTGRTop5.Rows[0].Cells[1].Value = tiempoT;
                        puntos[i] = segundos;
                    }
                    if (i == 1)
                    {
                        Jugador ju = new Jugador();
                        ju.Id          = vecV[i].id_jugador;
                        segundos       = vecV[i].SegundoTotales;
                        tiempoT        = VicBO.ConvertirTiempo(segundos);
                        ju             = juBO.CargarJugador(ju.Id);
                        Top5Compartir += "\n" + ju.Nombre + "              " + tiempoT + "\n";
                        DTGRTop5.Rows[1].Cells[0].Value = ju.Nombre;
                        seriesArray[i] = "2: " + ju.Nombre.ToString();
                        DTGRTop5.Rows[1].Cells[1].Value = tiempoT;
                        puntos[i] = segundos;
                    }
                    if (i == 2)
                    {
                        Jugador ju = new Jugador();
                        ju.Id          = vecV[i].id_jugador;
                        segundos       = vecV[i].SegundoTotales;
                        tiempoT        = VicBO.ConvertirTiempo(segundos);
                        ju             = juBO.CargarJugador(ju.Id);
                        Top5Compartir += "\n" + ju.Nombre + "                " + tiempoT + "\n";
                        DTGRTop5.Rows[2].Cells[0].Value = ju.Nombre;
                        seriesArray[i] = "3: " + ju.Nombre.ToString();
                        DTGRTop5.Rows[2].Cells[1].Value = tiempoT;
                        puntos[i] = segundos;
                    }
                    if (i == 3)
                    {
                        Jugador ju = new Jugador();
                        ju.Id          = vecV[i].id_jugador;
                        segundos       = vecV[i].SegundoTotales;
                        tiempoT        = VicBO.ConvertirTiempo(segundos);
                        ju             = juBO.CargarJugador(ju.Id);
                        Top5Compartir += "\n" + ju.Nombre + "                " + tiempoT + "\n";
                        DTGRTop5.Rows[3].Cells[0].Value = ju.Nombre;
                        seriesArray[i] = "4: " + ju.Nombre.ToString();
                        DTGRTop5.Rows[3].Cells[1].Value = tiempoT;
                        puntos[i] = segundos;
                    }
                    if (i == 4)
                    {
                        Jugador ju = new Jugador();
                        ju.Id          = vecV[i].id_jugador;
                        segundos       = vecV[i].SegundoTotales;
                        tiempoT        = VicBO.ConvertirTiempo(segundos);
                        ju             = juBO.CargarJugador(ju.Id);
                        Top5Compartir += "\n" + ju.Nombre + "                " + tiempoT + "\n";
                        DTGRTop5.Rows[4].Cells[0].Value = ju.Nombre;
                        seriesArray[i] = "5: " + ju.Nombre.ToString();
                        DTGRTop5.Rows[4].Cells[1].Value = tiempoT;
                        puntos[i] = segundos;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// extrae un los 5 mejores tiempos de todas las victorias
        /// </summary>
        /// <param name="lisV">lista de todas las victorias</param>
        /// <returns>matriz con los 5 mejores tiempos</returns>
        public Victoria[] Top5(List <Victoria> lisV)
        {
            int con = 0;

            Victoria[] top5    = new Victoria[5];
            bool       verfica = false;
            bool       ver     = false;

            for (int i = 0; i < 5; i++)
            {
                top5[i] = new Victoria();
            }
            foreach (Victoria vict in lisV)
            {
                Victoria vic = lisV[con];

                int acum      = 0;
                int acum1     = 0;
                int acum2     = 0;
                int acum3     = 0;
                int idJuAcum  = 0;
                int idJuAcum1 = 0;
                int idJuAcum2 = 0;
                int idJuAcum3 = 0;
                ver = false;

                for (int i = 0; i < 5; i++)
                {
                    if (top5[i].SegundoTotales == 0 && verfica == false)
                    {
                        top5[i].SegundoTotales = vic.SegundoTotales;
                        top5[i].id_jugador     = vic.id_jugador;
                        verfica = true;
                    }

                    if (top5[i].SegundoTotales != 0 && vic.SegundoTotales < top5[i].SegundoTotales && ver == false)
                    {
                        int x = i;
                        acum     = top5[x].SegundoTotales;
                        idJuAcum = top5[x].id_jugador;
                        top5[x].SegundoTotales = vic.SegundoTotales;
                        top5[x].id_jugador     = vic.id_jugador;
                        x++;
                        if (x < 5)
                        {
                            acum1     = top5[x].SegundoTotales;
                            idJuAcum1 = top5[x].id_jugador;
                            top5[x].SegundoTotales = acum;
                            top5[x].id_jugador     = idJuAcum;
                        }
                        x++;
                        if (x < 5)
                        {
                            acum2     = top5[x].SegundoTotales;
                            idJuAcum2 = top5[x].id_jugador;
                            top5[x].SegundoTotales = acum1;
                            top5[x].id_jugador     = idJuAcum1;
                        }
                        x++;
                        if (x < 5)
                        {
                            acum3     = top5[x].SegundoTotales;
                            idJuAcum3 = top5[x].id_jugador;
                            top5[x].SegundoTotales = acum2;
                            top5[x].id_jugador     = idJuAcum2;
                        }
                        x++;
                        if (x < 5)
                        {
                            top5[x].SegundoTotales = acum3;
                            top5[x].id_jugador     = idJuAcum3;
                        }
                        ver = true;
                    }
                }
                con++;
                verfica = false;
            }
            return(top5);
        }