public List <HighScore> dohvatiHighscore(string razina) { List <HighScore> lista = new List <HighScore>(); string sql = "select * from highscores WHERE Razina = '" + razina + "' order by Minute,Sekunde"; SQLiteCommand command = new SQLiteCommand(sql, Connection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { HighScore highscore = new HighScore(); highscore.Ime = reader["Ime"].ToString(); highscore.Minute = reader["Minute"].ToString(); highscore.Sekunde = reader["Sekunde"].ToString(); highscore.Razina = reader["Razina"].ToString(); highscore.Vrijeme = highscore.Minute + ":" + highscore.Sekunde; lista.Add(highscore); } return(lista); }
public static void Main(string[] args) { string command = string.Empty; char[,] gameField = CreateGameField(); char[,] mines = PlaceBombs(); int movesCount = 0; bool isOnBomb = false; List <HighScore> winners = new List <HighScore>(6); int row = 0; int col = 0; bool isGameStartedThisTurn = true; const int MaximumMoves = 35; bool areAllFreeBoxesOpen = false; do { if (isGameStartedThisTurn) { Console.WriteLine("Hajde da igraem na “Mini4KI”. Probvaj si kasmeta da otkriesh poleteta bez mini4ki." + " Komanda 'top' pokazva klasiraneto, 'restart' po4va nova igra, 'exit' izliza i hajde 4ao!"); DisplayGameField(gameField); isGameStartedThisTurn = false; } Console.Write("Daj red i kolona : "); command = Console.ReadLine().Trim(); if (command.Length >= 3) { if (int.TryParse(command[0].ToString(), out row) && int.TryParse(command[2].ToString(), out col) && row <= gameField.GetLength(0) && col <= gameField.GetLength(1)) { command = "turn"; } } switch (command) { case "top": Leaderboard(winners); break; case "restart": gameField = CreateGameField(); mines = PlaceBombs(); DisplayGameField(gameField); isOnBomb = false; isGameStartedThisTurn = false; break; case "exit": Console.WriteLine("4a0, 4a0, 4a0!"); break; case "turn": if (mines[row, col] != '*') { if (mines[row, col] == '-') { PlayerTurn(gameField, mines, row, col); movesCount++; } if (MaximumMoves == movesCount) { areAllFreeBoxesOpen = true; } else { DisplayGameField(gameField); } } else { isOnBomb = true; } break; default: Console.WriteLine("\nGreshka! nevalidna Komanda\n"); break; } if (isOnBomb) { DisplayGameField(mines); Console.Write("\nHrrrrrr! Umria gerojski s {0} to4ki. " + "Daj si niknejm: ", movesCount); string nickname = Console.ReadLine(); HighScore highScore = new HighScore(nickname, movesCount); if (winners.Count < 5) { winners.Add(highScore); } else { for (int i = 0; i < winners.Count; i++) { if (winners[i].Points < highScore.Points) { winners.Insert(i, highScore); winners.RemoveAt(winners.Count - 1); break; } } } winners.Sort((HighScore highScore1, HighScore highScore2) => highScore2.Name.CompareTo(highScore1.Name)); winners.Sort((HighScore highScore1, HighScore highScore2) => highScore2.Points.CompareTo(highScore1.Points)); Leaderboard(winners); gameField = CreateGameField(); mines = PlaceBombs(); movesCount = 0; isOnBomb = false; isGameStartedThisTurn = true; } if (areAllFreeBoxesOpen) { Console.WriteLine("\nBRAVOOOS! Otvri 35 kletki bez kapka kryv."); DisplayGameField(mines); Console.WriteLine("Daj si imeto, batka: "); string imeee = Console.ReadLine(); HighScore to4kii = new HighScore(imeee, movesCount); winners.Add(to4kii); Leaderboard(winners); gameField = CreateGameField(); mines = PlaceBombs(); movesCount = 0; areAllFreeBoxesOpen = false; isGameStartedThisTurn = true; } }while (command != "exit"); Console.WriteLine("Made in Bulgaria - Uauahahahahaha!"); Console.WriteLine("AREEEEEEeeeeeee."); Console.Read(); }