Skip to content

Preventing King to castle when already in check#27

Open
gauravnetes wants to merge 1 commit intoprrockzed:mainfrom
gauravnetes:castle
Open

Preventing King to castle when already in check#27
gauravnetes wants to merge 1 commit intoprrockzed:mainfrom
gauravnetes:castle

Conversation

@gauravnetes
Copy link

…event castling while the king is in check

🚀 Pull Request Overview

Description

Modified the function getCastlingMoves in the KingMoves.ts file of the rules folder.
Added the logic to prevent the king to castle when the King is already in check.
Tested the output and it's working.

  • Bug Fix 🐛

🐛 Bug Fix:

  • Issue Fixed: [Link to the issue being fixed] ](Allows castling when king is in check #20 (comment))
  • Description of Fix: In the getCastlingMoves function there was written the logics to get the castling moves of King. Just added a few checks there to prevent the king from castling while already being checked.
  • Steps to Verify:
    1. The issue stated the King is allowed to castle even when it's in check. By the chess rules the king shouldn't be able to castle while being in a check.
    2. Checked by running into the local system and making some quick moves to check if the fix works and Yes it's working.

Additional Context

image


Open Source Programs

I'm associated with KWOC here.


✅ Checklist:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant