diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2024-04-17 17:07:24 -0600 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2024-04-17 17:07:24 -0600 |
commit | 081adb89d7f5c8e80961e3873654be3473faef71 (patch) | |
tree | d64151ad8d3b06077dae64952d0bacdcd2e9a103 | |
parent | 8e5bf91607d5d222f22676411eda7c0ac9a90427 (diff) |
add option to get image name
-rw-r--r-- | Sources/SwiftChessNeo/Piece.swift | 11 | ||||
-rw-r--r-- | Tests/SwiftChessNeoTests/PlayerTests.swift (renamed from Tests/SwiftChessNeoTests/SwiftChessNeoPlayer.swift) | 0 | ||||
-rw-r--r-- | Tests/SwiftChessNeoTests/VariantTests.swift | 35 |
3 files changed, 46 insertions, 0 deletions
diff --git a/Sources/SwiftChessNeo/Piece.swift b/Sources/SwiftChessNeo/Piece.swift index 492ad87..d97efe1 100644 --- a/Sources/SwiftChessNeo/Piece.swift +++ b/Sources/SwiftChessNeo/Piece.swift @@ -287,6 +287,17 @@ public struct Piece: Hashable, CustomStringConvertible { case .king: return "♚" } } + + public func getNaturalName() -> String { + switch kind { + case .pawn: return self.color.isWhite ? "White Pawn" : "Black Pawn" + case .bishop: return self.color.isWhite ? "White Bishop" : "Black Bishop" + case .king: return self.color.isWhite ? "White King" : "Black King" + case .queen: return self.color.isWhite ? "White Queen" : "Black Queen" + case .rook: return self.color.isWhite ? "White Rook" : "Black Rook" + case .knight: return self.color.isWhite ? "White Knight" : "Black Knight" + } + } } diff --git a/Tests/SwiftChessNeoTests/SwiftChessNeoPlayer.swift b/Tests/SwiftChessNeoTests/PlayerTests.swift index b21b33c..b21b33c 100644 --- a/Tests/SwiftChessNeoTests/SwiftChessNeoPlayer.swift +++ b/Tests/SwiftChessNeoTests/PlayerTests.swift diff --git a/Tests/SwiftChessNeoTests/VariantTests.swift b/Tests/SwiftChessNeoTests/VariantTests.swift new file mode 100644 index 0000000..4f0513e --- /dev/null +++ b/Tests/SwiftChessNeoTests/VariantTests.swift @@ -0,0 +1,35 @@ +// +// VariantTests.swift +// +// +// Created by Navan Chauhan on 4/17/24. +// + +import XCTest + +final class VariantTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} |