Sliding pieces moves are now illegal if after piece of same color
This commit is contained in:
@@ -7,6 +7,27 @@ final class Queen: Piece, LinearMoves, DiagonalMoves {
|
||||
return getDiagonalMoves(from: position) + getLinearMoves(from: position)
|
||||
}
|
||||
|
||||
override func getLegalPosition() {
|
||||
legalPositions = []
|
||||
var last: Square.Position? = nil
|
||||
for position in pseudoLegalPositions {
|
||||
if !isLegal(on: position) {
|
||||
last = position
|
||||
continue
|
||||
}
|
||||
|
||||
if !LinearDirection.isLegal(last: &last, current: position)
|
||||
&& !DiagonalDirection.isLegal(last: &last, current: position)
|
||||
{
|
||||
last = nil
|
||||
}
|
||||
|
||||
if last == nil {
|
||||
legalPositions.append(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func isLegal(on pos: Square.Position) -> Bool {
|
||||
super.isLegal(on: pos)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user