protected override ValidateChessPieceMoveResponse Handle(ValidateChessPieceMoveRequest request) { var isMoveAllowed = chessPieceCollection.GetChessPiece(request.ChessPieceKind).IsMoveAllowed( new ChessboardPosition(request.CurrentPosition.X, request.CurrentPosition.Y), new ChessboardPosition(request.TargetPosition.X, request.TargetPosition.Y)); return(isMoveAllowed ? ValidateChessPieceMoveResponse.ValidMove : ValidateChessPieceMoveResponse.InvalidMove); }
protected override GetChessPiecePossibleMovesResponse Handle(GetChessPiecePossibleMovesRequest request) { var currentPosition = new ChessboardPosition(request.ChessboardPosition.X, request.ChessboardPosition.Y); var possibleMoves = chessPieceCollection .GetChessPiece(request.ChessPieceKind) .GetPossibleMoves(currentPosition); return(new GetChessPiecePossibleMovesResponse( request.ChessboardPosition, possibleMoves.Select(m => new ChessboardPositionDto(m.To.X, m.To.Y)))); }