Sliding pieces moves are now illegal if it's after the enemy
This commit is contained in:
@@ -22,6 +22,14 @@ final class Bishop: Piece, DiagonalMoves {
|
|||||||
}
|
}
|
||||||
if last == nil {
|
if last == nil {
|
||||||
legalPositions.append(position)
|
legalPositions.append(position)
|
||||||
|
if let square = delegate?.getSquareInfo(on: position),
|
||||||
|
let piece = square.piece
|
||||||
|
{
|
||||||
|
if piece.color != color {
|
||||||
|
delegate?.notify(.piecePinned(from: self, on: piece))
|
||||||
|
last = position
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ public enum Kind: String, CaseIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Piece: Hashable {
|
public class Piece: Hashable {
|
||||||
#warning("TODO: To be removed, handle everything through the delegate")
|
|
||||||
public internal(set) var color: Color
|
public internal(set) var color: Color
|
||||||
public internal(set) var halfMoveCount: UInt8 = 0
|
public internal(set) var halfMoveCount: UInt8 = 0
|
||||||
public var unicodeRepresentation: String {
|
public var unicodeRepresentation: String {
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ final class Queen: Piece, LinearMoves, DiagonalMoves {
|
|||||||
|
|
||||||
if last == nil {
|
if last == nil {
|
||||||
legalPositions.append(position)
|
legalPositions.append(position)
|
||||||
|
if let square = delegate?.getSquareInfo(on: position),
|
||||||
|
let piece = square.piece
|
||||||
|
{
|
||||||
|
if piece.color != color {
|
||||||
|
delegate?.notify(.piecePinned(from: self, on: piece))
|
||||||
|
last = position
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ final class Rook: Piece, LinearMoves {
|
|||||||
}
|
}
|
||||||
if last == nil {
|
if last == nil {
|
||||||
legalPositions.append(position)
|
legalPositions.append(position)
|
||||||
|
if let square = delegate?.getSquareInfo(on: position),
|
||||||
|
let piece = square.piece
|
||||||
|
{
|
||||||
|
if piece.color != color {
|
||||||
|
delegate?.notify(.piecePinned(from: self, on: piece))
|
||||||
|
last = position
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user