Added commands to execute interactively
This commit is contained in:
@@ -55,7 +55,6 @@ public enum Kind: String, CaseIterable {
|
||||
|
||||
public class Piece: Hashable {
|
||||
#warning("TODO: To be removed, handle everything through the delegate")
|
||||
internal weak var board: Board?
|
||||
public internal(set) var color: Color
|
||||
public internal(set) var halfMoveCount: UInt8 = 0
|
||||
public var unicodeRepresentation: String {
|
||||
@@ -73,7 +72,7 @@ public class Piece: Hashable {
|
||||
internal var delegate: EventDelegate?
|
||||
|
||||
internal func move(to dst: Square.Position) throws {
|
||||
if !(legalPositions.contains { $0 == dst }) {
|
||||
guard (legalPositions.contains { $0 == dst }) else {
|
||||
throw Board.MoveFailure.destinationIsIllegal(pos: dst)
|
||||
}
|
||||
|
||||
@@ -83,7 +82,7 @@ public class Piece: Hashable {
|
||||
|
||||
#warning("This method should be better thought out.")
|
||||
internal func isLegal(on pos: Square.Position) -> Bool {
|
||||
if let board = board, let s = board[pos] {
|
||||
if let s = delegate?.getSquareInfo(on: pos) {
|
||||
if let p = s.piece {
|
||||
if p.color == color { return false }
|
||||
if let king = p as? King {
|
||||
|
||||
Reference in New Issue
Block a user