Create a Chess game with ReactJS part 29: King protection

Опубликовано: 29 Март 2026
на канале: Frontend Coding
1,031
24

Keeping track of the turns and preventing pieces from putting the king in danger is what we are going to talk about and implement in this episode of creating a chess game with React using TypeScript.

The code in this video can be found on the Frontend Coding GitHub repository:
https://github.com/FrontendCodingYT/c...

Timestamps:
0:00 Welcome! Short introduction.
1:10 Coding! Adding totalTurns variable.
3:30 Coding! Rendering the totalTurns on screen.
5:01 Explaining! How to determine the current team.
6:10 Coding! Only allow current team to play.
7:55 Explaining! Modulus.
11:55 Coding! Updating total turns.
16:00 Coding! Prevent both kings from danger moves.
17:18 Coding! Calculated currentTeam variable.
19:20 Coding! Using the currentTeam variable.
22:33 Coding! Fixing the king movement bug.
24:35 Coding! Only show possible moves if it's your turn.
28:05 Explaining! Illegal move scenario.
30:38 Coding! Checking all the moves from the team.
35:33 Coding! Looping through enemy pieces.
44:55 Explaining! Walking through the new function.
48:00 Coding! Fixing the bug in checkCurrentTeamMoves.
48:40 Demo! Is it working?
50:20 Coding! Removing destination piece.
53:10 Coding! Adding some more comments.
54:20 Thank you for watching! See you next time :)