예제 #1
0
        public Rook(Coordinates startCoordinates, IChessBoard chessboard)
        {
            _chessboard = chessboard ?? throw new ArgumentNullException(nameof(chessboard));

            if (!_chessboard.LocationExists(startCoordinates))
            {
                throw new InvalidStartLocationException(startCoordinates);
            }

            Location = startCoordinates;
        }
예제 #2
0
        public Knight(Coordinates startCoordinates, IChessBoard chessboard, IMovementTracker movementTracker)
        {
            _chessboard      = chessboard ?? throw new ArgumentNullException(nameof(chessboard));
            _movementTracker = movementTracker ?? throw new ArgumentNullException(nameof(movementTracker));

            if (!_chessboard.LocationExists(startCoordinates))
            {
                throw new InvalidStartLocationException(startCoordinates);
            }

            Location = startCoordinates;
            _movementTracker.LogLocation(startCoordinates);
        }
예제 #3
0
        public KnightV2(Coordinates startCoordinates, IChessBoard chessboard)
        {
            _chessboard = chessboard ?? throw new ArgumentNullException(nameof(chessboard));

            if (!_chessboard.LocationExists(startCoordinates))
            {
                throw new InvalidStartLocationException(startCoordinates);
            }

            _isStartPosition = true;
            Location         = startCoordinates;

            _observers = new List <IObserver <Coordinates> >();
        }
예제 #4
0
        private KnightV2(Coordinates newCoordinates, IChessBoard chessboard, List <IObserver <Coordinates> > observers = null)
        {
            _chessboard = chessboard ?? throw new ArgumentNullException(nameof(chessboard));

            if (!_chessboard.LocationExists(newCoordinates))
            {
                throw new InvalidStartLocationException(newCoordinates);
            }

            _isStartPosition = false;
            Location         = newCoordinates;

            _observers = observers ?? new List <IObserver <Coordinates> >();
            PublishMovement(newCoordinates);
        }
예제 #5
0
 public bool LocationExists(Coordinates coordinates)
 {
     return(_chessBoard.LocationExists(coordinates));
 }