public static void Main() { Game game = new Game(); while (!game.GameIsFinished) { Console.Clear(); Console.SetCursorPosition(0, 0); Console.WriteLine(game.GetGridAsString()); string message; message = game.KingIsOnTheMove ? "Please enter king's turn: " : "Please enter pawn's turn: "; while (true) { Console.Write(message); string userInput = GetUserInput(); if (userInput == string.Empty) { Console.WriteLine("Please enter something!"); continue; } if (game.ValidateCommand(userInput)) { if (ExecuteCommand(userInput, game)) { break; } else { if (game.CheckIfAllPawnsAreStuck()) { Console.WriteLine("King wins!"); } else if (game.CheckIfKingIsStuck()) { Console.WriteLine("King loses!"); } else { Console.WriteLine("You can't go in this direction! "); } } } else { Console.WriteLine("Illegal move!"); } } if (game.CheckIfKingExited()) { Console.WriteLine("End!"); Console.WriteLine("King wins in {0} moves!", game.KingTurns); break; } } Console.WriteLine("Game is finished!"); Console.WriteLine("\nThank you for using this game!\n\n"); }
public void TestPlayPawnIsStuck() { Game game = new Game(); game.PlayPawnMove('A', 'L'); bool result = game.CheckIfAllPawnsAreStuck(); bool expected = false; Assert.AreEqual(expected, result); }