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); }
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; } }