Board(Grid) -> FEN

This commit is contained in:
cdricms
2024-06-28 18:30:28 +02:00
parent c79e80680c
commit 501484558a
4 changed files with 64 additions and 5 deletions

View File

@@ -12,6 +12,20 @@ public enum Kind: String, CaseIterable {
}
}
func fenRepresentation(with color: Color) -> String {
let str =
switch self {
case .Pawn: "P"
case .Bishop: "B"
case .Knight: "N"
case .Rook: "R"
case .Queen: "Q"
case .King: "K"
}
return color == .White ? str : str.lowercased()
}
static subscript(_ c: Character) -> (Self, Color)? {
let v = c.uppercased()