public static void Main() { IUserInterface userInterface = new ConsoleUserInterface(); IEngine engine = new MinesweeperEngine(userInterface); engine.Run(); }
public void TestIsPlayerGrandWinner() { MinesweeperEngine testGame = new MinesweeperEngine(); Cell[,] matrix = new Cell[5, 10]; for (int i = 0; i < 5; i++) { for (int j = 0; j < 9; j++) { matrix[i, j].Value = "3"; } matrix[i, 9].Value = "*"; } var result = testGame.IsPlayerGrandWinner(matrix, 5); Assert.AreEqual(true, result); /* Field mineFieldTest = new Minesweeper.Field(5, 10, 5); //mineFieldTest.Initialize(); Cell [,] testMineFiled = mineFieldTest.MineField; for (int i = 0; i < 5; i++) { for (int j = 0; j < 9; j++) { testMineFiled[i, j].Value = "4"; //testMineFiled[i, j].isFlagged = true; } //testMineFiled[i, 9].isBomb = true; testMineFiled[i, 9].Value = "*"; } var result = testGame.IsPlayerGrandWinner(testMineFiled, 5); Assert.AreEqual(true, result);*/ }
public void TestEndGameMetdod() { MinesweeperEngine testGame = new MinesweeperEngine(); // var winMessage = Messages.Success; // var failMessage = Messages.BoomMessage; testGame.EndGame(true, true); }
public static void Main() { IDataBase db = new DataBase(); ICommandManager commandManager = new CommandManager(); IInputReader reader = new ConsoleReader(); IOutputWriter writer = new ConsoleWriter { AutoFlush = true }; IEngine engine = new MinesweeperEngine(db, commandManager, reader, writer); engine.Run(); }
internal static void Main() { MinesweeperEngine.Play(); }
static void Main() { // Initialize the variables which rule the game string command = string.Empty; char[,] gamefield = MinesweeperEngine.CreateGamefield(); char[,] bombs = MinesweeperEngine.GenerateBombs(); List <Player> champions = new List <Player>(CHAMPIONS_LIST_SIZE); int row = 0; int column = 0; int moveCounter = 0; bool isBomb = false; bool isNewGame = true; bool isEndGame = false; // Run the game do { if (isNewGame) { Console.WriteLine( "Lets play Minesweeper. Try your luck. Find fields without bombs." + "To show the results enter - \"top\", to start new game enter - \"restart\"," + "to make move enter row and column separated by space, to exit enter - \"exit\""); MinesweeperEngine.PrintGamefield(gamefield); isNewGame = false; } command = ReadCommand(command, gamefield, ref row, ref column); switch (command) { case "top": MinesweeperEngine.PrintResults(champions); break; case "restart": gamefield = MinesweeperEngine.CreateGamefield(); bombs = MinesweeperEngine.GenerateBombs(); MinesweeperEngine.PrintGamefield(gamefield); isBomb = false; isNewGame = false; break; case "exit": Console.WriteLine("Bye, Bye, Bye!"); break; case "turn": if (bombs[row, column] != BOMB_SYMBOL) { MinesweeperEngine.Move(gamefield, bombs, row, column); moveCounter++; if (NOT_BOMBS_NUMBER == moveCounter) { isEndGame = true; } else { MinesweeperEngine.PrintGamefield(gamefield); } } else { isBomb = true; } break; default: Console.WriteLine(Environment.NewLine + "Invalid input! You should enter valid command - top, restart, valid row and column or exit" + Environment.NewLine); break; } // End current game and start new one if there is a bomb if (isBomb) { MinesweeperEngine.PrintGamefield(bombs); Console.Write(Environment.NewLine + "Game over! Your scores are {0}. Enter username: "******"Congratulations! You win this game."); MinesweeperEngine.PrintGamefield(bombs); Console.WriteLine("Enter username: "******"exit"); Console.WriteLine("Made in Bulgaria"); Console.WriteLine("Press any key to exit the program."); Console.Read(); }