yes
This commit is contained in:
@@ -29,13 +29,16 @@ final class Bishop: Piece, DiagonalMoves {
|
||||
if let king = piece as? King {
|
||||
delegate?.notify(.kingInCheck(self, on: king))
|
||||
legalPositions.removeLast()
|
||||
last = position
|
||||
return
|
||||
} else {
|
||||
delegate?.notify(
|
||||
.piecePinned(from: self, on: piece))
|
||||
last = position
|
||||
}
|
||||
last = position
|
||||
}
|
||||
}
|
||||
delegate?.addPieceToTarget(self, target: position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
final class King: Piece {
|
||||
typealias Threats = (Piece?, Piece?)
|
||||
var threats: Threats = (nil, nil)
|
||||
internal private(set) var threats: Threats = (nil, nil)
|
||||
|
||||
func insertThreat(_ piece: Piece) {
|
||||
if threats.0 == nil {
|
||||
threats.0 = piece
|
||||
return
|
||||
}
|
||||
|
||||
if threats.1 == nil {
|
||||
threats.1 = piece
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
override var unicodeRepresentation: String {
|
||||
return color == .Black ? "♚" : "♔"
|
||||
}
|
||||
|
||||
@@ -31,13 +31,16 @@ final class Queen: Piece, LinearMoves, DiagonalMoves {
|
||||
if let king = piece as? King {
|
||||
delegate?.notify(.kingInCheck(self, on: king))
|
||||
legalPositions.removeLast()
|
||||
last = position
|
||||
return
|
||||
} else {
|
||||
delegate?.notify(
|
||||
.piecePinned(from: self, on: piece))
|
||||
last = position
|
||||
}
|
||||
last = position
|
||||
}
|
||||
}
|
||||
delegate?.addPieceToTarget(self, target: position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,16 @@ final class Rook: Piece, LinearMoves {
|
||||
if let king = piece as? King {
|
||||
delegate?.notify(.kingInCheck(self, on: king))
|
||||
legalPositions.removeLast()
|
||||
last = position
|
||||
return
|
||||
} else {
|
||||
delegate?.notify(
|
||||
.piecePinned(from: self, on: piece))
|
||||
last = position
|
||||
}
|
||||
last = position
|
||||
}
|
||||
}
|
||||
delegate?.addPieceToTarget(self, target: position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user