Add king check highlighting feature
https://github.com/code100x/chess/assets/70210929/fc2a98c1-6e94-48f2-ae91-a7a7f8861f8d
@hkirat can you review the changes
@hkirat can you review the changes
Can you please impove the algorithm a bit. This is so much important. We cannot check with a 2 loops running and rerendering things in every single piece move. @hkirat Am I right?
@SujithThirumalaisamy @Sama-004
Just use chess.inCheck()
@SujithThirumalaisamy @Sama-004
Just use
chess.inCheck()
that is being used but how would you highlight the square king is on
When mapping through the board in the code, we get the access to piece and colour, can use that.
something like piece === "k" and chess.inCheck() And change the background colour if it's true
@SujithThirumalaisamy @Sama-004
Just use
chess.inCheck()
Oh he said there was no functions for that. My bad
@SujithThirumalaisamy @Sama-004 Just use
chess.inCheck()that is being used but how would you highlight the square king is on
use a global var or state somewhere. just mutate it when a new move comes. And if and only if the move is of a king. Update the state with the new king's location . Simple. You dont even want to itterate. Just get the king from the state. Do the check and update it. @nimit9 Your view on this man?
When mapping through the board in the code, we get the access to piece and colour, can use that.
something like piece === "k" and chess.inCheck() And change the background colour if it's true
@SujithThirumalaisamy this is how you should do it. We're using chess.js which gives you all the required information. No need to have a global state, or anything of that sort
When mapping through the board in the code, we get the access to piece and colour, can use that. something like piece === "k" and chess.inCheck() And change the background colour if it's true
@SujithThirumalaisamy this is how you should do it. We're using chess.js which gives you all the required information. No need to have a global state, or anything of that sort
trying this out
When mapping through the board in the code, we get the access to piece and colour, can use that. something like piece === "k" and chess.inCheck() And change the background colour if it's true
@SujithThirumalaisamy this is how you should do it. We're using chess.js which gives you all the required information. No need to have a global state, or anything of that sort
Perfect, Got it!
When mapping through the board in the code, we get the access to piece and colour, can use that. something like piece === "k" and chess.inCheck() And change the background colour if it's true
@SujithThirumalaisamy this is how you should do it. We're using chess.js which gives you all the required information. No need to have a global state, or anything of that sort
trying this out
No need of the extra function or extra loops, just add this to where we're looping through the board array and rendering the squares. @Sama-004
@nimit9 @SujithThirumalaisamy check this out
Have added the comments, also it'd be great if you can add a video recording of the feature.
Have added the comments, also it'd be great if you can add a video recording of the feature.
added
The color looks bad, can you use the same color as chess.com?
@Sama-004 could you please address the comments and make the changes?
@Sama-004 could you please address the comments and make the changes?
can't see any comment :(
Ohh, I'm unable to comment on the PR. They're in the pending state. @hkirat will have to approve the comments for it to show.
@nimit9 anything else?
@nimit9 anything else?
Haha, no, it's perfect now. Can be merged @hkirat
merging for now but there's a small issue I've pointed in the comments
Ohh, I'm unable to comment on the PR. They're in the pending state. @hkirat will have to approve the comments for it to show.
@nimit9 fyi: you need to press finish your review. Github collects your reviews thats why it is pending
https://github.com/orgs/community/discussions/10369
