Here is my test.js code:
What I am doing here is creating the pieces and testing if the piece (when clicked) is able to move to a position, highlight the possible positions, and allow to move there, but the problem is, this never happens. The highlighting is not shown and I get an error that B.get is undefined.
My get function is defined in my Board.js code:
I am defining my pieces here:
I know that is probably a lot and I am really not sure if it is understandable, but what I am trying to do again is play a very basic game of chess in a browser (I can include the html, but it is very basic). There is no saving or anything like that. It just starts with white going first followed by black, etc. where players should be able to take pieces of the other side, but not their own. I do not want to check for checkmate yet. Just dealing with piece taking and movements. Any thoughts on this as it is really baffling me.
Bear Bibeault wrote:Welcome to the Ranch.
But yes, that's way too much code to wade through. I'd suggest setting breakpoints in the browser and checking where things aren't doing what you expect. Then you can ask more targeted questions on smaller code fragments.
Well, when I set a breakpoint, I seem to get an error that B.get is not a function. I am guessing this means that my get function is not properly detecting mouse clicks?
If you are getting a "get" is not defined errors, it means that you are referring to it out of scope. Certainly nothing's going to run correctly until such errors are gone. (Then you just to find any logic errors.)
If the B.get line (7) is throwing an error, then either B or B.get isn't defined at that point. Back-track why you think it should be and why it isn't.