27 lines
613 B
Swift
27 lines
613 B
Swift
final class Rook: Piece, LinearMoves {
|
|
|
|
override var unicodeRepresentation: String {
|
|
return color == .Black ? "♜" : "♖"
|
|
}
|
|
|
|
override var pseudoLegalPositions: [Square.Position] {
|
|
return getLinearMoves(from: position)
|
|
}
|
|
|
|
override var legalPositions: [Square.Position] {
|
|
return pseudoLegalPositions.filter { isLegal(on: $0) }
|
|
}
|
|
|
|
override func isLegal(on pos: Square.Position) -> Bool {
|
|
super.isLegal(on: pos)
|
|
}
|
|
|
|
init(with color: Color, on position: Square.Position) {
|
|
super.init(kind: .Rook, on: position, with: color)
|
|
self.color = color
|
|
self.kind = .Rook
|
|
self.position = position
|
|
}
|
|
|
|
}
|