Skip to content

Commit

Permalink
Merge pull request #60 from Ido-Barnea/57-knight-is-in-the-wrong-square
Browse files Browse the repository at this point in the history
  • Loading branch information
Ido-Barnea authored Oct 18, 2023
2 parents 954aa5c + 5a8f841 commit 9f84333
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
15 changes: 4 additions & 11 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
README.md
tsconfig.json
package.json
package-lock.json
LICENSE
.gitignore
.github
assets
node_modules
dist
.parcel-cache
/node_modules
/dist
/.parcel-cache
*.md
nx.json
File renamed without changes.
16 changes: 8 additions & 8 deletions development/src/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ const blackPlayer: Player = {
export const players = [whitePlayer, blackPlayer];
export let pieces = [
new Rook([0, 0], players[1]),
new Bishop([1, 0], players[1]),
new Knight([2, 0], players[1]),
new Knight([1, 0], players[1]),
new Bishop([2, 0], players[1]),
new Queen([3, 0], players[1]),
new King([4, 0], players[1]),
new Knight([5, 0], players[1]),
new Bishop([6, 0], players[1]),
new Bishop([5, 0], players[1]),
new Knight([6, 0], players[1]),
new Rook([7, 0], players[1]),
new Pawn([0, 1], players[1]),
new Pawn([1, 1], players[1]),
Expand All @@ -51,12 +51,12 @@ export let pieces = [
new Pawn([6, 6], players[0]),
new Pawn([7, 6], players[0]),
new Rook([0, 7], players[0]),
new Bishop([1, 7], players[0]),
new Knight([2, 7], players[0]),
new Knight([1, 7], players[0]),
new Bishop([2, 7], players[0]),
new Queen([3, 7], players[0]),
new King([4, 7], players[0]),
new Knight([5, 7], players[0]),
new Bishop([6, 7], players[0]),
new Bishop([5, 7], players[0]),
new Knight([6, 7], players[0]),
new Rook([7, 7], players[0]),
];

Expand Down
6 changes: 5 additions & 1 deletion development/src/pieces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ function validateMove(

// Check if any square along the piece's path is occupied (not including the destination square)
const targetPiece = getPieceByPosition(nextPosition);
if (targetPiece && (!comparePositions(nextPosition, targetPosition) || !allowedToAttackOnLastStep)) {
if (
targetPiece &&
(!comparePositions(nextPosition, targetPosition) ||
!allowedToAttackOnLastStep)
) {
return false;
}

Expand Down

0 comments on commit 9f84333

Please sign in to comment.