public static bool CreatePlayer(string nickname)
        {
            var dt = ConnectionDB.ExecuteQuery($"SELECT * FROM PLAYER WHERE nickname = '{nickname}'");

            if (dt.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                ConnectionDB.ExecuteNonQuery($"INSERT INTO PLAYER(nickname) VALUES ('{nickname}')");

                return(false);
            }
        }
        public static List <Player> PlayersTop()
        {
            var topPlayers = new List <Player>();
            var dt         = ConnectionDB.ExecuteQuery("SELECT PLAYER.nickname, SCORES.idscore " +
                                                       "FROM PLAYER, SCORES " +
                                                       "WHERE PLAYER.idPlayer = SCORES.idPlayer " +
                                                       "ORDER BY SCORES.idscore DESC " +
                                                       "LIMIT 10");

            foreach (DataRow dr  in dt.Rows)
            {
                topPlayers.Add(new Player(dr[0].ToString(), Convert.ToInt32(dr[1])));
            }

            return(topPlayers);
        }
Ejemplo n.º 3
0
        //Método encargada de guardar en una lista el nickname de los mejores 10 puntajes
        //ordenados de mayor a menor
        public static List <string> getNickName()
        {
            List <string> listScore = new List <string>();
            DataTable     dt        = null;

            try
            {
                dt = ConnectionDB.ExecuteQuery("SELECT nickname FROM SCORE ORDER BY score DESC, score LIMIT 10");
            }
            catch (Exception e)
            {
                MessageBox.Show("Ha ocurrido un error!");
            }

            foreach (DataRow row in dt.Rows)
            {
                listScore.Add(row[0].ToString());
            }
            return(listScore);
        }
Ejemplo n.º 4
0
        //Método que permite el acceso a la base de datos para identificar jugadores existentes
        public static List <Player> getPlayer()
        {
            DataTable     dt         = null;
            List <Player> listPlayer = new List <Player>();

            try
            {
                dt = ConnectionDB.ExecuteQuery("SELECT * FROM PLAYER");
            }
            catch (Exception e)
            {
                MessageBox.Show("Ha ocurrido un error!");
            }

            foreach (DataRow row in dt.Rows)
            {
                Player p = new Player();
                p.nickname = row[0].ToString();
                listPlayer.Add(p);
            }
            return(listPlayer);
        }
Ejemplo n.º 5
0
        //Método que permite el acceso a la base de datos para identificar los puntajes
        //de los jugadores existentes
        public static List <Score> getPlayerScore()
        {
            List <Score> listScore = new List <Score>();
            DataTable    dt        = null;

            try
            {
                dt = ConnectionDB.ExecuteQuery("SELECT * FROM SCORE");
            }
            catch (Exception e)
            {
                MessageBox.Show("Ha ocurrido un error!");
            }

            foreach (DataRow row in dt.Rows)
            {
                Score s = new Score();
                s.idScore  = Convert.ToInt32(row[0].ToString());
                s.score    = Convert.ToInt32(row[1].ToString());
                s.nickname = row[3].ToString();
                listScore.Add(s);
            }
            return(listScore);
        }