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