Linear + Diagonal moves
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
internal final class King: Piece {
|
||||
internal weak var board: Board?
|
||||
internal var kind: Kind = .King
|
||||
final class King: Piece {
|
||||
weak var board: Board?
|
||||
var kind: Kind = .King
|
||||
|
||||
internal var unicodeRepresentation: String {
|
||||
var unicodeRepresentation: String {
|
||||
return color == .Black ? "♛" : "♕"
|
||||
}
|
||||
internal var color: Color
|
||||
var color: Color
|
||||
|
||||
internal var position: Square.Position
|
||||
var position: Square.Position
|
||||
|
||||
internal var pseudoLegalPositions: [Square.Position] {
|
||||
var pseudoLegalPositions: [Square.Position] {
|
||||
return []
|
||||
}
|
||||
|
||||
internal var legalPositions: [Square.Position] {
|
||||
var legalPositions: [Square.Position] {
|
||||
return pseudoLegalPositions.filter { isLegal(on: $0) }
|
||||
}
|
||||
|
||||
internal func move(to dst: Square.Position) -> Bool {
|
||||
func move(to dst: Square.Position) -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
internal func isLegal(on pos: Square.Position) -> Bool {
|
||||
func isLegal(on pos: Square.Position) -> Bool {
|
||||
if let board = board, let s = board[pos] {
|
||||
if let p = s.piece {
|
||||
if p.color == color { return false }
|
||||
@@ -35,7 +35,7 @@ internal final class King: Piece {
|
||||
return true
|
||||
}
|
||||
|
||||
internal init(color: Color, on position: Square.Position) {
|
||||
init(color: Color, on position: Square.Position) {
|
||||
self.color = color
|
||||
self.position = position
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user