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

            if (dt.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                ArkanoidDBcn.ExecuteNonquery("INSERT INTO PLAYER(nickname) VALUES " +
                                             $"('{nickname}')");
                return(false);
            }
        }
        public static List <Player> ObtainTopPlayers()
        {
            var       TopPlayers = new List <Player>();
            DataTable dt         = ArkanoidDBcn.ExecuteQuery("SELECT pl.nickname, sc.score " +
                                                             "FROM PLAYER pl, SCORE sc " +
                                                             "WHERE pl.idPlayer = sc.idPlayer " +
                                                             "ORDER BY sc.score DESC " +
                                                             "LIMIT 10");

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

            return(TopPlayers);
        }
示例#3
0
        //obteniendo el ID del jugador
        private void GettingScore()
        {
            string query = $"SELECT idPlayer FROM PLAYER WHERE nickname = '{_gn.CurrentPlayer.Nickname}'";

            var dt       = ArkanoidDBcn.ExecuteQuery(query);
            var dr       = dt.Rows[0];
            var idPlayer = Convert.ToInt32(dr[0].ToString());

            ArkanoidDBcn.ExecuteNonquery("INSERT INTO SCORE(idPlayer,score) VALUES " +
                                         $"({idPlayer},{GameData.score})");

            if (MessageBox.Show($"Su puntuación de {GameData.score}, se ha registrado correctamente",
                                "Arkanoid message", MessageBoxButtons.OK) == DialogResult.OK)
            {
                FrmMainMenu menu = new FrmMainMenu();
                menu.Show();
                Dispose();
            }
        }