Skip to content

Commit

Permalink
bug with build (#92)
Browse files Browse the repository at this point in the history
* Feature/save game (#65)

* feat: add saving game

* refactor

* fix

* fix: some bug

* feat: better ai

* fix: tests en passant

* fix: isValidMove returns true for en passant capture

* fix: isValidMove returns true for en passant capture

* fix: add true

* Create CODE_OF_CONDUCT.md

Signed-off-by: Antoine Greuzard <[email protected]>

* Update issue templates

* refactor ai

* refactor board

* refactor piece

* refactor pieces

* refactor utils

* refactor canvas

* refactor timer

* fix: drag impossible on ai pieces

* fix: remove save game

---------

Signed-off-by: Antoine Greuzard <[email protected]>
Co-authored-by: Antoine GREUZARD <[email protected]>

* fix: remove saveGameToFile

* Update pull_request_template.md

Signed-off-by: Antoine Greuzard <[email protected]>

* fix: remove saveGameToFile

* refactor: add ai folder

* Create dependabot.yml

Signed-off-by: Antoine Greuzard <[email protected]>

* feat: add some jobs

* fix: add token

* fix: rename token to github_token

* feat: add letters and x,y on canvas

* remove dependabot

* feat: add @size-limit

* remove size-limit

* remove size-limit

* remove size-limit job

* feat: better sort

* feat: better quiescence

* feat: better board evaluation

* feat: better opening move

* feat: add tests

* feat: add tests

* feat: add tests

* feat: add tests

* feat: add tests

* feat: add tests

* refactor

* refactor

* refactor: console.log deleted

* refactor

* restore handlePromotion

* fix: add static

* fix: bug with build

* refactor

---------

Signed-off-by: Antoine Greuzard <[email protected]>
Co-authored-by: Antoine GREUZARD <[email protected]>
  • Loading branch information
antoinegreuzard and Antoine GREUZARD authored Nov 1, 2024
1 parent cdcc8df commit 6d44170
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export class Board implements BoardInterface {
if (piece && piece.color !== color) {
// Utilise `isThreatenedMove` pour éviter la récursion infinie
if (piece.type === PieceType.KING) {
if (King.isThreatenedMove(fromX, fromY, x, y)) {
if (piece.isThreatenedMove(fromX, fromY, x, y)) {
return true;
}
} else if (piece.isValidMove(fromX, fromY, x, y, this)) {
Expand Down
12 changes: 12 additions & 0 deletions src/piece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,16 @@ export abstract class Piece {
static async fromData(data: any): Promise<Piece> {
return await createPiece(data.type, data.color);
}

// Nouvelle méthode pour vérifier les menaces sans règles spécifiques du roi
public isThreatenedMove(
fromX: number,
fromY: number,
toX: number,
toY: number,
): boolean {
const dx = Math.abs(toX - fromX);
const dy = Math.abs(toY - fromY);
return dx <= 1 && dy <= 1;
}
}

0 comments on commit 6d44170

Please sign in to comment.