public void checkScoreFor100TilesGame(Player_Tiles player) { if (ListFor100Tiles.Count < 10) { ListFor100Tiles.Add(player); } else { Player_Tiles p = ListFor100Tiles[9] as Player_Tiles; if (player.seconds < p.seconds) { ListFor100Tiles.RemoveAt(9); ListFor100Tiles.Add(player); } } ListFor100Tiles.Sort(); writeResults("scoresFor100TilesGame.txt"); }
private void loadResults() { if (File.Exists("scoresFor1MinGame.txt")) { using (StreamReader reader = new StreamReader("scoresFor1MinGame.txt")) { string line; while ((line = reader.ReadLine()) != null) { string[] part = line.Split(' '); Player_Time p = new Player_Time(part[1], part[2], Convert.ToInt32(part[3])); ListFor1MinGame.Add(p); } } } if (File.Exists("scoresFor30SecGame.txt")) { using (StreamReader reader = new StreamReader("scoresFor30SecGame.txt")) { string line; while ((line = reader.ReadLine()) != null) { string[] part = line.Split(' '); Player_Time p = new Player_Time(part[1], part[2], Convert.ToInt32(part[3])); ListFor30SecGame.Add(p); } } } if (File.Exists("scoresFor100TilesGame.txt")) { using (StreamReader reader = new StreamReader("scoresFor100TilesGame.txt")) { string line; while ((line = reader.ReadLine()) != null) { string[] part = line.Split(' '); string name = part[1]; string surname = part[2]; string[] times = part[3].Split(':'); int sec = Convert.ToInt32(times[0]) * 60; sec += Convert.ToInt32(times[1]); Player_Tiles p = new Player_Tiles(name, surname, sec); ListFor100Tiles.Add(p); } } } if (File.Exists("scoresFor300TilesGame.txt")) { using (StreamReader reader = new StreamReader("scoresFor300TilesGame.txt")) { string line; while ((line = reader.ReadLine()) != null) { string[] part = line.Split(' '); string name = part[1]; string surname = part[2]; string[] times = part[3].Split(':'); int sec = Convert.ToInt32(times[0]) * 60; sec += Convert.ToInt32(times[1]); Player_Tiles p = new Player_Tiles(name, surname, sec); ListFor300Tiles.Add(p); } } } ListFor100Tiles.Sort(); ListFor300Tiles.Sort(); ListFor30SecGame.Sort(); ListFor1MinGame.Sort(); }