Beispiel #1
0
        bool Start()
        {
            ChessGame chessGame = new ChessGame();

            Console.WriteLine("This chess game does not allow En Passant or Castling.\nThe game is won by capturing the king instead of getting checkmate.\nTherefore you can put your own king in check.\n");
            chessGame.InitChessboard();
            DisplayChessboard(chessGame);
            PlayChess(chessGame);


            return(ProgramTools.LoopGame());
        }
Beispiel #2
0
 void PlayChess(ChessGame chessGame)
 {
     while (!chessGame.checkmate)
     {
         Position fromPos = new Position();
         Position toPos   = new Position();
         Console.WriteLine($"\n{chessGame.turn}'s turn:");
         fromPos = ReadPosition("Enter a from-position: ");
         toPos   = ReadPosition("Enter a to-position: ");
         while (!CheckMove(chessGame, fromPos, toPos))
         {
             fromPos = ReadPosition("Enter a from-position: ");
             toPos   = ReadPosition("Enter a to-position: ");
         }
         chessGame.DoMove(fromPos, toPos);
         Console.WriteLine();
         DisplayChessboard(chessGame);
     }
     Console.WriteLine($"\nCongratulations {chessGame.turn}, you won!");
 }