예제 #1
0
        private void UpdateGameField(Figure currentFigure, Direction direction)
        {
            Position oldPosition = currentFigure.Position;
            Position displacement = GetDisplacement(direction);
            Position newPosition = oldPosition + displacement;
            char sign = gameBoard[oldPosition.Row, oldPosition.Column];
            gameBoard[oldPosition.Row, oldPosition.Column] = ' ';
            gameBoard[newPosition.Row, newPosition.Column] = sign;
            this.MoveCounter++; //we processed a valid command so the moves increment

            CheckForKingExit(newPosition.Row);
        }
예제 #2
0
        internal Position GetNewCoordinates(Figure currentFigure, Direction direction)
        {
            Position currentPosition = currentFigure.Position;
            Position displacement = GetDisplacement(direction);
            Position newPosition = currentPosition + displacement;

            if (IsValidGameBoardCell(newPosition))
            {
                return newPosition;
            }
            else
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.WriteLine("You can't move there!");
                Console.ResetColor();
                return null;
            }
        }