Files
swift-chess/Sources/Engine/Square.swift
cdricms c36319d4d7 batman
2024-06-25 18:08:25 +02:00

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
}
}