implement function isLegal
implement function isLegal

Finally isLegal has been completed.
The tests still need to be added though and there are probably quite
some bugs in there.
Also it could get a little bit more comments.

jupiter24/web-chess,jupiter24/web-chess,jupiter24/web-chess,jupiter24/web-chess