Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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> >();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 public bool LocationExists(Coordinates coordinates)
 {
     return(_chessBoard.LocationExists(coordinates));
 }