25 lines
499 B
Swift
25 lines
499 B
Swift
public struct Square: Equatable {
|
|
|
|
public struct Position: Equatable {
|
|
public let file: Int8
|
|
public let rank: Int8
|
|
|
|
public var index: Int {
|
|
return Int(8*(8-rank)+file-1)
|
|
}
|
|
|
|
public static func == (lhs: Position, rhs: Position) -> Bool {
|
|
return lhs.index == rhs.index
|
|
}
|
|
}
|
|
|
|
public let position: Position
|
|
public let index: Int
|
|
var piece: Piece? = nil
|
|
public let color: Color
|
|
|
|
public static func == (lhs: Square, rhs: Square) -> Bool {
|
|
return lhs.position == rhs.position
|
|
}
|
|
}
|