fixed more colour issues
This commit is contained in:
parent
e95caa0015
commit
6b0a134230
@ -1,5 +1,5 @@
|
|||||||
from logic.move import Move, PieceMove
|
from logic.move import Move, PieceMove
|
||||||
from logic.pieces.piece import Piece
|
from logic.pieces.piece import Colour, Piece
|
||||||
from logic.position import Position
|
from logic.position import Position
|
||||||
|
|
||||||
class Pawn(Piece):
|
class Pawn(Piece):
|
||||||
@ -8,23 +8,23 @@ class Pawn(Piece):
|
|||||||
|
|
||||||
# can we capture to the left?
|
# can we capture to the left?
|
||||||
if self.pos.x > 0 and (
|
if self.pos.x > 0 and (
|
||||||
(self.colour == self.WHITE and (capturable_piece := board.piece_at(self.pos.x - 1, self.pos.y + 1)))
|
(self.colour == Colour.WHITE and (capturable_piece := board.piece_at(self.pos.x - 1, self.pos.y + 1)))
|
||||||
or
|
or
|
||||||
(self.colour == self.BLACK and (capturable_piece := board.piece_at(self.pos.x - 1, self.pos.y - 1)))
|
(self.colour == Colour.BLACK and (capturable_piece := board.piece_at(self.pos.x - 1, self.pos.y - 1)))
|
||||||
):
|
):
|
||||||
if capturable_piece.colour != self.colour:
|
if capturable_piece.colour != self.colour:
|
||||||
ret.append(PieceMove(self, capturable_piece.pos, is_capturing = True))
|
ret.append(PieceMove(self, capturable_piece.pos, is_capturing = True))
|
||||||
|
|
||||||
# can we capture to the right?
|
# can we capture to the right?
|
||||||
if self.pos.x < 7 and (
|
if self.pos.x < 7 and (
|
||||||
(self.colour == self.WHITE and (capturable_piece := board.piece_at(self.pos.x + 1, self.pos.y + 1)))
|
(self.colour == Colour.WHITE and (capturable_piece := board.piece_at(self.pos.x + 1, self.pos.y + 1)))
|
||||||
or
|
or
|
||||||
(self.colour == self.BLACK and (capturable_piece := board.piece_at(self.pos.x + 1, self.pos.y - 1)))
|
(self.colour == Colour.BLACK and (capturable_piece := board.piece_at(self.pos.x + 1, self.pos.y - 1)))
|
||||||
):
|
):
|
||||||
if capturable_piece.colour != self.colour:
|
if capturable_piece.colour != self.colour:
|
||||||
ret.append(PieceMove(self, capturable_piece.pos, is_capturing = True))
|
ret.append(PieceMove(self, capturable_piece.pos, is_capturing = True))
|
||||||
|
|
||||||
if self.colour == Piece.WHITE:
|
if self.colour == Colour.WHITE:
|
||||||
for dy in range(1, 3 if self.pos.y == 1 else 2):
|
for dy in range(1, 3 if self.pos.y == 1 else 2):
|
||||||
if self.pos.y + dy > 7 or board.piece_at(self.pos.x, self.pos.y + dy):
|
if self.pos.y + dy > 7 or board.piece_at(self.pos.x, self.pos.y + dy):
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user