From b88867376a60313dcd8a571db74feda97afc72e3 Mon Sep 17 00:00:00 2001 From: "Louis.dufour" Date: Mon, 15 Jan 2024 12:09:41 +0100 Subject: [PATCH 1/7] =?UTF-8?q?Add(Tp1):=20Premi=C3=A8re=20partie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Extensions/.gitignore | 9 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + Extensions/Package.swift | 28 ++ Extensions/README.md | 3 + Extensions/Sources/Extensions/Animal.swift | 24 ++ Extensions/Sources/Extensions/Board.swift | 25 ++ Extensions/Sources/Extensions/CellType.swift | 21 ++ Extensions/Sources/Extensions/Owner.swift | 19 + .../ExtensionsTests/ExtensionsTests.swift | 11 + Model/.gitignore | 9 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + Model/Package.swift | 28 ++ Model/README.md | 3 + Model/Sources/Model/Animal.swift | 11 + Model/Sources/Model/Board.swift | 32 ++ Model/Sources/Model/Cell.swift | 25 ++ Model/Sources/Model/CellType.swift | 12 + Model/Sources/Model/Owner.swift | 21 ++ Model/Sources/Model/Piece.swift | 22 ++ Model/Tests/ModelTests/ModelTests.swift | 11 + .../project.pbxproj | 324 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + ProjectDouShouQi/Sources/main.swift | 64 ++++ 24 files changed, 733 insertions(+) create mode 100644 Extensions/.gitignore create mode 100644 Extensions/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Extensions/Package.swift create mode 100644 Extensions/README.md create mode 100644 Extensions/Sources/Extensions/Animal.swift create mode 100644 Extensions/Sources/Extensions/Board.swift create mode 100644 Extensions/Sources/Extensions/CellType.swift create mode 100644 Extensions/Sources/Extensions/Owner.swift create mode 100644 Extensions/Tests/ExtensionsTests/ExtensionsTests.swift create mode 100644 Model/.gitignore create mode 100644 Model/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Model/Package.swift create mode 100644 Model/README.md create mode 100644 Model/Sources/Model/Animal.swift create mode 100644 Model/Sources/Model/Board.swift create mode 100644 Model/Sources/Model/Cell.swift create mode 100644 Model/Sources/Model/CellType.swift create mode 100644 Model/Sources/Model/Owner.swift create mode 100644 Model/Sources/Model/Piece.swift create mode 100644 Model/Tests/ModelTests/ModelTests.swift create mode 100644 ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.pbxproj create mode 100644 ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 ProjectDouShouQi/Sources/main.swift diff --git a/Extensions/.gitignore b/Extensions/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/Extensions/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Extensions/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Extensions/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Extensions/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Extensions/Package.swift b/Extensions/Package.swift new file mode 100644 index 0000000..9b79cee --- /dev/null +++ b/Extensions/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Extensions", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "Extensions", + targets: ["Extensions"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "Extensions", + dependencies: []), + .testTarget( + name: "ExtensionsTests", + dependencies: ["Extensions"]), + ] +) diff --git a/Extensions/README.md b/Extensions/README.md new file mode 100644 index 0000000..6e5d31f --- /dev/null +++ b/Extensions/README.md @@ -0,0 +1,3 @@ +# Extensions + +A description of this package. diff --git a/Extensions/Sources/Extensions/Animal.swift b/Extensions/Sources/Extensions/Animal.swift new file mode 100644 index 0000000..d95fe89 --- /dev/null +++ b/Extensions/Sources/Extensions/Animal.swift @@ -0,0 +1,24 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation +import Model + +public extension Animal { + var symbol: String { + switch self { + case .rat: return "🐭" + case .cat: return "🐱" + case .dog: return "🐶" + case .wolf: return "🐺" + case .leopard: return "🐆" + case .tiger: return "🐯" + case .lion: return "🦁" + case .elephant: return "🐘" + } + } +} diff --git a/Extensions/Sources/Extensions/Board.swift b/Extensions/Sources/Extensions/Board.swift new file mode 100644 index 0000000..d1ebb98 --- /dev/null +++ b/Extensions/Sources/Extensions/Board.swift @@ -0,0 +1,25 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation +import Model + +public extension Board { + func toString() -> String { + var boardString = "" + for row in grid { + for cell in row { + let cellSymbol = cell.cellType.symbol + let pieceSymbol = cell.piece?.animal.symbol ?? " " + let ownerSymbol = cell.piece?.owner.symbol ?? " " + boardString += "\(cellSymbol)\(pieceSymbol)\(ownerSymbol) " + } + boardString += "\n\n" + } + return boardString + } +} diff --git a/Extensions/Sources/Extensions/CellType.swift b/Extensions/Sources/Extensions/CellType.swift new file mode 100644 index 0000000..241bd1a --- /dev/null +++ b/Extensions/Sources/Extensions/CellType.swift @@ -0,0 +1,21 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation +import Model + +public extension CellType { + var symbol: String { + switch self { + case .unknown: return " " + case .jungle: return "🌿" + case .water: return "💧" + case .trap: return "🪤" + case .den: return "🪹" + } + } +} diff --git a/Extensions/Sources/Extensions/Owner.swift b/Extensions/Sources/Extensions/Owner.swift new file mode 100644 index 0000000..1442715 --- /dev/null +++ b/Extensions/Sources/Extensions/Owner.swift @@ -0,0 +1,19 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation +import Model + +public extension Owner { + var symbol: String { + switch self { + case .noOne: return " " + case .player1: return "🟡" + case .player2: return "🔴" + } + } +} diff --git a/Extensions/Tests/ExtensionsTests/ExtensionsTests.swift b/Extensions/Tests/ExtensionsTests/ExtensionsTests.swift new file mode 100644 index 0000000..d129bd4 --- /dev/null +++ b/Extensions/Tests/ExtensionsTests/ExtensionsTests.swift @@ -0,0 +1,11 @@ +import XCTest +/*@testable import Extensions + +final class ExtensionsTests: XCTestCase { + 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. + XCTAssertEqual(Extensions().text, "Hello, World!") + } +}*/ diff --git a/Model/.gitignore b/Model/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/Model/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Model/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Model/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Model/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Model/Package.swift b/Model/Package.swift new file mode 100644 index 0000000..cda3b64 --- /dev/null +++ b/Model/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Model", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "Model", + targets: ["Model"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "Model", + dependencies: []), + .testTarget( + name: "ModelTests", + dependencies: ["Model"]), + ] +) diff --git a/Model/README.md b/Model/README.md new file mode 100644 index 0000000..3d677e7 --- /dev/null +++ b/Model/README.md @@ -0,0 +1,3 @@ +# Model + +A description of this package. diff --git a/Model/Sources/Model/Animal.swift b/Model/Sources/Model/Animal.swift new file mode 100644 index 0000000..543dff5 --- /dev/null +++ b/Model/Sources/Model/Animal.swift @@ -0,0 +1,11 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation + +public enum Animal: String { case rat, cat, dog, wolf, leopard, tiger, lion, elephant } + diff --git a/Model/Sources/Model/Board.swift b/Model/Sources/Model/Board.swift new file mode 100644 index 0000000..49187df --- /dev/null +++ b/Model/Sources/Model/Board.swift @@ -0,0 +1,32 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation + +public struct Board { + let nbRows: Int + let nbColumns: Int + private var grid: [[Cell]] + + public init?(withGrid grid: [[Cell]]) { + guard let firstRowLength = grid.first?.count, grid.allSatisfy({ $0.count == firstRowLength }) else { + return nil + } + + self.nbRows = grid.count + self.nbColumns = firstRowLength + self.grid=grid + } + + func getCell(atRow row: Int, column: Int) -> Cell? { + guard row >= 0, row < nbRows, column >= 0, column < nbColumns else { + return nil + } + return grid[row][column] + } +} + diff --git a/Model/Sources/Model/Cell.swift b/Model/Sources/Model/Cell.swift new file mode 100644 index 0000000..f080abf --- /dev/null +++ b/Model/Sources/Model/Cell.swift @@ -0,0 +1,25 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation + +public struct Cell { + let cellType: CellType + let initialOwner: Owner + var piece: Piece? + + public init(ofType cellType: CellType, ownedBy initialOwner: Owner = .noOne, withPiece piece: Piece? = nil) { + self.cellType = cellType + self.initialOwner = initialOwner + self.piece = piece + } + + func toString() -> String { + let pieceString = piece?.toString() ?? "ø" + return "\(pieceString) on .\(cellType), \(initialOwner.toString())" + } +} diff --git a/Model/Sources/Model/CellType.swift b/Model/Sources/Model/CellType.swift new file mode 100644 index 0000000..1430450 --- /dev/null +++ b/Model/Sources/Model/CellType.swift @@ -0,0 +1,12 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation + +public enum CellType { + case unknown, jungle, water, trap, den +} diff --git a/Model/Sources/Model/Owner.swift b/Model/Sources/Model/Owner.swift new file mode 100644 index 0000000..0a57e72 --- /dev/null +++ b/Model/Sources/Model/Owner.swift @@ -0,0 +1,21 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation + +public enum Owner { + case noOne, player1, player2 + + func toString() -> String { + switch self { + case .noOne: return "x" + case .player1: return "1" + case .player2: return "2" + } + } +} + diff --git a/Model/Sources/Model/Piece.swift b/Model/Sources/Model/Piece.swift new file mode 100644 index 0000000..db9fe11 --- /dev/null +++ b/Model/Sources/Model/Piece.swift @@ -0,0 +1,22 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation + +public struct Piece { + let owner: Owner + let animal: Animal + + public init(withOwner owner: Owner, andAnimal animal: Animal) { + self.owner = owner + self.animal = animal + } + + func toString() -> String { + return "[\(owner.toString()):\(animal)]" + } +} diff --git a/Model/Tests/ModelTests/ModelTests.swift b/Model/Tests/ModelTests/ModelTests.swift new file mode 100644 index 0000000..cf597ce --- /dev/null +++ b/Model/Tests/ModelTests/ModelTests.swift @@ -0,0 +1,11 @@ +import XCTest +/*@testable import Model + +final class ModelTests: XCTestCase { + 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. + XCTAssertEqual(Model().text, "Hello, World!") + } +}*/ diff --git a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.pbxproj b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.pbxproj new file mode 100644 index 0000000..bbb2172 --- /dev/null +++ b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.pbxproj @@ -0,0 +1,324 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 16F41E872B553BEA007D4B7F /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16F41E862B553BEA007D4B7F /* main.swift */; }; + 16F41E942B5546C4007D4B7F /* Model in Frameworks */ = {isa = PBXBuildFile; productRef = 16F41E932B5546C4007D4B7F /* Model */; }; + 16F41E962B5546C7007D4B7F /* Extensions in Frameworks */ = {isa = PBXBuildFile; productRef = 16F41E952B5546C7007D4B7F /* Extensions */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 16F41E812B553BEA007D4B7F /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 16F41E832B553BEA007D4B7F /* ProjectDouShouQi */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ProjectDouShouQi; sourceTree = BUILT_PRODUCTS_DIR; }; + 16F41E862B553BEA007D4B7F /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 16F41E8E2B553BFE007D4B7F /* Model */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Model; path = ../Model; sourceTree = ""; }; + 16F41E902B55409F007D4B7F /* Extensions */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Extensions; path = ../Extensions; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 16F41E802B553BEA007D4B7F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 16F41E962B5546C7007D4B7F /* Extensions in Frameworks */, + 16F41E942B5546C4007D4B7F /* Model in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 16F41E7A2B553BE9007D4B7F = { + isa = PBXGroup; + children = ( + 16F41E8D2B553BFE007D4B7F /* Packages */, + 16F41E852B553BEA007D4B7F /* Sources */, + 16F41E842B553BEA007D4B7F /* Products */, + 16F41E922B5546C4007D4B7F /* Frameworks */, + ); + sourceTree = ""; + }; + 16F41E842B553BEA007D4B7F /* Products */ = { + isa = PBXGroup; + children = ( + 16F41E832B553BEA007D4B7F /* ProjectDouShouQi */, + ); + name = Products; + sourceTree = ""; + }; + 16F41E852B553BEA007D4B7F /* Sources */ = { + isa = PBXGroup; + children = ( + 16F41E862B553BEA007D4B7F /* main.swift */, + ); + path = Sources; + sourceTree = ""; + }; + 16F41E8D2B553BFE007D4B7F /* Packages */ = { + isa = PBXGroup; + children = ( + 16F41E8E2B553BFE007D4B7F /* Model */, + 16F41E902B55409F007D4B7F /* Extensions */, + ); + name = Packages; + sourceTree = ""; + }; + 16F41E922B5546C4007D4B7F /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 16F41E822B553BEA007D4B7F /* ProjectDouShouQi */ = { + isa = PBXNativeTarget; + buildConfigurationList = 16F41E8A2B553BEA007D4B7F /* Build configuration list for PBXNativeTarget "ProjectDouShouQi" */; + buildPhases = ( + 16F41E7F2B553BEA007D4B7F /* Sources */, + 16F41E802B553BEA007D4B7F /* Frameworks */, + 16F41E812B553BEA007D4B7F /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ProjectDouShouQi; + packageProductDependencies = ( + 16F41E932B5546C4007D4B7F /* Model */, + 16F41E952B5546C7007D4B7F /* Extensions */, + ); + productName = ProjectDouShouQi; + productReference = 16F41E832B553BEA007D4B7F /* ProjectDouShouQi */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 16F41E7B2B553BE9007D4B7F /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1420; + LastUpgradeCheck = 1420; + TargetAttributes = { + 16F41E822B553BEA007D4B7F = { + CreatedOnToolsVersion = 14.2; + }; + }; + }; + buildConfigurationList = 16F41E7E2B553BE9007D4B7F /* Build configuration list for PBXProject "ProjectDouShouQi" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 16F41E7A2B553BE9007D4B7F; + productRefGroup = 16F41E842B553BEA007D4B7F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 16F41E822B553BEA007D4B7F /* ProjectDouShouQi */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 16F41E7F2B553BEA007D4B7F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 16F41E872B553BEA007D4B7F /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 16F41E882B553BEA007D4B7F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 16F41E892B553BEA007D4B7F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 16F41E8B2B553BEA007D4B7F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 16F41E8C2B553BEA007D4B7F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 16F41E7E2B553BE9007D4B7F /* Build configuration list for PBXProject "ProjectDouShouQi" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 16F41E882B553BEA007D4B7F /* Debug */, + 16F41E892B553BEA007D4B7F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 16F41E8A2B553BEA007D4B7F /* Build configuration list for PBXNativeTarget "ProjectDouShouQi" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 16F41E8B2B553BEA007D4B7F /* Debug */, + 16F41E8C2B553BEA007D4B7F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 16F41E932B5546C4007D4B7F /* Model */ = { + isa = XCSwiftPackageProductDependency; + productName = Model; + }; + 16F41E952B5546C7007D4B7F /* Extensions */ = { + isa = XCSwiftPackageProductDependency; + productName = Extensions; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 16F41E7B2B553BE9007D4B7F /* Project object */; +} diff --git a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ProjectDouShouQi/Sources/main.swift b/ProjectDouShouQi/Sources/main.swift new file mode 100644 index 0000000..29accda --- /dev/null +++ b/ProjectDouShouQi/Sources/main.swift @@ -0,0 +1,64 @@ +// +// main.swift +// ProjectDouShouQi +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation +import Model +import Extensions + +let initialBoardConfiguration: [[Cell]] = [ + // Ligne 1 + [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .lion)), + Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .den), Cell(ofType: .trap), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .tiger))], + + // Ligne 2 + [Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .dog)), + Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .jungle), + Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .cat)), Cell(ofType: .jungle)], + + // Ligne 3 + [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .rat)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .leopard)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .wolf)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .elephant))], + + // Lignes 4 à 7 (Eau et Jungle) + [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), + Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], + + [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), + Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], + + [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), + Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], + + [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), + Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], + + // Ligne 8 + [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .elephant)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .wolf)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .leopard)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .rat))], + + // Ligne 9 + [Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .cat)), + Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .jungle), + Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .dog)), Cell(ofType: .jungle)], + + // Ligne 10 + [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .tiger)), + Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .den), Cell(ofType: .trap), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .lion))] +] + +if let board = Board(withGrid: initialBoardConfiguration) { + // Afficher le plateau de jeu + print(board.toString()) +} else { + print("Erreur lors de l'initialisation du plateau de jeu.") +} From dc9927e478c40e85d7e4b66486634e4a354e9e95 Mon Sep 17 00:00:00 2001 From: Louis DUFOUR Date: Mon, 15 Jan 2024 12:16:01 +0100 Subject: [PATCH 2/7] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 216 +++++++----------------------------------------------- 1 file changed, 26 insertions(+), 190 deletions(-) diff --git a/README.md b/README.md index 2c8735f..b2d9291 100644 --- a/README.md +++ b/README.md @@ -1,196 +1,32 @@ -**Home** | [Semaine 1](./subject_week1.md) - -# Introduction +# Projet DouShouQi en Swift -- [Introduction](#introduction) -- [Dou Shou Qi](#dou-shou-qi) - - [**But du jeu** :](#but-du-jeu-) - - [**Matériel** :](#matériel-) - - [Pouvoir des animaux](#pouvoir-des-animaux) - - [Déroulement du jeu](#déroulement-du-jeu) -- [Déroulement des TP](#déroulement-des-tp) -- [Évaluation](#évaluation) -- [Structure de l'application](#structure-de-lapplication) -- [Énoncés](#énoncés) +## Introduction +Le projet DouShouQi en Swift est une implémentation console du jeu de plateau DouShouQi. +## Prérequis +- **Système d'exploitation**: macOS Ventura 13.1 +- **Logiciel**: Xcode version 14.2 -Cette introduction explique comment cette ressource va se dérouler, ce qu'il y aura à réaliser, et comment vous serez évaluées et évalués. -Pour découvrir le langage **Swift**, nous proposons de développer le modèle d'un jeu traditionnel chinois appelé le **Dou Shou Qi** dont les origines remontraient au Vème siècle. - -# Dou Shou Qi -## **But du jeu** : -- occuper la tanière de son adversaire -- ou manger toutes ses pièces -- ou l'empêcher de bouger. -## **Matériel** : -Chaque joueur possède 8 pions numérotés (pour représenter leur force) et représentant des animaux : **Rat** 🐭 (1), **Chat** 🐱 (2), **Chien** 🐶 (3), **Loup** 🐺 (4), **Léopard** 🐆 (5), **Tigre** 🐯 (6), **Lion** 🦁 (7) et **Éléphant** 🐘 (8). - -Le plateau de jeu est une grille à deux dimensions de 10 lignes et 7 colonnes. Il est fait de 4 types de cases : -- **Jungle** 🌿 : aucune particularité -- **Lac** 💧 : interdit à tous les animaux sauf le **Rat** ; le **Lion** et le **Tigre** peuvent sauter par-dessus. -- **Tanière** 🪹 : un joueur ne peut pas se déplacer sur sa propre **Tanière** et doit aller sur la **Tanière** de l'adversaire pour gagner -- **Piège** 🪤 : un pion sur un piège (quel que soit le côté du plateau) a une force de **0**. - -La grille originale ressemble à : - -🌿 🌿 🪤 🪹 🪤 🌿 🌿 -🌿 🌿 🌿 🪤 🌿 🌿 🌿 -🌿 🌿 🌿 🌿 🌿 🌿 🌿 -🌿 💧 💧 🌿 💧 💧 🌿 -🌿 💧 💧 🌿 💧 💧 🌿 -🌿 💧 💧 🌿 💧 💧 🌿 -🌿 💧 💧 🌿 💧 💧 🌿 -🌿 🌿 🌿 🌿 🌿 🌿 🌿 -🌿 🌿 🌿 🪤 🌿 🌿 🌿 -🌿 🌿 🪤 🪹 🪤 🌿 🌿 -(la tanière du haut est celle du joueur 1, celle du bas du joueur 2). - -De plus, certaines cases sont les cases de départ des pions : -🦁 🌿 🪤 🪹 🪤 🌿 🐯 -🌿 🐶 🌿 🪤 🌿 🐱 🌿 -🐭 🌿 🐆 🌿 🐺 🌿 🐘 -🌿 💧 💧 🌿 💧 💧 🌿 -🌿 💧 💧 🌿 💧 💧 🌿 -🌿 💧 💧 🌿 💧 💧 🌿 -🌿 💧 💧 🌿 💧 💧 🌿 -🐘 🌿 🐺 🌿 🐆 🌿 🐭 -🌿 🐱 🌿 🪤 🌿 🐶 🌿 -🐯 🌿 🪤 🪹 🪤 🌿 🦁 -(où les animaux du haut sont ceux du joueur 1, et ceux du bas du joueur 2). - -## Pouvoir des animaux -- Tous les animaux peuvent _manger_ un animal de force égale ou inférieure, avec les exceptions suivantes : - - l'éléphant ne peut pas _manger_ le rat, - - le rat peut _manger_ l'éléphant, - - on ne peut pas _manger_ son propre animal. -- Les animaux ne peuvent se déplacer que sur une case adjacente (même ligne ou même colonne) -- Les animaux ne peuvent pas se déplacer sur leur propre **Tanière** -- Les animaux ne peuvent pas se déplacer dans l'eau (sauf le **Rat**). Attention, le **Rat** ne peut pas sortir de l'eau pour attaquer l'**éléphant** adverse, mais il peut le faire pour attaquer le **rat** adverse. -- Le **lion** et le **tigre** peuvent sauter par-dessus les lacs (en restant sur la même ligne ou sur la même colonne), **sauf** si un **rat** est dans le lac, sur la trajectoire du saut. - -## Déroulement du jeu -Chaque joueur doit à son tour de jeu déplacer l'un de ses animaux. - -# Déroulement des TP - -L'objectif des TP est de réaliser cette application en 5 TP durant 6 semaines. -Les énoncés seront donnés en début de semaine ainsi qu'une liste de thème à travailler pour bien réussir le TP. -La sixième semaine sert de tampon, pour rattraper le retard accumulé pendant les semaines précédentes. -Pour chacune des 5 premières semaines, il est conseillé de : -- avant le TP : - - travailler les thèmes donnés en avance, via : - - la [documentation officielle du langage Swift](https://www.swift.org/documentation/) - - le [livre Apple sur le langage Swift](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) - - les [ressources de cours sur code first](https://codefirst.iut.uca.fr/documentation/mchCoursDocusaurus/docusaurus/Swift/) - - profiter du résumé en cours et poser des questions sur les parties non comprises -- pendant le TP : - - réaliser au maximum les tâches demandées - - et les faire valider par l'enseignant pour obtenir validation de l'acquisition des compétences -- après le TP : - - faire le point sur le "reste à faire" et s'organiser pour la semaine suivante - - faire le point sur les acquis que vous n'avez pas fait valider pour solliciter l'enseignant à la séance suivante - -Pour la sixième semaine : -- profiter du dernier cours pour poser les dernières questions techniques -- profiter du dernier TP pour rattraper le retard et faire valider ses derniers acquis non validés par l'enseignant. - -> Note : -> Les ressources de cours sur code first ne remplacent pas la documentation officielle. Elles apportent des conseils sur l'ordre de lecture dans la réalisation des TP. -> -# Évaluation - -Une fiche de compétences à acquérir et des points à réaliser en TP sera préparée et accessible pour chaque TP sur code first. -Vous aurez accès aux évaluations de l'enseignant au fur et à mesure de son évaluation. -Pour obtenir une validation, vous devrez prouver votre acquisition des compétences à l'enseignant via : un entretien oral ou un examen écrit. -La note finale sera composée de l'ensemble des acquis validés par l'enseignant à la dernière minute du dernier TP. - -# Structure de l'application - -Voici un diagramme de classes volontairement simplifié présentant grossièrement les différents acteurs de l'application que vous devez réaliser : - -```mermaid -classDiagram -direction TB - -Game --> "1" Rules : rules -Game --> "1" Board : board -Game --> "2" Player: players - -Rules <|.. ClassicRules -Rules <|.. VerySimpleRules - -Rules ..> Board -Board --> "*,*" Cell : grid - -Player <|-- RandomPlayer -Player <|-- HumanPlayer - -class Board { - +insert(piece:, atRow:, andColumn:) - +removePiece(atRow:, andColumn:) -} - -class Cell { - +cellType : CellType - +initialOwner: Owner - +piece : Piece? -} - -class Rules { - +createBoard() : Board$ - +getNextPlayer() : Owner - +isMoveValid(Board, Move) : Bool - +isGameOver(Board, Int, Int) : Bool -} - -class Player { - +chooseMove(in: Board, with: Rules) Move? -} - -class Game { - +init(withRules:, andPlayer1:, andPlayer2: Player) - +start() -} +## Installation et Configuration +### Étape 1 : Clonage du projet +``` +git clone ``` -- ```Board``` représente le plateau de jeu et est composé d'un tableau à deux dimensions de ```Cell``` : il est responsable de l'insertion, de la suppression et donc du déplacement des pions. -- ```Rules``` représente les règles du jeu. Comme elles sont assez touffues (```ClassicRules```), je vous proposerai des règles simplifiées (```VerySimpleRules```). ```Rules``` indique qui est le prochain joueur, si un coup est valide, si la partie est terminée, etc. -- ```Player``` représente un joueur. Nous en réaliserons deux versions en particulier : une *IA* qui jouera aléatoirement (```RandomPlayer```) et un joueur humain (```HumanPlayer```). -- ```Game``` : sert de médiateur et d'ordonnanceur pour la gestion globale du jeu. - -L'application à réaliser est une application en lignes de commandes qui permettra de jouer dans un terminal et ressemblera au résultat ci-dessous : - - - -Vous travaillerez sur : -- ```Board``` et ```Cell``` pendant les deux premières semaines, -- ```Rules``` et ```VerySimpleRules``` pendant la 3ème semaine, -- ```Player```, ```RandomPlayer``` et ```HumanPlayer``` pendant la 4ème semaine, -- ```Game``` et l'application finale pendant la 5ème semaine. - -Des énoncés plus détaillés vous seront donnés au début de chaque semaine. - -# Énoncés -- [Semaine 1](./subject_week1.md) - -**Home** | [Semaine 1](./subject_week1.md) - ---- -Copyright © 2023-2024 Marc Chevaldonné - -While writing this tutorial, I was listening to... - - - - - - -
- - -
-

On The Corner

-

Miles Davis (1972)

-
-
\ No newline at end of file +### Étape 2 : Ouvrir le projet dans Xcode +- Ouvrez Xcode. +- Cliquez sur "File" (Fichier) dans la barre de menu. +- Sélectionnez "Open" (Ouvrir). +- Naviguez jusqu'au répertoire où vous avez cloné le projet et ouvrez le fichier `.xcodeproj`. + +### Étape 3 : Compilation et exécution +- Appuyez sur le bouton de lecture (triangle vert) dans Xcode pour compiler et exécuter le projet. + +## Problèmes Connus et Solutions +- Refaire une structure de projet +- Un autre truc sur tostring +- On peu pas lire Owner, car internal (donc getter) +- Pareil pour cell +- Pareil pour board (peux pas la lire) +- Juste faire un print de board \ No newline at end of file From bdcd281f02068faf53587ab66851644f44223640 Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 15 Jan 2024 16:50:36 +0100 Subject: [PATCH 3/7] Add(Tp1): Folder subjects --- Sujets/README.md | 196 ++++++++++++++++++++ subject_week1.md => Sujets/subject_week1.md | 0 2 files changed, 196 insertions(+) create mode 100644 Sujets/README.md rename subject_week1.md => Sujets/subject_week1.md (100%) diff --git a/Sujets/README.md b/Sujets/README.md new file mode 100644 index 0000000..2c8735f --- /dev/null +++ b/Sujets/README.md @@ -0,0 +1,196 @@ +**Home** | [Semaine 1](./subject_week1.md) + + +# Introduction + +- [Introduction](#introduction) +- [Dou Shou Qi](#dou-shou-qi) + - [**But du jeu** :](#but-du-jeu-) + - [**Matériel** :](#matériel-) + - [Pouvoir des animaux](#pouvoir-des-animaux) + - [Déroulement du jeu](#déroulement-du-jeu) +- [Déroulement des TP](#déroulement-des-tp) +- [Évaluation](#évaluation) +- [Structure de l'application](#structure-de-lapplication) +- [Énoncés](#énoncés) + + +Cette introduction explique comment cette ressource va se dérouler, ce qu'il y aura à réaliser, et comment vous serez évaluées et évalués. +Pour découvrir le langage **Swift**, nous proposons de développer le modèle d'un jeu traditionnel chinois appelé le **Dou Shou Qi** dont les origines remontraient au Vème siècle. + +# Dou Shou Qi +## **But du jeu** : +- occuper la tanière de son adversaire +- ou manger toutes ses pièces +- ou l'empêcher de bouger. +## **Matériel** : +Chaque joueur possède 8 pions numérotés (pour représenter leur force) et représentant des animaux : **Rat** 🐭 (1), **Chat** 🐱 (2), **Chien** 🐶 (3), **Loup** 🐺 (4), **Léopard** 🐆 (5), **Tigre** 🐯 (6), **Lion** 🦁 (7) et **Éléphant** 🐘 (8). + +Le plateau de jeu est une grille à deux dimensions de 10 lignes et 7 colonnes. Il est fait de 4 types de cases : +- **Jungle** 🌿 : aucune particularité +- **Lac** 💧 : interdit à tous les animaux sauf le **Rat** ; le **Lion** et le **Tigre** peuvent sauter par-dessus. +- **Tanière** 🪹 : un joueur ne peut pas se déplacer sur sa propre **Tanière** et doit aller sur la **Tanière** de l'adversaire pour gagner +- **Piège** 🪤 : un pion sur un piège (quel que soit le côté du plateau) a une force de **0**. + +La grille originale ressemble à : + +🌿 🌿 🪤 🪹 🪤 🌿 🌿 +🌿 🌿 🌿 🪤 🌿 🌿 🌿 +🌿 🌿 🌿 🌿 🌿 🌿 🌿 +🌿 💧 💧 🌿 💧 💧 🌿 +🌿 💧 💧 🌿 💧 💧 🌿 +🌿 💧 💧 🌿 💧 💧 🌿 +🌿 💧 💧 🌿 💧 💧 🌿 +🌿 🌿 🌿 🌿 🌿 🌿 🌿 +🌿 🌿 🌿 🪤 🌿 🌿 🌿 +🌿 🌿 🪤 🪹 🪤 🌿 🌿 +(la tanière du haut est celle du joueur 1, celle du bas du joueur 2). + +De plus, certaines cases sont les cases de départ des pions : +🦁 🌿 🪤 🪹 🪤 🌿 🐯 +🌿 🐶 🌿 🪤 🌿 🐱 🌿 +🐭 🌿 🐆 🌿 🐺 🌿 🐘 +🌿 💧 💧 🌿 💧 💧 🌿 +🌿 💧 💧 🌿 💧 💧 🌿 +🌿 💧 💧 🌿 💧 💧 🌿 +🌿 💧 💧 🌿 💧 💧 🌿 +🐘 🌿 🐺 🌿 🐆 🌿 🐭 +🌿 🐱 🌿 🪤 🌿 🐶 🌿 +🐯 🌿 🪤 🪹 🪤 🌿 🦁 +(où les animaux du haut sont ceux du joueur 1, et ceux du bas du joueur 2). + +## Pouvoir des animaux +- Tous les animaux peuvent _manger_ un animal de force égale ou inférieure, avec les exceptions suivantes : + - l'éléphant ne peut pas _manger_ le rat, + - le rat peut _manger_ l'éléphant, + - on ne peut pas _manger_ son propre animal. +- Les animaux ne peuvent se déplacer que sur une case adjacente (même ligne ou même colonne) +- Les animaux ne peuvent pas se déplacer sur leur propre **Tanière** +- Les animaux ne peuvent pas se déplacer dans l'eau (sauf le **Rat**). Attention, le **Rat** ne peut pas sortir de l'eau pour attaquer l'**éléphant** adverse, mais il peut le faire pour attaquer le **rat** adverse. +- Le **lion** et le **tigre** peuvent sauter par-dessus les lacs (en restant sur la même ligne ou sur la même colonne), **sauf** si un **rat** est dans le lac, sur la trajectoire du saut. + +## Déroulement du jeu +Chaque joueur doit à son tour de jeu déplacer l'un de ses animaux. + +# Déroulement des TP + +L'objectif des TP est de réaliser cette application en 5 TP durant 6 semaines. +Les énoncés seront donnés en début de semaine ainsi qu'une liste de thème à travailler pour bien réussir le TP. +La sixième semaine sert de tampon, pour rattraper le retard accumulé pendant les semaines précédentes. +Pour chacune des 5 premières semaines, il est conseillé de : +- avant le TP : + - travailler les thèmes donnés en avance, via : + - la [documentation officielle du langage Swift](https://www.swift.org/documentation/) + - le [livre Apple sur le langage Swift](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) + - les [ressources de cours sur code first](https://codefirst.iut.uca.fr/documentation/mchCoursDocusaurus/docusaurus/Swift/) + - profiter du résumé en cours et poser des questions sur les parties non comprises +- pendant le TP : + - réaliser au maximum les tâches demandées + - et les faire valider par l'enseignant pour obtenir validation de l'acquisition des compétences +- après le TP : + - faire le point sur le "reste à faire" et s'organiser pour la semaine suivante + - faire le point sur les acquis que vous n'avez pas fait valider pour solliciter l'enseignant à la séance suivante + +Pour la sixième semaine : +- profiter du dernier cours pour poser les dernières questions techniques +- profiter du dernier TP pour rattraper le retard et faire valider ses derniers acquis non validés par l'enseignant. + +> Note : +> Les ressources de cours sur code first ne remplacent pas la documentation officielle. Elles apportent des conseils sur l'ordre de lecture dans la réalisation des TP. +> +# Évaluation + +Une fiche de compétences à acquérir et des points à réaliser en TP sera préparée et accessible pour chaque TP sur code first. +Vous aurez accès aux évaluations de l'enseignant au fur et à mesure de son évaluation. +Pour obtenir une validation, vous devrez prouver votre acquisition des compétences à l'enseignant via : un entretien oral ou un examen écrit. +La note finale sera composée de l'ensemble des acquis validés par l'enseignant à la dernière minute du dernier TP. + +# Structure de l'application + +Voici un diagramme de classes volontairement simplifié présentant grossièrement les différents acteurs de l'application que vous devez réaliser : + +```mermaid +classDiagram +direction TB + +Game --> "1" Rules : rules +Game --> "1" Board : board +Game --> "2" Player: players + +Rules <|.. ClassicRules +Rules <|.. VerySimpleRules + +Rules ..> Board +Board --> "*,*" Cell : grid + +Player <|-- RandomPlayer +Player <|-- HumanPlayer + +class Board { + +insert(piece:, atRow:, andColumn:) + +removePiece(atRow:, andColumn:) +} + +class Cell { + +cellType : CellType + +initialOwner: Owner + +piece : Piece? +} + +class Rules { + +createBoard() : Board$ + +getNextPlayer() : Owner + +isMoveValid(Board, Move) : Bool + +isGameOver(Board, Int, Int) : Bool +} + +class Player { + +chooseMove(in: Board, with: Rules) Move? +} + +class Game { + +init(withRules:, andPlayer1:, andPlayer2: Player) + +start() +} +``` + +- ```Board``` représente le plateau de jeu et est composé d'un tableau à deux dimensions de ```Cell``` : il est responsable de l'insertion, de la suppression et donc du déplacement des pions. +- ```Rules``` représente les règles du jeu. Comme elles sont assez touffues (```ClassicRules```), je vous proposerai des règles simplifiées (```VerySimpleRules```). ```Rules``` indique qui est le prochain joueur, si un coup est valide, si la partie est terminée, etc. +- ```Player``` représente un joueur. Nous en réaliserons deux versions en particulier : une *IA* qui jouera aléatoirement (```RandomPlayer```) et un joueur humain (```HumanPlayer```). +- ```Game``` : sert de médiateur et d'ordonnanceur pour la gestion globale du jeu. + +L'application à réaliser est une application en lignes de commandes qui permettra de jouer dans un terminal et ressemblera au résultat ci-dessous : + + + +Vous travaillerez sur : +- ```Board``` et ```Cell``` pendant les deux premières semaines, +- ```Rules``` et ```VerySimpleRules``` pendant la 3ème semaine, +- ```Player```, ```RandomPlayer``` et ```HumanPlayer``` pendant la 4ème semaine, +- ```Game``` et l'application finale pendant la 5ème semaine. + +Des énoncés plus détaillés vous seront donnés au début de chaque semaine. + +# Énoncés +- [Semaine 1](./subject_week1.md) + +**Home** | [Semaine 1](./subject_week1.md) + +--- +Copyright © 2023-2024 Marc Chevaldonné + +While writing this tutorial, I was listening to... + + + + + + +
+ + +
+

On The Corner

+

Miles Davis (1972)

+
+
\ No newline at end of file diff --git a/subject_week1.md b/Sujets/subject_week1.md similarity index 100% rename from subject_week1.md rename to Sujets/subject_week1.md From c4eac64efa04faf6efcd2eb3cdf73a77e3e84583 Mon Sep 17 00:00:00 2001 From: louis Date: Wed, 17 Jan 2024 12:41:33 +0100 Subject: [PATCH 4/7] Update(Tp1): workspace good --- .../project.pbxproj | 285 ++++++++++++++++++ DouShouQiConsole/DouShouQiConsole/main.swift | 11 + 2 files changed, 296 insertions(+) create mode 100644 DouShouQiConsole/DouShouQiConsole.xcodeproj/project.pbxproj create mode 100644 DouShouQiConsole/DouShouQiConsole/main.swift diff --git a/DouShouQiConsole/DouShouQiConsole.xcodeproj/project.pbxproj b/DouShouQiConsole/DouShouQiConsole.xcodeproj/project.pbxproj new file mode 100644 index 0000000..013f732 --- /dev/null +++ b/DouShouQiConsole/DouShouQiConsole.xcodeproj/project.pbxproj @@ -0,0 +1,285 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 167C5A152B57F0BC006FB682 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 167C5A142B57F0BC006FB682 /* main.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 167C5A0F2B57F0BC006FB682 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 167C5A112B57F0BC006FB682 /* DouShouQiConsole */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DouShouQiConsole; sourceTree = BUILT_PRODUCTS_DIR; }; + 167C5A142B57F0BC006FB682 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 167C5A0E2B57F0BC006FB682 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 167C5A082B57F0BC006FB682 = { + isa = PBXGroup; + children = ( + 167C5A132B57F0BC006FB682 /* DouShouQiConsole */, + 167C5A122B57F0BC006FB682 /* Products */, + ); + sourceTree = ""; + }; + 167C5A122B57F0BC006FB682 /* Products */ = { + isa = PBXGroup; + children = ( + 167C5A112B57F0BC006FB682 /* DouShouQiConsole */, + ); + name = Products; + sourceTree = ""; + }; + 167C5A132B57F0BC006FB682 /* DouShouQiConsole */ = { + isa = PBXGroup; + children = ( + 167C5A142B57F0BC006FB682 /* main.swift */, + ); + path = DouShouQiConsole; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 167C5A102B57F0BC006FB682 /* DouShouQiConsole */ = { + isa = PBXNativeTarget; + buildConfigurationList = 167C5A182B57F0BC006FB682 /* Build configuration list for PBXNativeTarget "DouShouQiConsole" */; + buildPhases = ( + 167C5A0D2B57F0BC006FB682 /* Sources */, + 167C5A0E2B57F0BC006FB682 /* Frameworks */, + 167C5A0F2B57F0BC006FB682 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DouShouQiConsole; + productName = DouShouQiConsole; + productReference = 167C5A112B57F0BC006FB682 /* DouShouQiConsole */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 167C5A092B57F0BC006FB682 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1420; + LastUpgradeCheck = 1420; + TargetAttributes = { + 167C5A102B57F0BC006FB682 = { + CreatedOnToolsVersion = 14.2; + }; + }; + }; + buildConfigurationList = 167C5A0C2B57F0BC006FB682 /* Build configuration list for PBXProject "DouShouQiConsole" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 167C5A082B57F0BC006FB682; + productRefGroup = 167C5A122B57F0BC006FB682 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 167C5A102B57F0BC006FB682 /* DouShouQiConsole */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 167C5A0D2B57F0BC006FB682 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 167C5A152B57F0BC006FB682 /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 167C5A162B57F0BC006FB682 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 167C5A172B57F0BC006FB682 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 167C5A192B57F0BC006FB682 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 167C5A1A2B57F0BC006FB682 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 167C5A0C2B57F0BC006FB682 /* Build configuration list for PBXProject "DouShouQiConsole" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 167C5A162B57F0BC006FB682 /* Debug */, + 167C5A172B57F0BC006FB682 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 167C5A182B57F0BC006FB682 /* Build configuration list for PBXNativeTarget "DouShouQiConsole" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 167C5A192B57F0BC006FB682 /* Debug */, + 167C5A1A2B57F0BC006FB682 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 167C5A092B57F0BC006FB682 /* Project object */; +} diff --git a/DouShouQiConsole/DouShouQiConsole/main.swift b/DouShouQiConsole/DouShouQiConsole/main.swift new file mode 100644 index 0000000..ffffa03 --- /dev/null +++ b/DouShouQiConsole/DouShouQiConsole/main.swift @@ -0,0 +1,11 @@ +// +// main.swift +// DouShouQiConsole +// +// Created by Louis DUFOUR on 17/01/2024. +// + +import Foundation + +print("Hello, World!") + From 4aef44cec5c1748bef9e8b5aa25239f529e4e569 Mon Sep 17 00:00:00 2001 From: louis Date: Wed, 17 Jan 2024 12:43:20 +0100 Subject: [PATCH 5/7] Update(Tp1): worksapce ok --- DouShouQiConsole/DouShouQiConsole/main.swift | 59 +++- {Extensions => Extension}/.gitignore | 0 {Extensions => Extension}/Package.swift | 12 +- {Extensions => Extension}/README.md | 2 +- .../Sources/Extension}/Animal.swift | 0 Extension/Sources/Extension/Board.swift | 23 ++ .../Sources/Extension}/CellType.swift | 0 .../Sources/Extension}/Owner.swift | 0 .../Tests/ExtensionTests/ExtensionTests.swift | 10 +- Extensions/Sources/Extensions/Board.swift | 25 -- .../xcshareddata/IDEWorkspaceChecks.plist | 8 - Model/Sources/Model/Board.swift | 2 +- Model/Sources/Model/Cell.swift | 16 +- Model/Sources/Model/Owner.swift | 8 - Model/Sources/Model/Piece.swift | 8 +- Model/Tests/ModelTests/ModelTests.swift | 6 +- .../project.pbxproj | 324 ------------------ .../contents.xcworkspacedata | 7 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - ProjectDouShouQi/Sources/main.swift | 64 ---- .../contents.xcworkspacedata | 13 + .../xcshareddata/IDEWorkspaceChecks.plist | 0 22 files changed, 124 insertions(+), 471 deletions(-) rename {Extensions => Extension}/.gitignore (100%) rename {Extensions => Extension}/Package.swift (79%) rename {Extensions => Extension}/README.md (71%) rename {Extensions/Sources/Extensions => Extension/Sources/Extension}/Animal.swift (100%) create mode 100644 Extension/Sources/Extension/Board.swift rename {Extensions/Sources/Extensions => Extension/Sources/Extension}/CellType.swift (100%) rename {Extensions/Sources/Extensions => Extension/Sources/Extension}/Owner.swift (100%) rename Extensions/Tests/ExtensionsTests/ExtensionsTests.swift => Extension/Tests/ExtensionTests/ExtensionTests.swift (61%) delete mode 100644 Extensions/Sources/Extensions/Board.swift delete mode 100644 Model/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.pbxproj delete mode 100644 ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 ProjectDouShouQi/Sources/main.swift create mode 100644 WorkSpaceDouShouQi.xcworkspace/contents.xcworkspacedata rename {Extensions/.swiftpm/xcode/package.xcworkspace => WorkSpaceDouShouQi.xcworkspace}/xcshareddata/IDEWorkspaceChecks.plist (100%) diff --git a/DouShouQiConsole/DouShouQiConsole/main.swift b/DouShouQiConsole/DouShouQiConsole/main.swift index ffffa03..f81fce8 100644 --- a/DouShouQiConsole/DouShouQiConsole/main.swift +++ b/DouShouQiConsole/DouShouQiConsole/main.swift @@ -1,11 +1,64 @@ // // main.swift -// DouShouQiConsole +// ProjectDouShouQi // -// Created by Louis DUFOUR on 17/01/2024. +// Created by Louis DUFOUR on 15/01/2024. // import Foundation +import Model +import Extension -print("Hello, World!") +let initialBoardConfiguration: [[Cell]] = [ + // Ligne 1 + [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .lion)), + Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .den), Cell(ofType: .trap), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .tiger))], + // Ligne 2 + [Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .dog)), + Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .jungle), + Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .cat)), Cell(ofType: .jungle)], + + // Ligne 3 + [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .rat)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .leopard)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .wolf)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .elephant))], + + // Lignes 4 à 7 (Eau et Jungle) + [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), + Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], + + [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), + Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], + + [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), + Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], + + [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), + Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], + + // Ligne 8 + [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .elephant)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .wolf)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .leopard)), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .rat))], + + // Ligne 9 + [Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .cat)), + Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .jungle), + Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .dog)), Cell(ofType: .jungle)], + + // Ligne 10 + [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .tiger)), + Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .den), Cell(ofType: .trap), + Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .lion))] +] + +if let board = Board(withGrid: initialBoardConfiguration) { + // Afficher le plateau de jeu + print(board.dispaly()) +} else { + print("Erreur lors de l'initialisation du plateau de jeu.") +} diff --git a/Extensions/.gitignore b/Extension/.gitignore similarity index 100% rename from Extensions/.gitignore rename to Extension/.gitignore diff --git a/Extensions/Package.swift b/Extension/Package.swift similarity index 79% rename from Extensions/Package.swift rename to Extension/Package.swift index 9b79cee..d9374c0 100644 --- a/Extensions/Package.swift +++ b/Extension/Package.swift @@ -4,12 +4,12 @@ import PackageDescription let package = Package( - name: "Extensions", + name: "Extension", products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( - name: "Extensions", - targets: ["Extensions"]), + name: "Extension", + targets: ["Extension"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. @@ -19,10 +19,10 @@ let package = Package( // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( - name: "Extensions", + name: "Extension", dependencies: []), .testTarget( - name: "ExtensionsTests", - dependencies: ["Extensions"]), + name: "ExtensionTests", + dependencies: ["Extension"]), ] ) diff --git a/Extensions/README.md b/Extension/README.md similarity index 71% rename from Extensions/README.md rename to Extension/README.md index 6e5d31f..16132f6 100644 --- a/Extensions/README.md +++ b/Extension/README.md @@ -1,3 +1,3 @@ -# Extensions +# Extension A description of this package. diff --git a/Extensions/Sources/Extensions/Animal.swift b/Extension/Sources/Extension/Animal.swift similarity index 100% rename from Extensions/Sources/Extensions/Animal.swift rename to Extension/Sources/Extension/Animal.swift diff --git a/Extension/Sources/Extension/Board.swift b/Extension/Sources/Extension/Board.swift new file mode 100644 index 0000000..e4042ef --- /dev/null +++ b/Extension/Sources/Extension/Board.swift @@ -0,0 +1,23 @@ +// +// File.swift +// +// +// Created by Louis DUFOUR on 15/01/2024. +// + +import Foundation +import Model + +public extension Board { + func display() { + for row in grid { + for cell in row { + if let _ = cell.piece{ + print(cell.display(), terminator: " ")} + else{ + print(cell.display(), terminator: " ")} + } + print() + } + } +} diff --git a/Extensions/Sources/Extensions/CellType.swift b/Extension/Sources/Extension/CellType.swift similarity index 100% rename from Extensions/Sources/Extensions/CellType.swift rename to Extension/Sources/Extension/CellType.swift diff --git a/Extensions/Sources/Extensions/Owner.swift b/Extension/Sources/Extension/Owner.swift similarity index 100% rename from Extensions/Sources/Extensions/Owner.swift rename to Extension/Sources/Extension/Owner.swift diff --git a/Extensions/Tests/ExtensionsTests/ExtensionsTests.swift b/Extension/Tests/ExtensionTests/ExtensionTests.swift similarity index 61% rename from Extensions/Tests/ExtensionsTests/ExtensionsTests.swift rename to Extension/Tests/ExtensionTests/ExtensionTests.swift index d129bd4..2de8524 100644 --- a/Extensions/Tests/ExtensionsTests/ExtensionsTests.swift +++ b/Extension/Tests/ExtensionTests/ExtensionTests.swift @@ -1,11 +1,13 @@ import XCTest -/*@testable import Extensions +@testable import Extension -final class ExtensionsTests: XCTestCase { +/* +final class ExtensionTests: XCTestCase { 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. - XCTAssertEqual(Extensions().text, "Hello, World!") + XCTAssertEqual(Extension().text, "Hello, World!") } -}*/ +} +*/ diff --git a/Extensions/Sources/Extensions/Board.swift b/Extensions/Sources/Extensions/Board.swift deleted file mode 100644 index d1ebb98..0000000 --- a/Extensions/Sources/Extensions/Board.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// File.swift -// -// -// Created by Louis DUFOUR on 15/01/2024. -// - -import Foundation -import Model - -public extension Board { - func toString() -> String { - var boardString = "" - for row in grid { - for cell in row { - let cellSymbol = cell.cellType.symbol - let pieceSymbol = cell.piece?.animal.symbol ?? " " - let ownerSymbol = cell.piece?.owner.symbol ?? " " - boardString += "\(cellSymbol)\(pieceSymbol)\(ownerSymbol) " - } - boardString += "\n\n" - } - return boardString - } -} diff --git a/Model/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Model/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Model/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Model/Sources/Model/Board.swift b/Model/Sources/Model/Board.swift index 49187df..b20ac86 100644 --- a/Model/Sources/Model/Board.swift +++ b/Model/Sources/Model/Board.swift @@ -10,7 +10,7 @@ import Foundation public struct Board { let nbRows: Int let nbColumns: Int - private var grid: [[Cell]] + public var grid: [[Cell]] public init?(withGrid grid: [[Cell]]) { guard let firstRowLength = grid.first?.count, grid.allSatisfy({ $0.count == firstRowLength }) else { diff --git a/Model/Sources/Model/Cell.swift b/Model/Sources/Model/Cell.swift index f080abf..8bf1075 100644 --- a/Model/Sources/Model/Cell.swift +++ b/Model/Sources/Model/Cell.swift @@ -8,9 +8,9 @@ import Foundation public struct Cell { - let cellType: CellType - let initialOwner: Owner - var piece: Piece? + public let cellType: CellType + public let initialOwner: Owner + public var piece: Piece? public init(ofType cellType: CellType, ownedBy initialOwner: Owner = .noOne, withPiece piece: Piece? = nil) { self.cellType = cellType @@ -18,8 +18,12 @@ public struct Cell { self.piece = piece } - func toString() -> String { - let pieceString = piece?.toString() ?? "ø" - return "\(pieceString) on .\(cellType), \(initialOwner.toString())" + public var Cell { + func display() -> String { + let cellSymbol = self.cellType.symbol + let pieceSymbol = self.piece?.display() ?? " " + return "\(cellSymbol)\(pieceSymbol)" + } } + } diff --git a/Model/Sources/Model/Owner.swift b/Model/Sources/Model/Owner.swift index 0a57e72..9a27739 100644 --- a/Model/Sources/Model/Owner.swift +++ b/Model/Sources/Model/Owner.swift @@ -9,13 +9,5 @@ import Foundation public enum Owner { case noOne, player1, player2 - - func toString() -> String { - switch self { - case .noOne: return "x" - case .player1: return "1" - case .player2: return "2" - } - } } diff --git a/Model/Sources/Model/Piece.swift b/Model/Sources/Model/Piece.swift index db9fe11..9ea8a75 100644 --- a/Model/Sources/Model/Piece.swift +++ b/Model/Sources/Model/Piece.swift @@ -8,15 +8,15 @@ import Foundation public struct Piece { - let owner: Owner - let animal: Animal + public let owner: Owner + public let animal: Animal public init(withOwner owner: Owner, andAnimal animal: Animal) { self.owner = owner self.animal = animal } - func toString() -> String { - return "[\(owner.toString()):\(animal)]" + public var description: String { + return "[\(owner):\(animal)]" } } diff --git a/Model/Tests/ModelTests/ModelTests.swift b/Model/Tests/ModelTests/ModelTests.swift index cf597ce..41e49f0 100644 --- a/Model/Tests/ModelTests/ModelTests.swift +++ b/Model/Tests/ModelTests/ModelTests.swift @@ -1,6 +1,7 @@ import XCTest -/*@testable import Model +@testable import Model +/* final class ModelTests: XCTestCase { func testExample() throws { // This is an example of a functional test case. @@ -8,4 +9,5 @@ final class ModelTests: XCTestCase { // results. XCTAssertEqual(Model().text, "Hello, World!") } -}*/ +} +*/ diff --git a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.pbxproj b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.pbxproj deleted file mode 100644 index bbb2172..0000000 --- a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.pbxproj +++ /dev/null @@ -1,324 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 56; - objects = { - -/* Begin PBXBuildFile section */ - 16F41E872B553BEA007D4B7F /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16F41E862B553BEA007D4B7F /* main.swift */; }; - 16F41E942B5546C4007D4B7F /* Model in Frameworks */ = {isa = PBXBuildFile; productRef = 16F41E932B5546C4007D4B7F /* Model */; }; - 16F41E962B5546C7007D4B7F /* Extensions in Frameworks */ = {isa = PBXBuildFile; productRef = 16F41E952B5546C7007D4B7F /* Extensions */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 16F41E812B553BEA007D4B7F /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 16F41E832B553BEA007D4B7F /* ProjectDouShouQi */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ProjectDouShouQi; sourceTree = BUILT_PRODUCTS_DIR; }; - 16F41E862B553BEA007D4B7F /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; - 16F41E8E2B553BFE007D4B7F /* Model */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Model; path = ../Model; sourceTree = ""; }; - 16F41E902B55409F007D4B7F /* Extensions */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Extensions; path = ../Extensions; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 16F41E802B553BEA007D4B7F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 16F41E962B5546C7007D4B7F /* Extensions in Frameworks */, - 16F41E942B5546C4007D4B7F /* Model in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 16F41E7A2B553BE9007D4B7F = { - isa = PBXGroup; - children = ( - 16F41E8D2B553BFE007D4B7F /* Packages */, - 16F41E852B553BEA007D4B7F /* Sources */, - 16F41E842B553BEA007D4B7F /* Products */, - 16F41E922B5546C4007D4B7F /* Frameworks */, - ); - sourceTree = ""; - }; - 16F41E842B553BEA007D4B7F /* Products */ = { - isa = PBXGroup; - children = ( - 16F41E832B553BEA007D4B7F /* ProjectDouShouQi */, - ); - name = Products; - sourceTree = ""; - }; - 16F41E852B553BEA007D4B7F /* Sources */ = { - isa = PBXGroup; - children = ( - 16F41E862B553BEA007D4B7F /* main.swift */, - ); - path = Sources; - sourceTree = ""; - }; - 16F41E8D2B553BFE007D4B7F /* Packages */ = { - isa = PBXGroup; - children = ( - 16F41E8E2B553BFE007D4B7F /* Model */, - 16F41E902B55409F007D4B7F /* Extensions */, - ); - name = Packages; - sourceTree = ""; - }; - 16F41E922B5546C4007D4B7F /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 16F41E822B553BEA007D4B7F /* ProjectDouShouQi */ = { - isa = PBXNativeTarget; - buildConfigurationList = 16F41E8A2B553BEA007D4B7F /* Build configuration list for PBXNativeTarget "ProjectDouShouQi" */; - buildPhases = ( - 16F41E7F2B553BEA007D4B7F /* Sources */, - 16F41E802B553BEA007D4B7F /* Frameworks */, - 16F41E812B553BEA007D4B7F /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ProjectDouShouQi; - packageProductDependencies = ( - 16F41E932B5546C4007D4B7F /* Model */, - 16F41E952B5546C7007D4B7F /* Extensions */, - ); - productName = ProjectDouShouQi; - productReference = 16F41E832B553BEA007D4B7F /* ProjectDouShouQi */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 16F41E7B2B553BE9007D4B7F /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1420; - LastUpgradeCheck = 1420; - TargetAttributes = { - 16F41E822B553BEA007D4B7F = { - CreatedOnToolsVersion = 14.2; - }; - }; - }; - buildConfigurationList = 16F41E7E2B553BE9007D4B7F /* Build configuration list for PBXProject "ProjectDouShouQi" */; - compatibilityVersion = "Xcode 14.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 16F41E7A2B553BE9007D4B7F; - productRefGroup = 16F41E842B553BEA007D4B7F /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 16F41E822B553BEA007D4B7F /* ProjectDouShouQi */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 16F41E7F2B553BEA007D4B7F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 16F41E872B553BEA007D4B7F /* main.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 16F41E882B553BEA007D4B7F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 13.1; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 16F41E892B553BEA007D4B7F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 13.1; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Release; - }; - 16F41E8B2B553BEA007D4B7F /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 16F41E8C2B553BEA007D4B7F /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 16F41E7E2B553BE9007D4B7F /* Build configuration list for PBXProject "ProjectDouShouQi" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 16F41E882B553BEA007D4B7F /* Debug */, - 16F41E892B553BEA007D4B7F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 16F41E8A2B553BEA007D4B7F /* Build configuration list for PBXNativeTarget "ProjectDouShouQi" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 16F41E8B2B553BEA007D4B7F /* Debug */, - 16F41E8C2B553BEA007D4B7F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCSwiftPackageProductDependency section */ - 16F41E932B5546C4007D4B7F /* Model */ = { - isa = XCSwiftPackageProductDependency; - productName = Model; - }; - 16F41E952B5546C7007D4B7F /* Extensions */ = { - isa = XCSwiftPackageProductDependency; - productName = Extensions; - }; -/* End XCSwiftPackageProductDependency section */ - }; - rootObject = 16F41E7B2B553BE9007D4B7F /* Project object */; -} diff --git a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/ProjectDouShouQi/ProjectDouShouQi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/ProjectDouShouQi/Sources/main.swift b/ProjectDouShouQi/Sources/main.swift deleted file mode 100644 index 29accda..0000000 --- a/ProjectDouShouQi/Sources/main.swift +++ /dev/null @@ -1,64 +0,0 @@ -// -// main.swift -// ProjectDouShouQi -// -// Created by Louis DUFOUR on 15/01/2024. -// - -import Foundation -import Model -import Extensions - -let initialBoardConfiguration: [[Cell]] = [ - // Ligne 1 - [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .lion)), - Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .den), Cell(ofType: .trap), - Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .tiger))], - - // Ligne 2 - [Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .dog)), - Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .jungle), - Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .cat)), Cell(ofType: .jungle)], - - // Ligne 3 - [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .rat)), - Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .leopard)), - Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .wolf)), - Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .elephant))], - - // Lignes 4 à 7 (Eau et Jungle) - [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), - Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], - - [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), - Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], - - [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), - Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], - - [Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), - Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)], - - // Ligne 8 - [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .elephant)), - Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .wolf)), - Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .leopard)), - Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .rat))], - - // Ligne 9 - [Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .cat)), - Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .jungle), - Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .dog)), Cell(ofType: .jungle)], - - // Ligne 10 - [Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .tiger)), - Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .den), Cell(ofType: .trap), - Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .lion))] -] - -if let board = Board(withGrid: initialBoardConfiguration) { - // Afficher le plateau de jeu - print(board.toString()) -} else { - print("Erreur lors de l'initialisation du plateau de jeu.") -} diff --git a/WorkSpaceDouShouQi.xcworkspace/contents.xcworkspacedata b/WorkSpaceDouShouQi.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..e8da9c7 --- /dev/null +++ b/WorkSpaceDouShouQi.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/Extensions/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/WorkSpaceDouShouQi.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from Extensions/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to WorkSpaceDouShouQi.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist From 051e68e176beb78aaad65c9e6805a4fd29b2572d Mon Sep 17 00:00:00 2001 From: louis Date: Wed, 17 Jan 2024 13:23:41 +0100 Subject: [PATCH 6/7] Update(Tp1): Fonctionne --- .../project.pbxproj | 27 +++++++++++++++++++ DouShouQiConsole/DouShouQiConsole/main.swift | 2 +- Extension/Package.swift | 5 ++-- Extension/Sources/Extension/Board.swift | 11 +++++--- Model/Sources/Model/Animal.swift | 27 ++++++++++++++++++- Model/Sources/Model/Board.swift | 12 +++++++++ Model/Sources/Model/Cell.swift | 22 ++++++++------- Model/Sources/Model/CellType.swift | 16 +++++++++++ Model/Sources/Model/Owner.swift | 12 +++++++++ Model/Sources/Model/Piece.swift | 4 +-- 10 files changed, 118 insertions(+), 20 deletions(-) diff --git a/DouShouQiConsole/DouShouQiConsole.xcodeproj/project.pbxproj b/DouShouQiConsole/DouShouQiConsole.xcodeproj/project.pbxproj index 013f732..d8d7311 100644 --- a/DouShouQiConsole/DouShouQiConsole.xcodeproj/project.pbxproj +++ b/DouShouQiConsole/DouShouQiConsole.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 167C5A152B57F0BC006FB682 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 167C5A142B57F0BC006FB682 /* main.swift */; }; + 16CE03F62B57F58E00A85305 /* Extension in Frameworks */ = {isa = PBXBuildFile; productRef = 16CE03F52B57F58E00A85305 /* Extension */; }; + 16CE03F82B57F59200A85305 /* Model in Frameworks */ = {isa = PBXBuildFile; productRef = 16CE03F72B57F59200A85305 /* Model */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -32,6 +34,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 16CE03F82B57F59200A85305 /* Model in Frameworks */, + 16CE03F62B57F58E00A85305 /* Extension in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -43,6 +47,7 @@ children = ( 167C5A132B57F0BC006FB682 /* DouShouQiConsole */, 167C5A122B57F0BC006FB682 /* Products */, + 16CE03F42B57F58E00A85305 /* Frameworks */, ); sourceTree = ""; }; @@ -62,6 +67,13 @@ path = DouShouQiConsole; sourceTree = ""; }; + 16CE03F42B57F58E00A85305 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -78,6 +90,10 @@ dependencies = ( ); name = DouShouQiConsole; + packageProductDependencies = ( + 16CE03F52B57F58E00A85305 /* Extension */, + 16CE03F72B57F59200A85305 /* Model */, + ); productName = DouShouQiConsole; productReference = 167C5A112B57F0BC006FB682 /* DouShouQiConsole */; productType = "com.apple.product-type.tool"; @@ -280,6 +296,17 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 16CE03F52B57F58E00A85305 /* Extension */ = { + isa = XCSwiftPackageProductDependency; + productName = Extension; + }; + 16CE03F72B57F59200A85305 /* Model */ = { + isa = XCSwiftPackageProductDependency; + productName = Model; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 167C5A092B57F0BC006FB682 /* Project object */; } diff --git a/DouShouQiConsole/DouShouQiConsole/main.swift b/DouShouQiConsole/DouShouQiConsole/main.swift index f81fce8..40a5085 100644 --- a/DouShouQiConsole/DouShouQiConsole/main.swift +++ b/DouShouQiConsole/DouShouQiConsole/main.swift @@ -58,7 +58,7 @@ let initialBoardConfiguration: [[Cell]] = [ if let board = Board(withGrid: initialBoardConfiguration) { // Afficher le plateau de jeu - print(board.dispaly()) + print(board.display()) } else { print("Erreur lors de l'initialisation du plateau de jeu.") } diff --git a/Extension/Package.swift b/Extension/Package.swift index d9374c0..ffc8005 100644 --- a/Extension/Package.swift +++ b/Extension/Package.swift @@ -14,15 +14,16 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), + .package(path: "../Model"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "Extension", - dependencies: []), + dependencies: ["Model"]), .testTarget( name: "ExtensionTests", - dependencies: ["Extension"]), + dependencies: ["Extension", "Model"]), ] ) diff --git a/Extension/Sources/Extension/Board.swift b/Extension/Sources/Extension/Board.swift index e4042ef..818fd25 100644 --- a/Extension/Sources/Extension/Board.swift +++ b/Extension/Sources/Extension/Board.swift @@ -8,14 +8,17 @@ import Foundation import Model + public extension Board { func display() { for row in grid { for cell in row { - if let _ = cell.piece{ - print(cell.display(), terminator: " ")} - else{ - print(cell.display(), terminator: " ")} + if let piece = cell.piece { + + print(cell.cellType.symbol + piece.owner.symbol + piece.animal.symbol, terminator: " ")} + else { + + print(cell.cellType.symbol, terminator: " ")} } print() } diff --git a/Model/Sources/Model/Animal.swift b/Model/Sources/Model/Animal.swift index 543dff5..1869392 100644 --- a/Model/Sources/Model/Animal.swift +++ b/Model/Sources/Model/Animal.swift @@ -7,5 +7,30 @@ import Foundation -public enum Animal: String { case rat, cat, dog, wolf, leopard, tiger, lion, elephant } +public enum Animal: String { case rat, cat, dog, wolf, leopard, tiger, lion, elephant + + + + public var description: String { + switch self { + case .rat: + return "Rat" + case .cat: + return "Cat" + case .dog: + return "Dog" + case .wolf: + return "Wolf" + case .leopard: + return "Leopard" + case .tiger: + return "Tiger" + case .lion: + return "Lion" + case .elephant: + return "Elephant" + } + } +} + diff --git a/Model/Sources/Model/Board.swift b/Model/Sources/Model/Board.swift index b20ac86..3909a4b 100644 --- a/Model/Sources/Model/Board.swift +++ b/Model/Sources/Model/Board.swift @@ -28,5 +28,17 @@ public struct Board { } return grid[row][column] } + + public var description: String { + var boardDescription = "" + for row in grid { + for cell in row { + boardDescription += cell.description + " " + } + boardDescription += "\n" + } + return boardDescription + } } + diff --git a/Model/Sources/Model/Cell.swift b/Model/Sources/Model/Cell.swift index 8bf1075..5e0c616 100644 --- a/Model/Sources/Model/Cell.swift +++ b/Model/Sources/Model/Cell.swift @@ -9,21 +9,23 @@ import Foundation public struct Cell { public let cellType: CellType - public let initialOwner: Owner + public var initialOwner: Owner public var piece: Piece? - public init(ofType cellType: CellType, ownedBy initialOwner: Owner = .noOne, withPiece piece: Piece? = nil) { + public init(ofType cellType: CellType, ownedBy initialOwner: Owner = .noOne, withPiece piece: Piece? = nil) { self.cellType = cellType self.initialOwner = initialOwner self.piece = piece } - public var Cell { - func display() -> String { - let cellSymbol = self.cellType.symbol - let pieceSymbol = self.piece?.display() ?? " " - return "\(cellSymbol)\(pieceSymbol)" - } - } - + public var description: String { + var pieceDescription = "nil" + if let piece = piece { + pieceDescription = piece.description + } + return "Cell(type: (cellType), owner: (initialOwner), piece: (pieceDescription))" + } } + + + diff --git a/Model/Sources/Model/CellType.swift b/Model/Sources/Model/CellType.swift index 1430450..f59fc22 100644 --- a/Model/Sources/Model/CellType.swift +++ b/Model/Sources/Model/CellType.swift @@ -9,4 +9,20 @@ import Foundation public enum CellType { case unknown, jungle, water, trap, den + + public var description: String { + switch self { + case .unknown: + return "unknown cell" + case .jungle: + return "jungle cell" + case .water: + return "water cell" + case .trap: + return "trap cell" + case .den: + return "den cell" + } + } } + diff --git a/Model/Sources/Model/Owner.swift b/Model/Sources/Model/Owner.swift index 9a27739..7bd92d9 100644 --- a/Model/Sources/Model/Owner.swift +++ b/Model/Sources/Model/Owner.swift @@ -9,5 +9,17 @@ import Foundation public enum Owner { case noOne, player1, player2 + + public var description: String { + switch self { + case .player1: + return "1" + case .player2: + return "2" + case .noOne: + return "x" + } + } } + diff --git a/Model/Sources/Model/Piece.swift b/Model/Sources/Model/Piece.swift index 9ea8a75..1d6f8c4 100644 --- a/Model/Sources/Model/Piece.swift +++ b/Model/Sources/Model/Piece.swift @@ -17,6 +17,6 @@ public struct Piece { } public var description: String { - return "[\(owner):\(animal)]" - } + return "[(owner):(animal)]" + } } From 3a6245e2cfa8d651a61d27d052936bf0fd46131e Mon Sep 17 00:00:00 2001 From: louis Date: Wed, 17 Jan 2024 13:28:29 +0100 Subject: [PATCH 7/7] Update(Tp1): Format --- Extension/Sources/Extension/Board.swift | 2 -- Model/Sources/Model/Animal.swift | 40 ++++++++++++------------- Model/Sources/Model/Board.swift | 16 +++++----- Model/Sources/Model/Cell.swift | 12 ++++---- Model/Sources/Model/CellType.swift | 24 +++++++-------- Model/Sources/Model/Owner.swift | 2 +- 6 files changed, 46 insertions(+), 50 deletions(-) diff --git a/Extension/Sources/Extension/Board.swift b/Extension/Sources/Extension/Board.swift index 818fd25..995e0f0 100644 --- a/Extension/Sources/Extension/Board.swift +++ b/Extension/Sources/Extension/Board.swift @@ -14,10 +14,8 @@ public extension Board { for row in grid { for cell in row { if let piece = cell.piece { - print(cell.cellType.symbol + piece.owner.symbol + piece.animal.symbol, terminator: " ")} else { - print(cell.cellType.symbol, terminator: " ")} } print() diff --git a/Model/Sources/Model/Animal.swift b/Model/Sources/Model/Animal.swift index 1869392..521f6d9 100644 --- a/Model/Sources/Model/Animal.swift +++ b/Model/Sources/Model/Animal.swift @@ -9,28 +9,26 @@ import Foundation public enum Animal: String { case rat, cat, dog, wolf, leopard, tiger, lion, elephant - - public var description: String { - switch self { - case .rat: - return "Rat" - case .cat: - return "Cat" - case .dog: - return "Dog" - case .wolf: - return "Wolf" - case .leopard: - return "Leopard" - case .tiger: - return "Tiger" - case .lion: - return "Lion" - case .elephant: - return "Elephant" - } - } + switch self { + case .rat: + return "Rat" + case .cat: + return "Cat" + case .dog: + return "Dog" + case .wolf: + return "Wolf" + case .leopard: + return "Leopard" + case .tiger: + return "Tiger" + case .lion: + return "Lion" + case .elephant: + return "Elephant" + } + } } diff --git a/Model/Sources/Model/Board.swift b/Model/Sources/Model/Board.swift index 3909a4b..f89fa3a 100644 --- a/Model/Sources/Model/Board.swift +++ b/Model/Sources/Model/Board.swift @@ -30,15 +30,15 @@ public struct Board { } public var description: String { - var boardDescription = "" - for row in grid { - for cell in row { - boardDescription += cell.description + " " - } - boardDescription += "\n" - } - return boardDescription + var boardDescription = "" + for row in grid { + for cell in row { + boardDescription += cell.description + " " } + boardDescription += "\n" + } + return boardDescription + } } diff --git a/Model/Sources/Model/Cell.swift b/Model/Sources/Model/Cell.swift index 5e0c616..ec96bc8 100644 --- a/Model/Sources/Model/Cell.swift +++ b/Model/Sources/Model/Cell.swift @@ -19,12 +19,12 @@ public struct Cell { } public var description: String { - var pieceDescription = "nil" - if let piece = piece { - pieceDescription = piece.description - } - return "Cell(type: (cellType), owner: (initialOwner), piece: (pieceDescription))" - } + var pieceDescription = "nil" + if let piece = piece { + pieceDescription = piece.description + } + return "Cell(type: (cellType), owner: (initialOwner), piece: (pieceDescription))" + } } diff --git a/Model/Sources/Model/CellType.swift b/Model/Sources/Model/CellType.swift index f59fc22..875102b 100644 --- a/Model/Sources/Model/CellType.swift +++ b/Model/Sources/Model/CellType.swift @@ -11,18 +11,18 @@ public enum CellType { case unknown, jungle, water, trap, den public var description: String { - switch self { - case .unknown: - return "unknown cell" - case .jungle: - return "jungle cell" - case .water: - return "water cell" - case .trap: - return "trap cell" - case .den: - return "den cell" - } + switch self { + case .unknown: + return "unknown cell" + case .jungle: + return "jungle cell" + case .water: + return "water cell" + case .trap: + return "trap cell" + case .den: + return "den cell" } + } } diff --git a/Model/Sources/Model/Owner.swift b/Model/Sources/Model/Owner.swift index 7bd92d9..137d78e 100644 --- a/Model/Sources/Model/Owner.swift +++ b/Model/Sources/Model/Owner.swift @@ -9,7 +9,7 @@ import Foundation public enum Owner { case noOne, player1, player2 - + public var description: String { switch self { case .player1: