implemented checkmate
Some checks failed
pre-release / Pre Release (push) Waiting to run
tagged-release / Tagged Release (push) Has been cancelled

This commit is contained in:
Karma Riuk
2025-01-31 18:19:27 +01:00
parent 496207861e
commit 6c0819428e
11 changed files with 73 additions and 11 deletions

View File

@ -4,7 +4,7 @@ class Knight(Piece):
def letter(self):
return "n"
def legal_moves(self, board: "Board") -> list["Move"]:
def legal_moves(self, board: "Board", / , looking_for_check = False) -> list["Move"]:
ret = []
for dx, dy in [
(+2, +1), (+1, +2), # north east
@ -15,5 +15,9 @@ class Knight(Piece):
move = self._move_for_position(board, self.pos.x + dx, self.pos.y + dy)
if move is not None:
ret.append(move)
if not looking_for_check and board.is_check_for(self.colour):
return self.keep_only_blocking(ret, board)
return ret