From 9a2495c874e2e7a2b9e2f978b10ef2b19959710c Mon Sep 17 00:00:00 2001 From: Mathieu GROUSSEAU Date: Sat, 18 Jan 2025 10:50:43 +0100 Subject: [PATCH] Board to String extensions --- CustomTypes/Package.swift | 6 +++- .../Sources/CustomTypes/CustomTypes.swift | 2 -- CustomTypes/Sources/CustomTypes/Display.swift | 35 +++++++++++++++++++ .../CustomTypesTests/CustomTypesTests.swift | 12 ------- .../Tests/CustomTypesTests/DisplayTests.swift | 21 +++++++++++ 5 files changed, 61 insertions(+), 15 deletions(-) delete mode 100644 CustomTypes/Sources/CustomTypes/CustomTypes.swift create mode 100644 CustomTypes/Sources/CustomTypes/Display.swift delete mode 100644 CustomTypes/Tests/CustomTypesTests/CustomTypesTests.swift create mode 100644 CustomTypes/Tests/CustomTypesTests/DisplayTests.swift diff --git a/CustomTypes/Package.swift b/CustomTypes/Package.swift index 3f2a492..ff70ef8 100644 --- a/CustomTypes/Package.swift +++ b/CustomTypes/Package.swift @@ -11,11 +11,15 @@ let package = Package( name: "CustomTypes", targets: ["CustomTypes"]), ], + dependencies: [ + .package(path: "../Model") + ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .target( - name: "CustomTypes"), + name: "CustomTypes", + dependencies: [ .product(name: "Model", package: "Model") ]), .testTarget( name: "CustomTypesTests", dependencies: ["CustomTypes"]), diff --git a/CustomTypes/Sources/CustomTypes/CustomTypes.swift b/CustomTypes/Sources/CustomTypes/CustomTypes.swift deleted file mode 100644 index 08b22b8..0000000 --- a/CustomTypes/Sources/CustomTypes/CustomTypes.swift +++ /dev/null @@ -1,2 +0,0 @@ -// The Swift Programming Language -// https://docs.swift.org/swift-book diff --git a/CustomTypes/Sources/CustomTypes/Display.swift b/CustomTypes/Sources/CustomTypes/Display.swift new file mode 100644 index 0000000..fdb9966 --- /dev/null +++ b/CustomTypes/Sources/CustomTypes/Display.swift @@ -0,0 +1,35 @@ +import Model + +extension Piece: CustomStringConvertible { + public var description: String { + switch self { + case .PlayerA: + "🔴" + case .PlayerB: + "🟡" + } + } +} + +extension Board: CustomStringConvertible, CustomDebugStringConvertible { + public var description: String { + var str = String() + + for row in 0..