Can now move pieces
This commit is contained in:
@@ -17,37 +17,8 @@ final class Pawn: Piece {
|
||||
color == .Black ? "♟" : "♙"
|
||||
}
|
||||
|
||||
override func move(to dst: Square.Position) {
|
||||
if !(legalPositions.contains { $0 == dst }) {
|
||||
return
|
||||
}
|
||||
|
||||
delegate?.movePiece(self, to: dst)
|
||||
|
||||
// if let board = board, var s = board[position], var d = board[dst] {
|
||||
// s.piece = self
|
||||
// d.piece = nil
|
||||
// }
|
||||
|
||||
// position = dst
|
||||
|
||||
// return true
|
||||
}
|
||||
|
||||
override func isLegal(on pos: Square.Position) -> Bool {
|
||||
// TODO: Handle "En-Passant"
|
||||
if let board = board, let s = board[pos] {
|
||||
if let p = s.piece {
|
||||
if p.color == color { return false }
|
||||
if p.kind == .King {
|
||||
// TODO: Notify board of check
|
||||
delegate?.notify(.kingInCheck(self))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true
|
||||
super.isLegal(on: pos)
|
||||
}
|
||||
|
||||
init(with color: Color, on position: Square.Position) {
|
||||
|
||||
Reference in New Issue
Block a user