public static PointsRecordDTOResponse FromResource(PointsRecord pointsRecord) { return(new PointsRecordDTOResponse { Id = pointsRecord.Id, Message = pointsRecord.Message, Creation = pointsRecord.CreatedAt }); }
/// <summary> /// afgjwhegekwhfkjwehfgjklwehgfklew /// </summary> /// <param name="args">wegwegwegew</param> private static void Main(string[] args) { string command = string.Empty; char[,] field = CreateGameField(); char[,] mines = PlaceMines(); int playerPointsCounter = 0; bool isBombExploded = false; List<PointsRecord> topRecords = new List<PointsRecord>(6); int row = 0; int column = 0; bool isFirstGameSinceLaunch = true; bool gameWon = false; do { if (isFirstGameSinceLaunch) { Console.WriteLine("Lets play Minesweeper!. Try to find the fields without mines. The command 'top' shows the rankings list, 'restart' starts new game, 'exit' exits the game."); DrawField(field); isFirstGameSinceLaunch = false; } Console.Write("Please enter row and column : "); command = Console.ReadLine().Trim(); if (command.Length >= 3) { if (int.TryParse(command[0].ToString(), out row) && int.TryParse(command[2].ToString(), out column) && row <= field.GetLength(0) && column <= field.GetLength(1)) { command = "turn"; } } switch (command) { case "top": DrawRanking(topRecords); break; case "restart": field = CreateGameField(); mines = PlaceMines(); DrawField(field); isBombExploded = false; isFirstGameSinceLaunch = false; break; case "exit": Console.WriteLine("bye,bye!"); break; case "turn": if (mines[row, column] != '*') { if (mines[row, column] == '-') { ProcessPlayerTurn(field, mines, row, column); playerPointsCounter++; } if (MAX_POINTS == playerPointsCounter) { gameWon = true; } else { DrawField(field); } } else { isBombExploded = true; } break; default: Console.WriteLine("\nError! invalid command\n"); break; } if (isBombExploded) { DrawField(mines); Console.Write("\nHrrrrrr! Your game is over with {{0}} points. Enter your nickname: ", playerPointsCounter); string nickName = Console.ReadLine(); PointsRecord newRecord = new PointsRecord(nickName, playerPointsCounter); if (topRecords.Count < 5) { topRecords.Add(newRecord); } else { for (int i = 0; i < topRecords.Count; i++) { if (topRecords[i].Points < newRecord.Points) { topRecords.Insert(i, newRecord); topRecords.RemoveAt(topRecords.Count - 1); break; } } } topRecords.Sort((PointsRecord r1, PointsRecord r2) => r2.Name.CompareTo(r1.Name)); topRecords.Sort((PointsRecord r1, PointsRecord r2) => r2.Points.CompareTo(r1.Points)); DrawRanking(topRecords); field = CreateGameField(); mines = PlaceMines(); playerPointsCounter = 0; isBombExploded = false; isFirstGameSinceLaunch = true; } if (gameWon) { Console.WriteLine("\nCongratulations! You stepped on 35 cells without exploding!"); DrawField(mines); Console.WriteLine("Please enter your nickname, f*cker: "); string playerName = Console.ReadLine(); PointsRecord playerPoints = new PointsRecord(playerName, playerPointsCounter); topRecords.Add(playerPoints); DrawRanking(topRecords); field = CreateGameField(); mines = PlaceMines(); playerPointsCounter = 0; gameWon = false; isFirstGameSinceLaunch = true; } } while (command != "exit"); Console.WriteLine("Made in Bulgaria - Uauahahahahaha!"); Console.WriteLine("AREEEEEEeeeeeee."); Console.Read(); }